Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
31a61ccc
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
31a61ccc
编写于
12月 30, 2020
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move rustc_mir::borrow_check to new crate rustc_borrowck.
上级
8ceea01b
变更
64
隐藏空白更改
内联
并排
Showing
64 changed file
with
372 addition
and
315 deletion
+372
-315
Cargo.lock
Cargo.lock
+27
-2
compiler/rustc_borrowck/Cargo.toml
compiler/rustc_borrowck/Cargo.toml
+30
-0
compiler/rustc_borrowck/src/borrow_set.rs
compiler/rustc_borrowck/src/borrow_set.rs
+5
-5
compiler/rustc_borrowck/src/borrowck_errors.rs
compiler/rustc_borrowck/src/borrowck_errors.rs
+1
-1
compiler/rustc_borrowck/src/constraint_generation.rs
compiler/rustc_borrowck/src/constraint_generation.rs
+1
-1
compiler/rustc_borrowck/src/constraints/graph.rs
compiler/rustc_borrowck/src/constraints/graph.rs
+1
-1
compiler/rustc_borrowck/src/constraints/mod.rs
compiler/rustc_borrowck/src/constraints/mod.rs
+1
-1
compiler/rustc_borrowck/src/consumers.rs
compiler/rustc_borrowck/src/consumers.rs
+0
-0
compiler/rustc_borrowck/src/dataflow.rs
compiler/rustc_borrowck/src/dataflow.rs
+101
-8
compiler/rustc_borrowck/src/def_use.rs
compiler/rustc_borrowck/src/def_use.rs
+0
-0
compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
...ler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
+2
-2
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+14
-14
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
+8
-8
compiler/rustc_borrowck/src/diagnostics/find_use.rs
compiler/rustc_borrowck/src/diagnostics/find_use.rs
+1
-1
compiler/rustc_borrowck/src/diagnostics/mod.rs
compiler/rustc_borrowck/src/diagnostics/mod.rs
+7
-4
compiler/rustc_borrowck/src/diagnostics/move_errors.rs
compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+6
-6
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
+3
-3
compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
...ler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
+3
-5
compiler/rustc_borrowck/src/diagnostics/region_errors.rs
compiler/rustc_borrowck/src/diagnostics/region_errors.rs
+5
-5
compiler/rustc_borrowck/src/diagnostics/region_name.rs
compiler/rustc_borrowck/src/diagnostics/region_name.rs
+1
-1
compiler/rustc_borrowck/src/diagnostics/var_name.rs
compiler/rustc_borrowck/src/diagnostics/var_name.rs
+2
-2
compiler/rustc_borrowck/src/facts.rs
compiler/rustc_borrowck/src/facts.rs
+3
-8
compiler/rustc_borrowck/src/invalidation.rs
compiler/rustc_borrowck/src/invalidation.rs
+3
-5
compiler/rustc_borrowck/src/lib.rs
compiler/rustc_borrowck/src/lib.rs
+40
-19
compiler/rustc_borrowck/src/location.rs
compiler/rustc_borrowck/src/location.rs
+0
-0
compiler/rustc_borrowck/src/member_constraints.rs
compiler/rustc_borrowck/src/member_constraints.rs
+0
-0
compiler/rustc_borrowck/src/nll.rs
compiler/rustc_borrowck/src/nll.rs
+8
-8
compiler/rustc_borrowck/src/path_utils.rs
compiler/rustc_borrowck/src/path_utils.rs
+5
-5
compiler/rustc_borrowck/src/place_ext.rs
compiler/rustc_borrowck/src/place_ext.rs
+1
-1
compiler/rustc_borrowck/src/places_conflict.rs
compiler/rustc_borrowck/src/places_conflict.rs
+3
-3
compiler/rustc_borrowck/src/prefixes.rs
compiler/rustc_borrowck/src/prefixes.rs
+0
-0
compiler/rustc_borrowck/src/region_infer/dump_mir.rs
compiler/rustc_borrowck/src/region_infer/dump_mir.rs
+1
-1
compiler/rustc_borrowck/src/region_infer/graphviz.rs
compiler/rustc_borrowck/src/region_infer/graphviz.rs
+1
-1
compiler/rustc_borrowck/src/region_infer/mod.rs
compiler/rustc_borrowck/src/region_infer/mod.rs
+11
-11
compiler/rustc_borrowck/src/region_infer/opaque_types.rs
compiler/rustc_borrowck/src/region_infer/opaque_types.rs
+2
-2
compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
+2
-2
compiler/rustc_borrowck/src/region_infer/values.rs
compiler/rustc_borrowck/src/region_infer/values.rs
+0
-0
compiler/rustc_borrowck/src/renumber.rs
compiler/rustc_borrowck/src/renumber.rs
+0
-0
compiler/rustc_borrowck/src/type_check/canonical.rs
compiler/rustc_borrowck/src/type_check/canonical.rs
+1
-1
compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
...er/rustc_borrowck/src/type_check/constraint_conversion.rs
+1
-1
compiler/rustc_borrowck/src/type_check/free_region_relations.rs
...er/rustc_borrowck/src/type_check/free_region_relations.rs
+2
-2
compiler/rustc_borrowck/src/type_check/input_output.rs
compiler/rustc_borrowck/src/type_check/input_output.rs
+3
-4
compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs
...r/rustc_borrowck/src/type_check/liveness/local_use_map.rs
+2
-2
compiler/rustc_borrowck/src/type_check/liveness/mod.rs
compiler/rustc_borrowck/src/type_check/liveness/mod.rs
+4
-4
compiler/rustc_borrowck/src/type_check/liveness/polonius.rs
compiler/rustc_borrowck/src/type_check/liveness/polonius.rs
+3
-4
compiler/rustc_borrowck/src/type_check/liveness/trace.rs
compiler/rustc_borrowck/src/type_check/liveness/trace.rs
+4
-5
compiler/rustc_borrowck/src/type_check/mod.rs
compiler/rustc_borrowck/src/type_check/mod.rs
+7
-7
compiler/rustc_borrowck/src/type_check/relate_tys.rs
compiler/rustc_borrowck/src/type_check/relate_tys.rs
+3
-3
compiler/rustc_borrowck/src/universal_regions.rs
compiler/rustc_borrowck/src/universal_regions.rs
+1
-1
compiler/rustc_borrowck/src/used_muts.rs
compiler/rustc_borrowck/src/used_muts.rs
+2
-3
compiler/rustc_interface/Cargo.toml
compiler/rustc_interface/Cargo.toml
+1
-0
compiler/rustc_interface/src/passes.rs
compiler/rustc_interface/src/passes.rs
+2
-0
compiler/rustc_mir/Cargo.toml
compiler/rustc_mir/Cargo.toml
+6
-8
compiler/rustc_mir/src/dataflow/drop_flag_effects.rs
compiler/rustc_mir/src/dataflow/drop_flag_effects.rs
+1
-1
compiler/rustc_mir/src/dataflow/framework/mod.rs
compiler/rustc_mir/src/dataflow/framework/mod.rs
+1
-2
compiler/rustc_mir/src/dataflow/framework/visitor.rs
compiler/rustc_mir/src/dataflow/framework/visitor.rs
+0
-93
compiler/rustc_mir/src/dataflow/impls/mod.rs
compiler/rustc_mir/src/dataflow/impls/mod.rs
+0
-2
compiler/rustc_mir/src/dataflow/mod.rs
compiler/rustc_mir/src/dataflow/mod.rs
+6
-9
compiler/rustc_mir/src/dataflow/move_paths/mod.rs
compiler/rustc_mir/src/dataflow/move_paths/mod.rs
+10
-4
compiler/rustc_mir/src/lib.rs
compiler/rustc_mir/src/lib.rs
+9
-18
compiler/rustc_mir/src/transform/promote_consts.rs
compiler/rustc_mir/src/transform/promote_consts.rs
+1
-1
compiler/rustc_mir/src/util/collect_writes.rs
compiler/rustc_mir/src/util/collect_writes.rs
+1
-1
compiler/rustc_mir/src/util/mod.rs
compiler/rustc_mir/src/util/mod.rs
+1
-2
compiler/rustc_mir/src/util/pretty.rs
compiler/rustc_mir/src/util/pretty.rs
+1
-1
未找到文件。
Cargo.lock
浏览文件 @
31a61ccc
...
...
@@ -3598,6 +3598,32 @@ dependencies = [
"rustc_span",
]
[[package]]
name = "rustc_borrowck"
version = "0.0.0"
dependencies = [
"either",
"itertools 0.9.0",
"polonius-engine",
"rustc_data_structures",
"rustc_errors",
"rustc_graphviz",
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_lexer",
"rustc_middle",
"rustc_mir",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
"tracing",
]
[[package]]
name = "rustc_builtin_macros"
version = "0.0.0"
...
...
@@ -3888,6 +3914,7 @@ dependencies = [
"rustc_ast_lowering",
"rustc_ast_passes",
"rustc_attr",
"rustc_borrowck",
"rustc_builtin_macros",
"rustc_codegen_llvm",
"rustc_codegen_ssa",
...
...
@@ -4059,7 +4086,6 @@ dependencies = [
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_lexer",
"rustc_macros",
"rustc_middle",
"rustc_serialize",
...
...
@@ -4067,7 +4093,6 @@ dependencies = [
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
"tracing",
]
...
...
compiler/rustc_borrowck/Cargo.toml
0 → 100644
浏览文件 @
31a61ccc
[package]
authors
=
[
"The Rust Project Developers"
]
name
=
"rustc_borrowck"
version
=
"0.0.0"
edition
=
"2018"
[lib]
doctest
=
false
[dependencies]
either
=
"1.5.0"
itertools
=
"0.9"
tracing
=
"0.1"
polonius-engine
=
"0.13.0"
smallvec
=
{
version
=
"1.6.1"
,
features
=
[
"union"
,
"may_dangle"
]
}
rustc_data_structures
=
{
path
=
"../rustc_data_structures"
}
rustc_errors
=
{
path
=
"../rustc_errors"
}
rustc_graphviz
=
{
path
=
"../rustc_graphviz"
}
rustc_hir
=
{
path
=
"../rustc_hir"
}
rustc_index
=
{
path
=
"../rustc_index"
}
rustc_infer
=
{
path
=
"../rustc_infer"
}
rustc_lexer
=
{
path
=
"../rustc_lexer"
}
rustc_middle
=
{
path
=
"../rustc_middle"
}
rustc_mir
=
{
path
=
"../rustc_mir"
}
rustc_serialize
=
{
path
=
"../rustc_serialize"
}
rustc_session
=
{
path
=
"../rustc_session"
}
rustc_target
=
{
path
=
"../rustc_target"
}
rustc_trait_selection
=
{
path
=
"../rustc_trait_selection"
}
rustc_traits
=
{
path
=
"../rustc_traits"
}
rustc_span
=
{
path
=
"../rustc_span"
}
compiler/rustc_
mir/src/borrow_check
/borrow_set.rs
→
compiler/rustc_
borrowck/src
/borrow_set.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
nll
::
ToRegionVid
;
use
crate
::
borrow_check
::
path_utils
::
allow_two_phase_borrow
;
use
crate
::
borrow_check
::
place_ext
::
PlaceExt
;
use
crate
::
dataflow
::
indexes
::
BorrowIndex
;
use
crate
::
dataflow
::
move_paths
::
MoveData
;
use
crate
::
nll
::
ToRegionVid
;
use
crate
::
path_utils
::
allow_two_phase_borrow
;
use
crate
::
place_ext
::
PlaceExt
;
use
crate
::
BorrowIndex
;
use
rustc_data_structures
::
fx
::{
FxHashMap
,
FxHashSet
,
FxIndexMap
};
use
rustc_index
::
bit_set
::
BitSet
;
use
rustc_middle
::
mir
::
traversal
;
use
rustc_middle
::
mir
::
visit
::{
MutatingUseContext
,
NonUseContext
,
PlaceContext
,
Visitor
};
use
rustc_middle
::
mir
::{
self
,
Body
,
Local
,
Location
};
use
rustc_middle
::
ty
::{
RegionVid
,
TyCtxt
};
use
rustc_mir
::
dataflow
::
move_paths
::
MoveData
;
use
std
::
fmt
;
use
std
::
ops
::
Index
;
...
...
compiler/rustc_
mir/src/util
/borrowck_errors.rs
→
compiler/rustc_
borrowck/src
/borrowck_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -2,7 +2,7 @@
use
rustc_middle
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_span
::{
MultiSpan
,
Span
};
impl
<
'cx
,
'tcx
>
crate
::
borrow_check
::
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
impl
<
'cx
,
'tcx
>
crate
::
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
crate
fn
cannot_move_when_borrowed
(
&
self
,
span
:
Span
,
desc
:
&
str
)
->
DiagnosticBuilder
<
'cx
>
{
struct_span_err!
(
self
,
span
,
E0505
,
"cannot move out of {} because it is borrowed"
,
desc
,)
}
...
...
compiler/rustc_
mir/src/borrow_check
/constraint_generation.rs
→
compiler/rustc_
borrowck/src
/constraint_generation.rs
浏览文件 @
31a61ccc
...
...
@@ -9,7 +9,7 @@
use
rustc_middle
::
ty
::
subst
::
SubstsRef
;
use
rustc_middle
::
ty
::{
self
,
RegionVid
,
Ty
};
use
crate
::
borrow_check
::
{
use
crate
::{
borrow_set
::
BorrowSet
,
facts
::
AllFacts
,
location
::
LocationTable
,
nll
::
ToRegionVid
,
places_conflict
,
region_infer
::
values
::
LivenessValues
,
};
...
...
compiler/rustc_
mir/src/borrow_check
/constraints/graph.rs
→
compiler/rustc_
borrowck/src
/constraints/graph.rs
浏览文件 @
31a61ccc
...
...
@@ -4,7 +4,7 @@
use
rustc_middle
::
ty
::{
RegionVid
,
VarianceDiagInfo
};
use
rustc_span
::
DUMMY_SP
;
use
crate
::
borrow_check
::
{
use
crate
::{
constraints
::
OutlivesConstraintIndex
,
constraints
::{
OutlivesConstraint
,
OutlivesConstraintSet
},
type_check
::
Locations
,
...
...
compiler/rustc_
mir/src/borrow_check
/constraints/mod.rs
→
compiler/rustc_
borrowck/src
/constraints/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -5,7 +5,7 @@
use
std
::
fmt
;
use
std
::
ops
::
Index
;
use
crate
::
borrow_check
::
type_check
::
Locations
;
use
crate
::
type_check
::
Locations
;
crate
mod
graph
;
...
...
compiler/rustc_
mir/src/borrow_check
/consumers.rs
→
compiler/rustc_
borrowck/src
/consumers.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/dataflow/impls/borrows
.rs
→
compiler/rustc_
borrowck/src/dataflow
.rs
浏览文件 @
31a61ccc
use
rustc_middle
::
mir
::{
self
,
Body
,
Location
,
Place
};
use
rustc_middle
::
ty
::
RegionVid
;
use
rustc_middle
::
ty
::
TyCtxt
;
use
rustc_data_structures
::
fx
::
FxHashMap
;
use
rustc_index
::
bit_set
::
BitSet
;
use
rustc_middle
::
mir
::{
self
,
BasicBlock
,
Body
,
Location
,
Place
};
use
rustc_middle
::
ty
::
RegionVid
;
use
rustc_middle
::
ty
::
TyCtxt
;
use
rustc_mir
::
dataflow
::
impls
::{
EverInitializedPlaces
,
MaybeUninitializedPlaces
};
use
rustc_mir
::
dataflow
::
ResultsVisitable
;
use
rustc_mir
::
dataflow
::{
self
,
fmt
::
DebugWithContext
,
GenKill
};
use
rustc_mir
::
dataflow
::{
Analysis
,
Direction
,
Results
};
use
std
::
fmt
;
use
std
::
iter
;
use
crate
::
borrow_check
::
{
use
crate
::{
places_conflict
,
BorrowSet
,
PlaceConflictBias
,
PlaceExt
,
RegionInferenceContext
,
ToRegionVid
,
};
use
crate
::
dataflow
::{
self
,
fmt
::
DebugWithContext
,
GenKill
};
use
std
::
fmt
;
use
std
::
iter
;
/// A tuple with named fields that can hold either the results or the transient state of the
/// dataflow analyses used by the borrow checker.
#[derive(Debug)]
pub
struct
BorrowckAnalyses
<
B
,
U
,
E
>
{
pub
borrows
:
B
,
pub
uninits
:
U
,
pub
ever_inits
:
E
,
}
/// The results of the dataflow analyses used by the borrow checker.
pub
type
BorrowckResults
<
'mir
,
'tcx
>
=
BorrowckAnalyses
<
Results
<
'tcx
,
Borrows
<
'mir
,
'tcx
>>
,
Results
<
'tcx
,
MaybeUninitializedPlaces
<
'mir
,
'tcx
>>
,
Results
<
'tcx
,
EverInitializedPlaces
<
'mir
,
'tcx
>>
,
>
;
/// The transient state of the dataflow analyses used by the borrow checker.
pub
type
BorrowckFlowState
<
'mir
,
'tcx
>
=
<
BorrowckResults
<
'mir
,
'tcx
>
as
ResultsVisitable
<
'tcx
>>
::
FlowState
;
macro_rules!
impl_visitable
{
(
$
(
$T:ident
{
$
(
$field:ident
:
$A:ident
),
*
$
(,)
?
}
)
*
)
=>
{
$
(
impl
<
'tcx
,
$
(
$A
),
*
,
D
:
Direction
>
ResultsVisitable
<
'tcx
>
for
$T
<
$
(
Results
<
'tcx
,
$A
>
),
*>
where
$
(
$A
:
Analysis
<
'tcx
,
Direction
=
D
>
,
)
*
{
type
Direction
=
D
;
type
FlowState
=
$T
<
$
(
$A
::
Domain
),
*>
;
fn
new_flow_state
(
&
self
,
body
:
&
mir
::
Body
<
'tcx
>
)
->
Self
::
FlowState
{
$T
{
$
(
$field
:
self
.
$field
.analysis
.bottom_value
(
body
)
),
*
}
}
fn
reset_to_block_entry
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
block
:
BasicBlock
,
)
{
$
(
state
.
$field
.clone_from
(
&
self
.
$field
.entry_set_for_block
(
block
));
)
*
}
fn
reconstruct_before_statement_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
stmt
:
&
mir
::
Statement
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_before_statement_effect
(
&
mut
state
.
$field
,
stmt
,
loc
);
)
*
}
fn
reconstruct_statement_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
stmt
:
&
mir
::
Statement
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_statement_effect
(
&
mut
state
.
$field
,
stmt
,
loc
);
)
*
}
fn
reconstruct_before_terminator_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
term
:
&
mir
::
Terminator
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_before_terminator_effect
(
&
mut
state
.
$field
,
term
,
loc
);
)
*
}
fn
reconstruct_terminator_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
term
:
&
mir
::
Terminator
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_terminator_effect
(
&
mut
state
.
$field
,
term
,
loc
);
)
*
}
}
)
*
}
}
impl_visitable!
{
BorrowckAnalyses
{
borrows
:
B
,
uninits
:
U
,
ever_inits
:
E
}
}
rustc_index
::
newtype_index!
{
pub
struct
BorrowIndex
{
...
...
compiler/rustc_
mir/src/borrow_check
/def_use.rs
→
compiler/rustc_
borrowck/src
/def_use.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/diagnostics/bound_region_errors.rs
→
compiler/rustc_
borrowck/src
/diagnostics/bound_region_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -14,8 +14,8 @@
use
std
::
fmt
;
use
std
::
rc
::
Rc
;
use
crate
::
borrow_check
::
region_infer
::
values
::
RegionElement
;
use
crate
::
borrow_check
::
MirBorrowckCtxt
;
use
crate
::
region_infer
::
values
::
RegionElement
;
use
crate
::
MirBorrowckCtxt
;
#[derive(Clone)]
crate
struct
UniverseInfo
<
'tcx
>
(
UniverseInfoInner
<
'tcx
>
);
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/conflict_errors.rs
→
compiler/rustc_
borrowck/src
/diagnostics/conflict_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -15,11 +15,11 @@
use
rustc_span
::{
BytePos
,
MultiSpan
,
Span
,
DUMMY_SP
};
use
rustc_trait_selection
::
infer
::
InferCtxtExt
;
use
crate
::
dataflow
::
drop_flag_effect
s
;
use
crate
::
dataflow
::
indexes
::{
MoveOutIndex
,
MovePathIndex
}
;
use
crate
::
util
::
borrowck_errors
;
use
crate
::
borrowck_error
s
;
use
rustc_mir
::
dataflow
::
drop_flag_effects
;
use
rustc_mir
::
dataflow
::
move_paths
::{
MoveOutIndex
,
MovePathIndex
}
;
use
crate
::
borrow_check
::
{
use
crate
::{
borrow_set
::
BorrowData
,
diagnostics
::
Instance
,
prefixes
::
IsPrefixOf
,
InitializationRequiringAction
,
MirBorrowckCtxt
,
PrefixSet
,
WriteKind
,
};
...
...
@@ -49,7 +49,7 @@ enum StorageDeadOrDrop<'tcx> {
}
impl
<
'cx
,
'tcx
>
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
pub
(
in
crate
::
borrow_check
)
fn
report_use_of_moved_or_uninitialized
(
pub
(
crate
)
fn
report_use_of_moved_or_uninitialized
(
&
mut
self
,
location
:
Location
,
desired_action
:
InitializationRequiringAction
,
...
...
@@ -441,7 +441,7 @@ pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
}
}
pub
(
in
crate
::
borrow_check
)
fn
report_move_out_while_borrowed
(
pub
(
crate
)
fn
report_move_out_while_borrowed
(
&
mut
self
,
location
:
Location
,
(
place
,
span
):
(
Place
<
'tcx
>
,
Span
),
...
...
@@ -489,7 +489,7 @@ pub(in crate::borrow_check) fn report_move_out_while_borrowed(
err
.buffer
(
&
mut
self
.errors_buffer
);
}
pub
(
in
crate
::
borrow_check
)
fn
report_use_while_mutably_borrowed
(
pub
(
crate
)
fn
report_use_while_mutably_borrowed
(
&
mut
self
,
location
:
Location
,
(
place
,
_
span
):
(
Place
<
'tcx
>
,
Span
),
...
...
@@ -535,7 +535,7 @@ pub(in crate::borrow_check) fn report_use_while_mutably_borrowed(
err
}
pub
(
in
crate
::
borrow_check
)
fn
report_conflicting_borrow
(
pub
(
crate
)
fn
report_conflicting_borrow
(
&
mut
self
,
location
:
Location
,
(
place
,
span
):
(
Place
<
'tcx
>
,
Span
),
...
...
@@ -798,7 +798,7 @@ fn suggest_split_at_mut_if_applicable(
/// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as
/// mutable (via `a.u.s.b`) [E0502]
/// ```
pub
(
in
crate
::
borrow_check
)
fn
describe_place_for_conflicting_borrow
(
pub
(
crate
)
fn
describe_place_for_conflicting_borrow
(
&
self
,
first_borrowed_place
:
Place
<
'tcx
>
,
second_borrowed_place
:
Place
<
'tcx
>
,
...
...
@@ -875,7 +875,7 @@ pub(in crate::borrow_check) fn describe_place_for_conflicting_borrow(
/// short a lifetime. (But sometimes it is more useful to report
/// it as a more direct conflict between the execution of a
/// `Drop::drop` with an aliasing borrow.)
pub
(
in
crate
::
borrow_check
)
fn
report_borrowed_value_does_not_live_long_enough
(
pub
(
crate
)
fn
report_borrowed_value_does_not_live_long_enough
(
&
mut
self
,
location
:
Location
,
borrow
:
&
BorrowData
<
'tcx
>
,
...
...
@@ -1634,7 +1634,7 @@ fn predecessor_locations(
(
result
,
reinits_reachable
)
}
pub
(
in
crate
::
borrow_check
)
fn
report_illegal_mutation_of_borrowed
(
pub
(
crate
)
fn
report_illegal_mutation_of_borrowed
(
&
mut
self
,
location
:
Location
,
(
place
,
span
):
(
Place
<
'tcx
>
,
Span
),
...
...
@@ -1695,7 +1695,7 @@ fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnost
Some
((
method_did
,
method_substs
)),
)
=
(
&
self
.body
[
loan
.reserve_location.block
]
.terminator
,
crate
::
util
::
find_self_call
(
rustc_mir
::
util
::
find_self_call
(
tcx
,
self
.body
,
loan
.assigned_place.local
,
...
...
@@ -1726,7 +1726,7 @@ fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnost
/// assigned; `err_place` is a place providing a reason why
/// `place` is not mutable (e.g., the non-`mut` local `x` in an
/// assignment to `x.f`).
pub
(
in
crate
::
borrow_check
)
fn
report_illegal_reassignment
(
pub
(
crate
)
fn
report_illegal_reassignment
(
&
mut
self
,
_
location
:
Location
,
(
place
,
span
):
(
Place
<
'tcx
>
,
Span
),
...
...
@@ -2226,7 +2226,7 @@ enum AnnotatedBorrowFnSignature<'tcx> {
impl
<
'tcx
>
AnnotatedBorrowFnSignature
<
'tcx
>
{
/// Annotate the provided diagnostic with information about borrow from the fn signature that
/// helps explain.
pub
(
in
crate
::
borrow_check
)
fn
emit
(
pub
(
crate
)
fn
emit
(
&
self
,
cx
:
&
mut
MirBorrowckCtxt
<
'_
,
'tcx
>
,
diag
:
&
mut
DiagnosticBuilder
<
'_
>
,
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/explain_borrow.rs
→
compiler/rustc_
borrowck/src
/diagnostics/explain_borrow.rs
浏览文件 @
31a61ccc
...
...
@@ -15,8 +15,8 @@
use
rustc_span
::
symbol
::
Symbol
;
use
rustc_span
::
Span
;
use
crate
::
borrow_check
::
region_infer
::
BlameConstraint
;
use
crate
::
borrow_check
::
{
use
crate
::
region_infer
::
BlameConstraint
;
use
crate
::{
borrow_set
::
BorrowData
,
nll
::
ConstraintDescription
,
region_infer
::
Cause
,
MirBorrowckCtxt
,
WriteKind
,
};
...
...
@@ -24,7 +24,7 @@
use
super
::{
find_use
,
RegionName
,
UseSpans
};
#[derive(Debug)]
pub
(
in
crate
::
borrow_check
)
enum
BorrowExplanation
{
pub
(
crate
)
enum
BorrowExplanation
{
UsedLater
(
LaterUseKind
,
Span
,
Option
<
Span
>
),
UsedLaterInLoop
(
LaterUseKind
,
Span
,
Option
<
Span
>
),
UsedLaterWhenDropped
{
...
...
@@ -43,7 +43,7 @@ pub(in crate::borrow_check) enum BorrowExplanation {
}
#[derive(Clone,
Copy,
Debug)]
pub
(
in
crate
::
borrow_check
)
enum
LaterUseKind
{
pub
(
crate
)
enum
LaterUseKind
{
TraitCapture
,
ClosureCapture
,
Call
,
...
...
@@ -52,13 +52,13 @@ pub(in crate::borrow_check) enum LaterUseKind {
}
impl
BorrowExplanation
{
pub
(
in
crate
::
borrow_check
)
fn
is_explained
(
&
self
)
->
bool
{
pub
(
crate
)
fn
is_explained
(
&
self
)
->
bool
{
match
self
{
BorrowExplanation
::
Unexplained
=>
false
,
_
=>
true
,
}
}
pub
(
in
crate
::
borrow_check
)
fn
add_explanation_to_diagnostic
<
'tcx
>
(
pub
(
crate
)
fn
add_explanation_to_diagnostic
<
'tcx
>
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
,
body
:
&
Body
<
'tcx
>
,
...
...
@@ -267,7 +267,7 @@ pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'tcx>(
_
=>
{}
}
}
pub
(
in
crate
::
borrow_check
)
fn
add_lifetime_bound_suggestion_to_diagnostic
(
pub
(
crate
)
fn
add_lifetime_bound_suggestion_to_diagnostic
(
&
self
,
err
:
&
mut
DiagnosticBuilder
<
'_
>
,
category
:
&
ConstraintCategory
,
...
...
@@ -326,7 +326,7 @@ fn free_region_constraint_info(
/// - second half is the place being accessed
///
/// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points
pub
(
in
crate
::
borrow_check
)
fn
explain_why_borrow_contains_point
(
pub
(
crate
)
fn
explain_why_borrow_contains_point
(
&
self
,
location
:
Location
,
borrow
:
&
BorrowData
<
'tcx
>
,
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/find_use.rs
→
compiler/rustc_
borrowck/src
/diagnostics/find_use.rs
浏览文件 @
31a61ccc
use
std
::
collections
::
VecDeque
;
use
std
::
rc
::
Rc
;
use
crate
::
borrow_check
::
{
use
crate
::{
def_use
::{
self
,
DefUse
},
nll
::
ToRegionVid
,
region_infer
::{
Cause
,
RegionInferenceContext
},
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/mod.rs
→
compiler/rustc_
borrowck/src
/diagnostics/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -12,6 +12,7 @@
};
use
rustc_middle
::
ty
::
print
::
Print
;
use
rustc_middle
::
ty
::{
self
,
DefIdTree
,
Instance
,
Ty
,
TyCtxt
};
use
rustc_mir
::
dataflow
::
move_paths
::{
InitLocation
,
LookupResult
};
use
rustc_span
::{
hygiene
::{
DesugaringKind
,
ForLoopLoc
},
symbol
::
sym
,
...
...
@@ -21,7 +22,6 @@
use
super
::
borrow_set
::
BorrowData
;
use
super
::
MirBorrowckCtxt
;
use
crate
::
dataflow
::
move_paths
::{
InitLocation
,
LookupResult
};
mod
find_use
;
mod
outlives_suggestion
;
...
...
@@ -899,9 +899,12 @@ pub(super) fn move_spans(
kind
:
TerminatorKind
::
Call
{
fn_span
,
from_hir_call
,
..
},
..
})
=
&
self
.body
[
location
.block
]
.terminator
{
let
(
method_did
,
method_substs
)
=
if
let
Some
(
info
)
=
crate
::
util
::
find_self_call
(
self
.infcx.tcx
,
&
self
.body
,
target_temp
,
location
.block
)
{
let
(
method_did
,
method_substs
)
=
if
let
Some
(
info
)
=
rustc_mir
::
util
::
find_self_call
(
self
.infcx.tcx
,
&
self
.body
,
target_temp
,
location
.block
,
)
{
info
}
else
{
return
normal_ret
;
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/move_errors.rs
→
compiler/rustc_
borrowck/src
/diagnostics/move_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -2,16 +2,16 @@
use
rustc_infer
::
infer
::
TyCtxtInferExt
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
ty
;
use
rustc_mir
::
dataflow
::
move_paths
::{
IllegalMoveOrigin
,
IllegalMoveOriginKind
,
LookupResult
,
MoveError
,
MovePathIndex
,
};
use
rustc_span
::
source_map
::
DesugaringKind
;
use
rustc_span
::{
sym
,
Span
,
DUMMY_SP
};
use
rustc_trait_selection
::
traits
::
type_known_to_meet_bound_modulo_regions
;
use
crate
::
borrow_check
::
diagnostics
::
UseSpans
;
use
crate
::
borrow_check
::
prefixes
::
PrefixSet
;
use
crate
::
borrow_check
::
MirBorrowckCtxt
;
use
crate
::
dataflow
::
move_paths
::{
IllegalMoveOrigin
,
IllegalMoveOriginKind
,
LookupResult
,
MoveError
,
MovePathIndex
,
};
use
crate
::
diagnostics
::
UseSpans
;
use
crate
::
prefixes
::
PrefixSet
;
use
crate
::
MirBorrowckCtxt
;
// Often when desugaring a pattern match we may have many individual moves in
// MIR that are all part of one operation from the user's point-of-view. For
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/mutability_errors.rs
→
compiler/rustc_
borrowck/src
/diagnostics/mutability_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -14,10 +14,10 @@
use
rustc_span
::
symbol
::{
kw
,
Symbol
};
use
rustc_span
::{
BytePos
,
Span
};
use
crate
::
borrow_check
::
diagnostics
::
BorrowedContentSource
;
use
crate
::
borrow_check
::
MirBorrowckCtxt
;
use
crate
::
util
::
collect_writes
::
FindAssignments
;
use
crate
::
diagnostics
::
BorrowedContentSource
;
use
crate
::
MirBorrowckCtxt
;
use
rustc_errors
::{
Applicability
,
DiagnosticBuilder
};
use
rustc_mir
::
util
::
collect_writes
::
FindAssignments
;
#[derive(Copy,
Clone,
Debug,
Eq,
PartialEq)]
pub
(
crate
)
enum
AccessKind
{
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/outlives_suggestion.rs
→
compiler/rustc_
borrowck/src
/diagnostics/outlives_suggestion.rs
浏览文件 @
31a61ccc
//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
//! outlives constraints.
use
std
::
collections
::
BTreeMap
;
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
rustc_errors
::
DiagnosticBuilder
;
use
rustc_middle
::
ty
::
RegionVid
;
use
tracing
::
debug
;
use
smallvec
::
SmallVec
;
use
std
::
collections
::
BTreeMap
;
use
tracing
::
debug
;
use
crate
::
borrow_check
::
MirBorrowckCtxt
;
use
crate
::
MirBorrowckCtxt
;
use
super
::{
ErrorConstraintInfo
,
RegionName
,
RegionNameSource
};
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/region_errors.rs
→
compiler/rustc_
borrowck/src
/diagnostics/region_errors.rs
浏览文件 @
31a61ccc
...
...
@@ -11,10 +11,10 @@
use
rustc_span
::
symbol
::{
kw
,
sym
};
use
rustc_span
::{
BytePos
,
Span
};
use
crate
::
util
::
borrowck_errors
;
use
crate
::
borrowck_errors
;
use
crate
::
borrow_check
::
region_infer
::
BlameConstraint
;
use
crate
::
borrow_check
::
{
use
crate
::
region_infer
::
BlameConstraint
;
use
crate
::{
nll
::
ConstraintDescription
,
region_infer
::{
values
::
RegionElement
,
TypeTest
},
universal_regions
::
DefiningTy
,
...
...
@@ -152,7 +152,7 @@ fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
}
/// Produces nice borrowck error diagnostics for all the errors collected in `nll_errors`.
pub
(
in
crate
::
borrow_check
)
fn
report_region_errors
(
&
mut
self
,
nll_errors
:
RegionErrors
<
'tcx
>
)
{
pub
(
crate
)
fn
report_region_errors
(
&
mut
self
,
nll_errors
:
RegionErrors
<
'tcx
>
)
{
// Iterate through all the errors, producing a diagnostic for each one. The diagnostics are
// buffered in the `MirBorrowckCtxt`.
...
...
@@ -265,7 +265,7 @@ pub(in crate::borrow_check) fn report_region_errors(&mut self, nll_errors: Regio
/// ```
///
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
pub
(
in
crate
::
borrow_check
)
fn
report_region_error
(
pub
(
crate
)
fn
report_region_error
(
&
mut
self
,
fr
:
RegionVid
,
fr_origin
:
NllRegionVariableOrigin
,
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/region_name.rs
→
compiler/rustc_
borrowck/src
/diagnostics/region_name.rs
浏览文件 @
31a61ccc
...
...
@@ -10,7 +10,7 @@
use
rustc_span
::
symbol
::{
kw
,
sym
,
Ident
,
Symbol
};
use
rustc_span
::{
Span
,
DUMMY_SP
};
use
crate
::
borrow_check
::
{
nll
::
ToRegionVid
,
universal_regions
::
DefiningTy
,
MirBorrowckCtxt
};
use
crate
::{
nll
::
ToRegionVid
,
universal_regions
::
DefiningTy
,
MirBorrowckCtxt
};
/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
...
...
compiler/rustc_
mir/src/borrow_check
/diagnostics/var_name.rs
→
compiler/rustc_
borrowck/src
/diagnostics/var_name.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
Upvar
;
use
crate
::
borrow_check
::
{
nll
::
ToRegionVid
,
region_infer
::
RegionInferenceContext
};
use
crate
::
Upvar
;
use
crate
::{
nll
::
ToRegionVid
,
region_infer
::
RegionInferenceContext
};
use
rustc_index
::
vec
::{
Idx
,
IndexVec
};
use
rustc_middle
::
mir
::{
Body
,
Local
};
use
rustc_middle
::
ty
::{
RegionVid
,
TyCtxt
};
...
...
compiler/rustc_
mir/src/borrow_check
/facts.rs
→
compiler/rustc_
borrowck/src
/facts.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
location
::{
LocationIndex
,
LocationTable
};
use
crate
::
dataflow
::
indexes
::{
BorrowIndex
,
MovePathIndex
}
;
use
crate
::
location
::{
LocationIndex
,
LocationTable
};
use
crate
::
BorrowIndex
;
use
polonius_engine
::
AllFacts
as
PoloniusFacts
;
use
polonius_engine
::
Atom
;
use
rustc_index
::
vec
::
Idx
;
use
rustc_middle
::
mir
::
Local
;
use
rustc_middle
::
ty
::{
RegionVid
,
TyCtxt
};
use
rustc_mir
::
dataflow
::
move_paths
::
MovePathIndex
;
use
std
::
error
::
Error
;
use
std
::
fmt
::
Debug
;
use
std
::
fs
::{
self
,
File
};
...
...
@@ -100,12 +101,6 @@ fn index(self) -> usize {
}
}
impl
Atom
for
MovePathIndex
{
fn
index
(
self
)
->
usize
{
Idx
::
index
(
self
)
}
}
struct
FactWriter
<
'w
>
{
location_table
:
&
'w
LocationTable
,
dir
:
&
'w
Path
,
...
...
compiler/rustc_
mir/src/borrow_check
/invalidation.rs
→
compiler/rustc_
borrowck/src
/invalidation.rs
浏览文件 @
31a61ccc
...
...
@@ -7,12 +7,10 @@
use
rustc_middle
::
ty
::
TyCtxt
;
use
std
::
iter
;
use
crate
::
dataflow
::
indexes
::
BorrowIndex
;
use
crate
::
borrow_check
::{
use
crate
::{
borrow_set
::
BorrowSet
,
facts
::
AllFacts
,
location
::
LocationTable
,
path_utils
::
*
,
AccessDepth
,
Activation
,
ArtificialField
,
Deep
,
JustWrite
,
LocalMutationIsAllowed
,
MutateMode
,
Read
,
ReadKind
,
ReadOrWrite
,
Reservation
,
Shallow
,
Write
,
WriteAndRead
,
WriteKind
,
Activation
,
ArtificialField
,
BorrowIndex
,
Deep
,
JustWrite
,
LocalMutationIsAllowed
,
MutateMode
,
Read
,
Read
Kind
,
ReadOrWrite
,
Reservation
,
Shallow
,
Write
,
WriteAndRead
,
WriteKind
,
};
pub
(
super
)
fn
generate_invalidates
<
'tcx
>
(
...
...
compiler/rustc_
mir/src/borrow_check/mod
.rs
→
compiler/rustc_
borrowck/src/lib
.rs
浏览文件 @
31a61ccc
//! This query borrow-checks the MIR to (further) ensure it is not broken.
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(const_panic)]
#![feature(crate_visibility_modifier)]
#![feature(format_args_capture)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(min_specialization)]
#![feature(stmt_expr_attributes)]
#![feature(trusted_step)]
#![feature(try_blocks)]
#[macro_use]
extern
crate
rustc_middle
;
#[macro_use]
extern
crate
tracing
;
use
rustc_data_structures
::
fx
::{
FxHashMap
,
FxHashSet
};
use
rustc_data_structures
::
graph
::
dominators
::
Dominators
;
use
rustc_errors
::{
Applicability
,
Diagnostic
,
DiagnosticBuilder
,
ErrorReported
};
...
...
@@ -29,14 +46,13 @@
use
std
::
mem
;
use
std
::
rc
::
Rc
;
use
crate
::
dataflow
;
use
crate
::
dataflow
::
impls
::{
Borrows
,
EverInitializedPlaces
,
MaybeInitializedPlaces
,
MaybeUninitializedPlaces
,
use
rustc_mir
::
dataflow
::
impls
::{
EverInitializedPlaces
,
MaybeInitializedPlaces
,
MaybeUninitializedPlaces
,
};
use
crate
::
dataflow
::
indexes
::{
BorrowIndex
,
InitIndex
,
MoveOutIndex
,
MovePathIndex
};
use
crate
::
dataflow
::
move_paths
::{
InitLocation
,
LookupResult
,
MoveData
,
MoveError
};
use
crate
::
dataflow
::
MoveDataParamEnv
;
use
crate
::
dataflow
::{
Analysis
,
BorrowckFlowState
as
Flows
,
BorrowckResults
}
;
use
rustc_mir
::
dataflow
::
move_paths
::{
InitIndex
,
MoveOutIndex
,
MovePathIndex
};
use
rustc_mir
::
dataflow
::
move_paths
::{
InitLocation
,
LookupResult
,
MoveData
,
MoveError
};
use
rustc_mir
::
dataflow
::
Analysis
;
use
rustc_mir
::
dataflow
::
MoveDataParamEnv
;
use
self
::
diagnostics
::{
AccessKind
,
RegionName
};
use
self
::
location
::
LocationTable
;
...
...
@@ -47,9 +63,10 @@
use
self
::
path_utils
::
*
;
mod
borrow_set
;
mod
borrowck_errors
;
mod
constraint_generation
;
mod
constraints
;
pub
mod
consumers
;
mod
dataflow
;
mod
def_use
;
mod
diagnostics
;
mod
facts
;
...
...
@@ -67,15 +84,19 @@
mod
universal_regions
;
mod
used_muts
;
crate
use
borrow_set
::{
BorrowData
,
BorrowSet
};
crate
use
nll
::{
PoloniusOutput
,
ToRegionVid
};
crate
use
place_ext
::
PlaceExt
;
crate
use
places_conflict
::{
places_conflict
,
PlaceConflictBias
};
crate
use
region_infer
::
RegionInferenceContext
;
// A public API provided for the Rust compiler consumers.
pub
mod
consumers
;
use
borrow_set
::{
BorrowData
,
BorrowSet
};
use
dataflow
::{
BorrowIndex
,
BorrowckFlowState
as
Flows
,
BorrowckResults
,
Borrows
};
use
nll
::{
PoloniusOutput
,
ToRegionVid
};
use
place_ext
::
PlaceExt
;
use
places_conflict
::{
places_conflict
,
PlaceConflictBias
};
use
region_infer
::
RegionInferenceContext
;
// FIXME(eddyb) perhaps move this somewhere more centrally.
#[derive(Debug)]
crate
struct
Upvar
<
'tcx
>
{
struct
Upvar
<
'tcx
>
{
place
:
CapturedPlace
<
'tcx
>
,
/// If true, the capture is behind a reference.
...
...
@@ -352,7 +373,7 @@ fn do_mir_borrowck<'a, 'tcx>(
mbcx
.report_move_errors
(
move_errors
);
dataflow
::
visit_results
(
rustc_mir
::
dataflow
::
visit_results
(
&
body
,
traversal
::
reverse_postorder
(
&
body
)
.map
(|(
bb
,
_
)|
bb
),
&
results
,
...
...
@@ -495,8 +516,8 @@ pub struct BodyWithBorrowckFacts<'tcx> {
pub
location_table
:
LocationTable
,
}
crate
struct
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
crate
infcx
:
&
'cx
InferCtxt
<
'cx
,
'tcx
>
,
struct
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
infcx
:
&
'cx
InferCtxt
<
'cx
,
'tcx
>
,
param_env
:
ParamEnv
<
'tcx
>
,
body
:
&
'cx
Body
<
'tcx
>
,
move_data
:
&
'cx
MoveData
<
'tcx
>
,
...
...
@@ -594,7 +615,7 @@ pub struct BodyWithBorrowckFacts<'tcx> {
// 2. loans made in overlapping scopes do not conflict
// 3. assignments do not affect things loaned out as immutable
// 4. moves do not affect things loaned out in any way
impl
<
'cx
,
'tcx
>
dataflow
::
ResultsVisitor
<
'cx
,
'tcx
>
for
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
impl
<
'cx
,
'tcx
>
rustc_mir
::
dataflow
::
ResultsVisitor
<
'cx
,
'tcx
>
for
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
type
FlowState
=
Flows
<
'cx
,
'tcx
>
;
fn
visit_statement_before_primary_effect
(
...
...
@@ -2344,7 +2365,7 @@ fn is_mutable(
/// then returns the index of the field being projected. Note that this closure will always
/// be `self` in the current MIR, because that is the only time we directly access the fields
/// of a closure type.
pub
fn
is_upvar_field_projection
(
&
self
,
place_ref
:
PlaceRef
<
'tcx
>
)
->
Option
<
Field
>
{
fn
is_upvar_field_projection
(
&
self
,
place_ref
:
PlaceRef
<
'tcx
>
)
->
Option
<
Field
>
{
path_utils
::
is_upvar_field_projection
(
self
.infcx.tcx
,
&
self
.upvars
,
place_ref
,
self
.body
())
}
}
...
...
compiler/rustc_
mir/src/borrow_check
/location.rs
→
compiler/rustc_
borrowck/src
/location.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/member_constraints.rs
→
compiler/rustc_
borrowck/src
/member_constraints.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/nll.rs
→
compiler/rustc_
borrowck/src
/nll.rs
浏览文件 @
31a61ccc
...
...
@@ -20,13 +20,13 @@
use
self
::
mir_util
::
PassWhere
;
use
polonius_engine
::{
Algorithm
,
Output
};
use
crate
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
crate
::
dataflow
::
move_paths
::{
InitKind
,
InitLocation
,
MoveData
};
use
crate
::
dataflow
::
ResultsCursor
;
use
crate
::
util
as
mir_util
;
use
crate
::
util
::
pretty
;
use
rustc_mir
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
rustc_mir
::
dataflow
::
move_paths
::{
InitKind
,
InitLocation
,
MoveData
};
use
rustc_mir
::
dataflow
::
ResultsCursor
;
use
rustc_mir
::
util
as
mir_util
;
use
rustc_mir
::
util
::
pretty
;
use
crate
::
borrow_check
::
{
use
crate
::{
borrow_set
::
BorrowSet
,
constraint_generation
,
diagnostics
::
RegionErrors
,
...
...
@@ -56,7 +56,7 @@
/// Rewrites the regions in the MIR to use NLL variables, also scraping out the set of universal
/// regions (e.g., region parameters) declared on the function. That set will need to be given to
/// `compute_regions`.
pub
(
in
crate
::
borrow_check
)
fn
replace_regions_in_mir
<
'cx
,
'tcx
>
(
pub
(
crate
)
fn
replace_regions_in_mir
<
'cx
,
'tcx
>
(
infcx
:
&
InferCtxt
<
'cx
,
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
body
:
&
mut
Body
<
'tcx
>
,
...
...
@@ -155,7 +155,7 @@ fn populate_polonius_move_facts(
/// Computes the (non-lexical) regions from the input MIR.
///
/// This may result in errors being reported.
pub
(
in
crate
::
borrow_check
)
fn
compute_regions
<
'cx
,
'tcx
>
(
pub
(
crate
)
fn
compute_regions
<
'cx
,
'tcx
>
(
infcx
:
&
InferCtxt
<
'cx
,
'tcx
>
,
universal_regions
:
UniversalRegions
<
'tcx
>
,
body
:
&
Body
<
'tcx
>
,
...
...
compiler/rustc_
mir/src/borrow_check
/path_utils.rs
→
compiler/rustc_
borrowck/src
/path_utils.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_
check
::
borrow_
set
::{
BorrowData
,
BorrowSet
,
TwoPhaseActivation
};
use
crate
::
borrow_check
::
places_conflict
;
use
crate
::
borrow_check
::
AccessDepth
;
use
crate
::
borrow_check
::
Upvar
;
use
crate
::
dataflow
::
indexes
::
BorrowIndex
;
use
crate
::
borrow_set
::{
BorrowData
,
BorrowSet
,
TwoPhaseActivation
};
use
crate
::
places_conflict
;
use
crate
::
AccessDepth
;
use
crate
::
BorrowIndex
;
use
crate
::
Upvar
;
use
rustc_data_structures
::
graph
::
dominators
::
Dominators
;
use
rustc_middle
::
mir
::
BorrowKind
;
use
rustc_middle
::
mir
::{
BasicBlock
,
Body
,
Field
,
Location
,
Place
,
PlaceRef
,
ProjectionElem
};
...
...
compiler/rustc_
mir/src/borrow_check
/place_ext.rs
→
compiler/rustc_
borrowck/src
/place_ext.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_
check
::
borrow_
set
::
LocalsStateAtExit
;
use
crate
::
borrow_set
::
LocalsStateAtExit
;
use
rustc_hir
as
hir
;
use
rustc_middle
::
mir
::
ProjectionElem
;
use
rustc_middle
::
mir
::{
Body
,
Mutability
,
Place
};
...
...
compiler/rustc_
mir/src/borrow_check
/places_conflict.rs
→
compiler/rustc_
borrowck/src
/places_conflict.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
ArtificialField
;
use
crate
::
borrow_check
::
Overlap
;
use
crate
::
borrow_check
::
{
AccessDepth
,
Deep
,
Shallow
};
use
crate
::
ArtificialField
;
use
crate
::
Overlap
;
use
crate
::{
AccessDepth
,
Deep
,
Shallow
};
use
rustc_hir
as
hir
;
use
rustc_middle
::
mir
::{
Body
,
BorrowKind
,
Local
,
Place
,
PlaceElem
,
PlaceRef
,
ProjectionElem
};
use
rustc_middle
::
ty
::{
self
,
TyCtxt
};
...
...
compiler/rustc_
mir/src/borrow_check
/prefixes.rs
→
compiler/rustc_
borrowck/src
/prefixes.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/region_infer/dump_mir.rs
→
compiler/rustc_
borrowck/src
/region_infer/dump_mir.rs
浏览文件 @
31a61ccc
...
...
@@ -4,7 +4,7 @@
//! context internal state.
use
super
::{
OutlivesConstraint
,
RegionInferenceContext
};
use
crate
::
borrow_check
::
type_check
::
Locations
;
use
crate
::
type_check
::
Locations
;
use
rustc_infer
::
infer
::
NllRegionVariableOrigin
;
use
rustc_middle
::
ty
::
TyCtxt
;
use
std
::
io
::{
self
,
Write
};
...
...
compiler/rustc_
mir/src/borrow_check
/region_infer/graphviz.rs
→
compiler/rustc_
borrowck/src
/region_infer/graphviz.rs
浏览文件 @
31a61ccc
...
...
@@ -6,7 +6,7 @@
use
std
::
io
::{
self
,
Write
};
use
super
::
*
;
use
crate
::
borrow_check
::
constraints
::
OutlivesConstraint
;
use
crate
::
constraints
::
OutlivesConstraint
;
use
rustc_graphviz
as
dot
;
impl
<
'tcx
>
RegionInferenceContext
<
'tcx
>
{
...
...
compiler/rustc_
mir/src/borrow_check
/region_infer/mod.rs
→
compiler/rustc_
borrowck/src
/region_infer/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -17,7 +17,7 @@
use
rustc_middle
::
ty
::{
self
,
subst
::
SubstsRef
,
RegionVid
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
rustc_span
::
Span
;
use
crate
::
borrow_check
::
{
use
crate
::{
constraints
::{
graph
::
NormalConstraintGraph
,
ConstraintSccIndex
,
OutlivesConstraint
,
OutlivesConstraintSet
,
},
...
...
@@ -132,33 +132,33 @@ pub(crate) struct AppliedMemberConstraint {
///
/// The vector if `AppliedMemberConstraint` elements is kept sorted
/// by this field.
pub
(
in
crate
::
borrow_check
)
member_region_scc
:
ConstraintSccIndex
,
pub
(
crate
)
member_region_scc
:
ConstraintSccIndex
,
/// The "best option" that `apply_member_constraint` found -- this was
/// added as an "ad-hoc" lower-bound to `member_region_scc`.
pub
(
in
crate
::
borrow_check
)
min_choice
:
ty
::
RegionVid
,
pub
(
crate
)
min_choice
:
ty
::
RegionVid
,
/// The "member constraint index" -- we can find out details about
/// the constraint from
/// `set.member_constraints[member_constraint_index]`.
pub
(
in
crate
::
borrow_check
)
member_constraint_index
:
NllMemberConstraintIndex
,
pub
(
crate
)
member_constraint_index
:
NllMemberConstraintIndex
,
}
pub
(
crate
)
struct
RegionDefinition
<
'tcx
>
{
/// What kind of variable is this -- a free region? existential
/// variable? etc. (See the `NllRegionVariableOrigin` for more
/// info.)
pub
(
in
crate
::
borrow_check
)
origin
:
NllRegionVariableOrigin
,
pub
(
crate
)
origin
:
NllRegionVariableOrigin
,
/// Which universe is this region variable defined in? This is
/// most often `ty::UniverseIndex::ROOT`, but when we encounter
/// forall-quantifiers like `for<'a> { 'a = 'b }`, we would create
/// the variable for `'a` in a fresh universe that extends ROOT.
pub
(
in
crate
::
borrow_check
)
universe
:
ty
::
UniverseIndex
,
pub
(
crate
)
universe
:
ty
::
UniverseIndex
,
/// If this is 'static or an early-bound region, then this is
/// `Some(X)` where `X` is the name of the region.
pub
(
in
crate
::
borrow_check
)
external_name
:
Option
<
ty
::
Region
<
'tcx
>>
,
pub
(
crate
)
external_name
:
Option
<
ty
::
Region
<
'tcx
>>
,
}
/// N.B., the variants in `Cause` are intentionally ordered. Lower
...
...
@@ -245,7 +245,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
///
/// The `outlives_constraints` and `type_tests` are an initial set
/// of constraints produced by the MIR type check.
pub
(
in
crate
::
borrow_check
)
fn
new
(
pub
(
crate
)
fn
new
(
var_infos
:
VarInfos
,
universal_regions
:
Rc
<
UniversalRegions
<
'tcx
>>
,
placeholder_indices
:
Rc
<
PlaceholderIndices
>
,
...
...
@@ -534,7 +534,7 @@ pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
/// Once region solving has completed, this function will return
/// the member constraints that were applied to the value of a given
/// region `r`. See `AppliedMemberConstraint`.
pub
(
in
crate
::
borrow_check
)
fn
applied_member_constraints
(
pub
(
crate
)
fn
applied_member_constraints
(
&
self
,
r
:
impl
ToRegionVid
,
)
->
&
[
AppliedMemberConstraint
]
{
...
...
@@ -1088,7 +1088,7 @@ fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
/// include the CFG anyhow.
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
/// a result `'y`.
pub
(
in
crate
::
borrow_check
)
fn
universal_upper_bound
(
&
self
,
r
:
RegionVid
)
->
RegionVid
{
pub
(
crate
)
fn
universal_upper_bound
(
&
self
,
r
:
RegionVid
)
->
RegionVid
{
debug!
(
"universal_upper_bound(r={:?}={})"
,
r
,
self
.region_value_str
(
r
));
// Find the smallest universal region that contains all other
...
...
@@ -1115,7 +1115,7 @@ pub(in crate::borrow_check) fn universal_upper_bound(&self, r: RegionVid) -> Reg
/// Therefore, this method should only be used in diagnostic code,
/// where displaying *some* named universal region is better than
/// falling back to 'static.
pub
(
in
crate
::
borrow_check
)
fn
approx_universal_upper_bound
(
&
self
,
r
:
RegionVid
)
->
RegionVid
{
pub
(
crate
)
fn
approx_universal_upper_bound
(
&
self
,
r
:
RegionVid
)
->
RegionVid
{
debug!
(
"approx_universal_upper_bound(r={:?}={})"
,
r
,
self
.region_value_str
(
r
));
// Find the smallest universal region that contains all other
...
...
compiler/rustc_
mir/src/borrow_check
/region_infer/opaque_types.rs
→
compiler/rustc_
borrowck/src
/region_infer/opaque_types.rs
浏览文件 @
31a61ccc
...
...
@@ -47,7 +47,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// which has no `external_name` in which case we use `'empty` as the
/// region to pass to `infer_opaque_definition_from_instantiation`.
#[instrument(skip(self,
infcx))]
pub
(
in
crate
::
borrow_check
)
fn
infer_opaque_types
(
pub
(
crate
)
fn
infer_opaque_types
(
&
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
opaque_ty_decls
:
VecMap
<
OpaqueTypeKey
<
'tcx
>
,
Ty
<
'tcx
>>
,
...
...
@@ -105,7 +105,7 @@ pub(in crate::borrow_check) fn infer_opaque_types(
/// that the regions produced are in fact equal to the named region they are
/// replaced with. This is fine because this function is only to improve the
/// region names in error messages.
pub
(
in
crate
::
borrow_check
)
fn
name_regions
<
T
>
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
,
ty
:
T
)
->
T
pub
(
crate
)
fn
name_regions
<
T
>
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
,
ty
:
T
)
->
T
where
T
:
TypeFoldable
<
'tcx
>
,
{
...
...
compiler/rustc_
mir/src/borrow_check
/region_infer/reverse_sccs.rs
→
compiler/rustc_
borrowck/src
/region_infer/reverse_sccs.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
constraints
::
ConstraintSccIndex
;
use
crate
::
borrow_check
::
RegionInferenceContext
;
use
crate
::
constraints
::
ConstraintSccIndex
;
use
crate
::
RegionInferenceContext
;
use
itertools
::
Itertools
;
use
rustc_data_structures
::
fx
::{
FxHashMap
,
FxHashSet
};
use
rustc_data_structures
::
graph
::
vec_graph
::
VecGraph
;
...
...
compiler/rustc_
mir/src/borrow_check
/region_infer/values.rs
→
compiler/rustc_
borrowck/src
/region_infer/values.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/renumber.rs
→
compiler/rustc_
borrowck/src
/renumber.rs
浏览文件 @
31a61ccc
文件已移动
compiler/rustc_
mir/src/borrow_check
/type_check/canonical.rs
→
compiler/rustc_
borrowck/src
/type_check/canonical.rs
浏览文件 @
31a61ccc
...
...
@@ -8,7 +8,7 @@
use
rustc_trait_selection
::
traits
::
query
::
type_op
::{
self
,
TypeOpOutput
};
use
rustc_trait_selection
::
traits
::
query
::
Fallible
;
use
crate
::
borrow_check
::
diagnostics
::{
ToUniverseInfo
,
UniverseInfo
};
use
crate
::
diagnostics
::{
ToUniverseInfo
,
UniverseInfo
};
use
super
::{
Locations
,
NormalizeLocation
,
TypeChecker
};
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/constraint_conversion.rs
→
compiler/rustc_
borrowck/src
/type_check/constraint_conversion.rs
浏览文件 @
31a61ccc
...
...
@@ -9,7 +9,7 @@
use
rustc_middle
::
ty
::{
self
,
TyCtxt
};
use
rustc_span
::
DUMMY_SP
;
use
crate
::
borrow_check
::
{
use
crate
::{
constraints
::
OutlivesConstraint
,
nll
::
ToRegionVid
,
region_infer
::
TypeTest
,
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/free_region_relations.rs
→
compiler/rustc_
borrowck/src
/type_check/free_region_relations.rs
浏览文件 @
31a61ccc
...
...
@@ -13,7 +13,7 @@
use
std
::
rc
::
Rc
;
use
type_op
::
TypeOpOutput
;
use
crate
::
borrow_check
::
{
use
crate
::{
nll
::
ToRegionVid
,
type_check
::
constraint_conversion
,
type_check
::{
Locations
,
MirTypeckRegionConstraints
},
...
...
@@ -55,7 +55,7 @@
type
NormalizedInputsAndOutput
<
'tcx
>
=
Vec
<
Ty
<
'tcx
>>
;
crate
struct
CreateResult
<
'tcx
>
{
pub
(
in
crate
::
borrow_check
)
universal_region_relations
:
Frozen
<
UniversalRegionRelations
<
'tcx
>>
,
crate
universal_region_relations
:
Frozen
<
UniversalRegionRelations
<
'tcx
>>
,
crate
region_bound_pairs
:
RegionBoundPairs
<
'tcx
>
,
crate
normalized_inputs_and_output
:
NormalizedInputsAndOutput
<
'tcx
>
,
}
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/input_output.rs
→
compiler/rustc_
borrowck/src
/type_check/input_output.rs
浏览文件 @
31a61ccc
...
...
@@ -7,16 +7,15 @@
//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
//! contain revealed `impl Trait` values).
use
rustc_index
::
vec
::
Idx
;
use
rustc_infer
::
infer
::
LateBoundRegionConversionTime
;
use
rustc_middle
::
mir
::
*
;
use
rustc_middle
::
traits
::
ObligationCause
;
use
rustc_middle
::
ty
::{
self
,
Ty
};
use
rustc_trait_selection
::
traits
::
query
::
normalize
::
AtExt
;
use
rustc_index
::
vec
::
Idx
;
use
rustc_span
::
Span
;
use
rustc_trait_selection
::
traits
::
query
::
normalize
::
AtExt
;
use
crate
::
borrow_check
::
universal_regions
::
UniversalRegions
;
use
crate
::
universal_regions
::
UniversalRegions
;
use
super
::{
Locations
,
TypeChecker
};
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/liveness/local_use_map.rs
→
compiler/rustc_
borrowck/src
/type_check/liveness/local_use_map.rs
浏览文件 @
31a61ccc
...
...
@@ -3,8 +3,8 @@
use
rustc_middle
::
mir
::
visit
::{
PlaceContext
,
Visitor
};
use
rustc_middle
::
mir
::{
Body
,
Local
,
Location
};
use
crate
::
borrow_check
::
def_use
::{
self
,
DefUse
};
use
crate
::
borrow_check
::
region_infer
::
values
::{
PointIndex
,
RegionValueElements
};
use
crate
::
def_use
::{
self
,
DefUse
};
use
crate
::
region_infer
::
values
::{
PointIndex
,
RegionValueElements
};
/// A map that cross references each local with the locations where it
/// is defined (assigned), used, or dropped. Used during liveness
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/liveness/mod.rs
→
compiler/rustc_
borrowck/src
/type_check/liveness/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -3,11 +3,11 @@
use
rustc_middle
::
ty
::{
RegionVid
,
TyCtxt
};
use
std
::
rc
::
Rc
;
use
crate
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
crate
::
dataflow
::
move_paths
::
MoveData
;
use
crate
::
dataflow
::
ResultsCursor
;
use
rustc_mir
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
rustc_mir
::
dataflow
::
move_paths
::
MoveData
;
use
rustc_mir
::
dataflow
::
ResultsCursor
;
use
crate
::
borrow_check
::
{
use
crate
::{
constraints
::
OutlivesConstraintSet
,
facts
::{
AllFacts
,
AllFactsExt
},
location
::
LocationTable
,
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/liveness/polonius.rs
→
compiler/rustc_
borrowck/src
/type_check/liveness/polonius.rs
浏览文件 @
31a61ccc
use
crate
::
borrow_check
::
def_use
::{
self
,
DefUse
};
use
crate
::
borrow_check
::
location
::{
LocationIndex
,
LocationTable
};
use
crate
::
dataflow
::
indexes
::
MovePathIndex
;
use
crate
::
dataflow
::
move_paths
::{
LookupResult
,
MoveData
};
use
crate
::
def_use
::{
self
,
DefUse
};
use
crate
::
location
::{
LocationIndex
,
LocationTable
};
use
rustc_middle
::
mir
::
visit
::{
MutatingUseContext
,
PlaceContext
,
Visitor
};
use
rustc_middle
::
mir
::{
Body
,
Local
,
Location
,
Place
};
use
rustc_middle
::
ty
::
subst
::
GenericArg
;
use
rustc_mir
::
dataflow
::
move_paths
::{
LookupResult
,
MoveData
,
MovePathIndex
};
use
super
::
TypeChecker
;
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/liveness/trace.rs
→
compiler/rustc_
borrowck/src
/type_check/liveness/trace.rs
浏览文件 @
31a61ccc
...
...
@@ -8,12 +8,11 @@
use
rustc_trait_selection
::
traits
::
query
::
type_op
::{
TypeOp
,
TypeOpOutput
};
use
std
::
rc
::
Rc
;
use
crate
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
crate
::
dataflow
::
indexes
::
MovePathIndex
;
use
crate
::
dataflow
::
move_paths
::{
HasMoveData
,
MoveData
};
use
crate
::
dataflow
::
ResultsCursor
;
use
rustc_mir
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
rustc_mir
::
dataflow
::
move_paths
::{
HasMoveData
,
MoveData
,
MovePathIndex
};
use
rustc_mir
::
dataflow
::
ResultsCursor
;
use
crate
::
borrow_check
::
{
use
crate
::{
region_infer
::
values
::{
self
,
PointIndex
,
RegionValueElements
},
type_check
::
liveness
::
local_use_map
::
LocalUseMap
,
type_check
::
liveness
::
polonius
,
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/mod.rs
→
compiler/rustc_
borrowck/src
/type_check/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -41,14 +41,14 @@
use
rustc_trait_selection
::
traits
::
query
::
Fallible
;
use
rustc_trait_selection
::
traits
::{
self
,
ObligationCause
,
PredicateObligations
};
use
crate
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
crate
::
dataflow
::
move_paths
::
MoveData
;
use
crate
::
dataflow
::
ResultsCursor
;
use
crate
::
transform
::{
use
rustc_mir
::
dataflow
::
impls
::
MaybeInitializedPlaces
;
use
rustc_mir
::
dataflow
::
move_paths
::
MoveData
;
use
rustc_mir
::
dataflow
::
ResultsCursor
;
use
rustc_mir
::
transform
::{
check_consts
::
ConstCx
,
promote_consts
::
is_const_fn_in_array_repeat_expression
,
};
use
crate
::
borrow_check
::
{
use
crate
::{
borrow_set
::
BorrowSet
,
constraints
::{
OutlivesConstraint
,
OutlivesConstraintSet
},
diagnostics
::
UniverseInfo
,
...
...
@@ -68,7 +68,7 @@
macro_rules!
span_mirbug
{
(
$context:expr
,
$elem:expr
,
$
(
$message:tt
)
*
)
=>
({
$crate
::
borrow_check
::
type_check
::
mirbug
(
$crate
::
type_check
::
mirbug
(
$context
.tcx
(),
$context
.last_span
,
&
format!
(
...
...
@@ -887,7 +887,7 @@ struct BorrowCheckContext<'a, 'tcx> {
crate
struct
MirTypeckResults
<
'tcx
>
{
crate
constraints
:
MirTypeckRegionConstraints
<
'tcx
>
,
pub
(
in
crate
::
borrow_check
)
universal_region_relations
:
Frozen
<
UniversalRegionRelations
<
'tcx
>>
,
crate
universal_region_relations
:
Frozen
<
UniversalRegionRelations
<
'tcx
>>
,
crate
opaque_type_values
:
VecMap
<
OpaqueTypeKey
<
'tcx
>
,
Ty
<
'tcx
>>
,
}
...
...
compiler/rustc_
mir/src/borrow_check
/type_check/relate_tys.rs
→
compiler/rustc_
borrowck/src
/type_check/relate_tys.rs
浏览文件 @
31a61ccc
...
...
@@ -5,9 +5,9 @@
use
rustc_middle
::
ty
::{
self
,
Const
,
Ty
};
use
rustc_trait_selection
::
traits
::
query
::
Fallible
;
use
crate
::
borrow_check
::
constraints
::
OutlivesConstraint
;
use
crate
::
borrow_check
::
diagnostics
::
UniverseInfo
;
use
crate
::
borrow_check
::
type_check
::{
BorrowCheckContext
,
Locations
};
use
crate
::
constraints
::
OutlivesConstraint
;
use
crate
::
diagnostics
::
UniverseInfo
;
use
crate
::
type_check
::{
BorrowCheckContext
,
Locations
};
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
///
...
...
compiler/rustc_
mir/src/borrow_check
/universal_regions.rs
→
compiler/rustc_
borrowck/src
/universal_regions.rs
浏览文件 @
31a61ccc
...
...
@@ -26,7 +26,7 @@
use
rustc_middle
::
ty
::{
self
,
RegionVid
,
Ty
,
TyCtxt
};
use
std
::
iter
;
use
crate
::
borrow_check
::
nll
::
ToRegionVid
;
use
crate
::
nll
::
ToRegionVid
;
#[derive(Debug)]
pub
struct
UniversalRegions
<
'tcx
>
{
...
...
compiler/rustc_
mir/src/borrow_check
/used_muts.rs
→
compiler/rustc_
borrowck/src
/used_muts.rs
浏览文件 @
31a61ccc
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
rustc_middle
::
mir
::
visit
::{
PlaceContext
,
Visitor
};
use
rustc_middle
::
mir
::{
Local
,
Location
,
Place
,
Statement
,
StatementKind
,
Terminator
,
TerminatorKind
,
};
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
crate
::
borrow_check
::
MirBorrowckCtxt
;
use
crate
::
MirBorrowckCtxt
;
impl
<
'cx
,
'tcx
>
MirBorrowckCtxt
<
'cx
,
'tcx
>
{
/// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes
...
...
compiler/rustc_interface/Cargo.toml
浏览文件 @
31a61ccc
...
...
@@ -14,6 +14,7 @@ rayon = { version = "0.3.1", package = "rustc-rayon" }
smallvec
=
{
version
=
"1.6.1"
,
features
=
[
"union"
,
"may_dangle"
]
}
rustc_ast
=
{
path
=
"../rustc_ast"
}
rustc_attr
=
{
path
=
"../rustc_attr"
}
rustc_borrowck
=
{
path
=
"../rustc_borrowck"
}
rustc_builtin_macros
=
{
path
=
"../rustc_builtin_macros"
}
rustc_expand
=
{
path
=
"../rustc_expand"
}
rustc_parse
=
{
path
=
"../rustc_parse"
}
...
...
compiler/rustc_interface/src/passes.rs
浏览文件 @
31a61ccc
...
...
@@ -4,6 +4,7 @@
use
rustc_ast
::
mut_visit
::
MutVisitor
;
use
rustc_ast
::{
self
as
ast
,
visit
};
use
rustc_borrowck
as
mir_borrowck
;
use
rustc_codegen_ssa
::
back
::
link
::
emit_metadata
;
use
rustc_codegen_ssa
::
traits
::
CodegenBackend
;
use
rustc_data_structures
::
parallel
;
...
...
@@ -739,6 +740,7 @@ pub fn prepare_outputs(
proc_macro_decls
::
provide
(
providers
);
rustc_middle
::
hir
::
provide
(
providers
);
mir
::
provide
(
providers
);
mir_borrowck
::
provide
(
providers
);
mir_build
::
provide
(
providers
);
rustc_privacy
::
provide
(
providers
);
typeck
::
provide
(
providers
);
...
...
compiler/rustc_mir/Cargo.toml
浏览文件 @
31a61ccc
...
...
@@ -8,30 +8,28 @@ doctest = false
[dependencies]
either
=
"1.5.0"
rustc_graphviz
=
{
path
=
"../rustc_graphviz"
}
gsgdt
=
"0.1.2"
itertools
=
"0.9"
tracing
=
"0.1"
polonius-engine
=
"0.13.0"
regex
=
"1"
rustc_middle
=
{
path
=
"../rustc_middle"
}
smallvec
=
{
version
=
"1.0"
,
features
=
[
"union"
,
"may_dangle"
]
}
tracing
=
"0.1"
rustc_apfloat
=
{
path
=
"../rustc_apfloat"
}
rustc_ast
=
{
path
=
"../rustc_ast"
}
rustc_attr
=
{
path
=
"../rustc_attr"
}
rustc_data_structures
=
{
path
=
"../rustc_data_structures"
}
rustc_errors
=
{
path
=
"../rustc_errors"
}
rustc_graphviz
=
{
path
=
"../rustc_graphviz"
}
rustc_hir
=
{
path
=
"../rustc_hir"
}
rustc_index
=
{
path
=
"../rustc_index"
}
rustc_infer
=
{
path
=
"../rustc_infer"
}
rustc_lexer
=
{
path
=
"../rustc_lexer"
}
rustc_macros
=
{
path
=
"../rustc_macros"
}
rustc_middle
=
{
path
=
"../rustc_middle"
}
rustc_serialize
=
{
path
=
"../rustc_serialize"
}
rustc_session
=
{
path
=
"../rustc_session"
}
rustc_target
=
{
path
=
"../rustc_target"
}
rustc_trait_selection
=
{
path
=
"../rustc_trait_selection"
}
rustc_traits
=
{
path
=
"../rustc_traits"
}
rustc_ast
=
{
path
=
"../rustc_ast"
}
rustc_span
=
{
path
=
"../rustc_span"
}
rustc_apfloat
=
{
path
=
"../rustc_apfloat"
}
smallvec
=
{
version
=
"1.6.1"
,
features
=
[
"union"
,
"may_dangle"
]
}
[dev-dependencies]
coverage_test_macros
=
{
path
=
"src/transform/coverage/test_macros"
}
compiler/rustc_mir/src/dataflow/drop_flag_effects.rs
浏览文件 @
31a61ccc
...
...
@@ -204,7 +204,7 @@ pub(crate) fn drop_flag_effects_for_location<'tcx, F>(
for_location_inits
(
tcx
,
body
,
move_data
,
loc
,
|
mpi
|
callback
(
mpi
,
DropFlagState
::
Present
));
}
pub
(
crate
)
fn
for_location_inits
<
'tcx
,
F
>
(
pub
fn
for_location_inits
<
'tcx
,
F
>
(
tcx
:
TyCtxt
<
'tcx
>
,
body
:
&
Body
<
'tcx
>
,
move_data
:
&
MoveData
<
'tcx
>
,
...
...
compiler/rustc_mir/src/dataflow/framework/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -50,8 +50,7 @@
pub
use
self
::
direction
::{
Backward
,
Direction
,
Forward
};
pub
use
self
::
engine
::{
Engine
,
Results
};
pub
use
self
::
lattice
::{
JoinSemiLattice
,
MeetSemiLattice
};
pub
use
self
::
visitor
::{
visit_results
,
ResultsVisitor
};
pub
use
self
::
visitor
::{
BorrowckFlowState
,
BorrowckResults
};
pub
use
self
::
visitor
::{
visit_results
,
ResultsVisitable
,
ResultsVisitor
};
/// Define the domain of a dataflow problem.
///
...
...
compiler/rustc_mir/src/dataflow/framework/visitor.rs
浏览文件 @
31a61ccc
use
rustc_middle
::
mir
::{
self
,
BasicBlock
,
Location
};
use
super
::{
Analysis
,
Direction
,
Results
};
use
crate
::
dataflow
::
impls
::{
borrows
::
Borrows
,
EverInitializedPlaces
,
MaybeUninitializedPlaces
};
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
/// dataflow state at that location.
...
...
@@ -186,95 +185,3 @@ fn reconstruct_terminator_effect(
self
.analysis
.apply_terminator_effect
(
state
,
term
,
loc
);
}
}
/// A tuple with named fields that can hold either the results or the transient state of the
/// dataflow analyses used by the borrow checker.
#[derive(Debug)]
pub
struct
BorrowckAnalyses
<
B
,
U
,
E
>
{
pub
borrows
:
B
,
pub
uninits
:
U
,
pub
ever_inits
:
E
,
}
/// The results of the dataflow analyses used by the borrow checker.
pub
type
BorrowckResults
<
'mir
,
'tcx
>
=
BorrowckAnalyses
<
Results
<
'tcx
,
Borrows
<
'mir
,
'tcx
>>
,
Results
<
'tcx
,
MaybeUninitializedPlaces
<
'mir
,
'tcx
>>
,
Results
<
'tcx
,
EverInitializedPlaces
<
'mir
,
'tcx
>>
,
>
;
/// The transient state of the dataflow analyses used by the borrow checker.
pub
type
BorrowckFlowState
<
'mir
,
'tcx
>
=
<
BorrowckResults
<
'mir
,
'tcx
>
as
ResultsVisitable
<
'tcx
>>
::
FlowState
;
macro_rules!
impl_visitable
{
(
$
(
$T:ident
{
$
(
$field:ident
:
$A:ident
),
*
$
(,)
?
}
)
*
)
=>
{
$
(
impl
<
'tcx
,
$
(
$A
),
*
,
D
:
Direction
>
ResultsVisitable
<
'tcx
>
for
$T
<
$
(
Results
<
'tcx
,
$A
>
),
*>
where
$
(
$A
:
Analysis
<
'tcx
,
Direction
=
D
>
,
)
*
{
type
Direction
=
D
;
type
FlowState
=
$T
<
$
(
$A
::
Domain
),
*>
;
fn
new_flow_state
(
&
self
,
body
:
&
mir
::
Body
<
'tcx
>
)
->
Self
::
FlowState
{
$T
{
$
(
$field
:
self
.
$field
.analysis
.bottom_value
(
body
)
),
*
}
}
fn
reset_to_block_entry
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
block
:
BasicBlock
,
)
{
$
(
state
.
$field
.clone_from
(
&
self
.
$field
.entry_set_for_block
(
block
));
)
*
}
fn
reconstruct_before_statement_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
stmt
:
&
mir
::
Statement
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_before_statement_effect
(
&
mut
state
.
$field
,
stmt
,
loc
);
)
*
}
fn
reconstruct_statement_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
stmt
:
&
mir
::
Statement
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_statement_effect
(
&
mut
state
.
$field
,
stmt
,
loc
);
)
*
}
fn
reconstruct_before_terminator_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
term
:
&
mir
::
Terminator
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_before_terminator_effect
(
&
mut
state
.
$field
,
term
,
loc
);
)
*
}
fn
reconstruct_terminator_effect
(
&
self
,
state
:
&
mut
Self
::
FlowState
,
term
:
&
mir
::
Terminator
<
'tcx
>
,
loc
:
Location
,
)
{
$
(
self
.
$field
.analysis
.apply_terminator_effect
(
&
mut
state
.
$field
,
term
,
loc
);
)
*
}
}
)
*
}
}
impl_visitable!
{
BorrowckAnalyses
{
borrows
:
B
,
uninits
:
U
,
ever_inits
:
E
}
}
compiler/rustc_mir/src/dataflow/impls/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -21,13 +21,11 @@
use
crate
::
dataflow
::
framework
::
SwitchIntEdgeEffects
;
mod
borrowed_locals
;
pub
(
super
)
mod
borrows
;
mod
init_locals
;
mod
liveness
;
mod
storage_liveness
;
pub
use
self
::
borrowed_locals
::{
MaybeBorrowedLocals
,
MaybeMutBorrowedLocals
};
pub
use
self
::
borrows
::
Borrows
;
pub
use
self
::
init_locals
::
MaybeInitializedLocals
;
pub
use
self
::
liveness
::
MaybeLiveLocals
;
pub
use
self
::
storage_liveness
::{
MaybeRequiresStorage
,
MaybeStorageLive
};
...
...
compiler/rustc_mir/src/dataflow/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -5,9 +5,9 @@
pub
(
crate
)
use
self
::
drop_flag_effects
::
*
;
pub
use
self
::
framework
::{
fmt
,
graphviz
,
lattice
,
visit_results
,
Analysis
,
AnalysisDomain
,
Backward
,
BorrowckFlowState
,
BorrowckResults
,
Engine
,
Forward
,
GenKill
,
GenKillAnalysis
,
JoinSemiLattice
,
Results
,
Results
Cursor
,
ResultsRefCursor
,
ResultsVisitor
,
SwitchIntEdgeEffects
,
fmt
,
lattice
,
visit_results
,
Analysis
,
AnalysisDomain
,
Backward
,
Direction
,
Engine
,
Forward
,
GenKill
,
GenKillAnalysis
,
JoinSemiLattice
,
Results
,
ResultsCursor
,
ResultsRefCursor
,
Results
Visitable
,
ResultsVisitor
,
};
use
self
::
move_paths
::
MoveData
;
...
...
@@ -18,15 +18,12 @@
pub
mod
move_paths
;
pub
(
crate
)
mod
indexes
{
pub
(
crate
)
use
super
::{
impls
::
borrows
::
BorrowIndex
,
move_paths
::{
InitIndex
,
MoveOutIndex
,
MovePathIndex
},
};
pub
(
crate
)
use
super
::
move_paths
::
MovePathIndex
;
}
pub
struct
MoveDataParamEnv
<
'tcx
>
{
pub
(
crate
)
move_data
:
MoveData
<
'tcx
>
,
pub
(
crate
)
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
pub
move_data
:
MoveData
<
'tcx
>
,
pub
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
}
pub
(
crate
)
fn
has_rustc_mir_with
(
...
...
compiler/rustc_mir/src/dataflow/move_paths/mod.rs
浏览文件 @
31a61ccc
...
...
@@ -19,6 +19,12 @@ pub struct MovePathIndex {
}
}
impl
polonius_engine
::
Atom
for
MovePathIndex
{
fn
index
(
self
)
->
usize
{
rustc_index
::
vec
::
Idx
::
index
(
self
)
}
}
rustc_index
::
newtype_index!
{
pub
struct
MoveOutIndex
{
DEBUG_FORMAT
=
"mo{}"
...
...
@@ -276,7 +282,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
}
impl
Init
{
crate
fn
span
<
'tcx
>
(
&
self
,
body
:
&
Body
<
'tcx
>
)
->
Span
{
pub
fn
span
<
'tcx
>
(
&
self
,
body
:
&
Body
<
'tcx
>
)
->
Span
{
match
self
.location
{
InitLocation
::
Argument
(
local
)
=>
body
.local_decls
[
local
]
.source_info.span
,
InitLocation
::
Statement
(
location
)
=>
body
.source_info
(
location
)
.span
,
...
...
@@ -338,12 +344,12 @@ pub fn iter_locals_enumerated(&self) -> Enumerated<Local, Iter<'_, MovePathIndex
#[derive(Debug)]
pub
struct
IllegalMoveOrigin
<
'tcx
>
{
pub
(
crate
)
location
:
Location
,
pub
(
crate
)
kind
:
IllegalMoveOriginKind
<
'tcx
>
,
pub
location
:
Location
,
pub
kind
:
IllegalMoveOriginKind
<
'tcx
>
,
}
#[derive(Debug)]
pub
(
crate
)
enum
IllegalMoveOriginKind
<
'tcx
>
{
pub
enum
IllegalMoveOriginKind
<
'tcx
>
{
/// Illegal move due to attempt to move from behind a reference.
BorrowedContent
{
/// The place the reference refers to: if erroneous code was trying to
...
...
compiler/rustc_mir/src/lib.rs
浏览文件 @
31a61ccc
...
...
@@ -4,40 +4,35 @@
*/
#![feature(nll)]
#![feature(in_band_lifetimes)]
#![feature(array_windows)]
#![feature(assert_matches)]
#![cfg_attr(bootstrap,
feature(bindings_after_at))]
#![feature(associated_type_defaults)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(exact_size_is_empty)]
#![feature(
format_args_capture
)]
#![feature(
in_band_lifetimes
)]
#![feature(iter_zip)]
#![feature(never_type)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(slice_ptr_get)]
#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(associated_type_defaults)]
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(option_get_or_insert_default)]
#![feature(once_cell)]
#![feature(control_flow_enum)]
#![feature(try_reserve)]
#![feature(try_reserve_kind)]
#![recursion_limit
=
"256"
]
#![feature(never_type)]
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(trusted_len)]
#![feature(trusted_step)]
#![feature(try_blocks)]
#[macro_use]
extern
crate
tracing
;
#[macro_use]
extern
crate
rustc_middle
;
mod
borrow_check
;
pub
mod
const_eval
;
pub
mod
dataflow
;
pub
mod
interpret
;
...
...
@@ -46,13 +41,9 @@
pub
mod
transform
;
pub
mod
util
;
// A public API provided for the Rust compiler consumers.
pub
use
self
::
borrow_check
::
consumers
;
use
rustc_middle
::
ty
::
query
::
Providers
;
pub
fn
provide
(
providers
:
&
mut
Providers
)
{
borrow_check
::
provide
(
providers
);
const_eval
::
provide
(
providers
);
shim
::
provide
(
providers
);
transform
::
provide
(
providers
);
...
...
compiler/rustc_mir/src/transform/promote_consts.rs
浏览文件 @
31a61ccc
...
...
@@ -1058,7 +1058,7 @@ pub fn promote_candidates<'tcx>(
/// This function returns `true` if the function being called in the array
/// repeat expression is a `const` function.
crate
fn
is_const_fn_in_array_repeat_expression
<
'tcx
>
(
pub
fn
is_const_fn_in_array_repeat_expression
<
'tcx
>
(
ccx
:
&
ConstCx
<
'_
,
'tcx
>
,
place
:
&
Place
<
'tcx
>
,
body
:
&
Body
<
'tcx
>
,
...
...
compiler/rustc_mir/src/util/collect_writes.rs
浏览文件 @
31a61ccc
...
...
@@ -2,7 +2,7 @@
use
rustc_middle
::
mir
::
visit
::
Visitor
;
use
rustc_middle
::
mir
::{
Body
,
Local
,
Location
};
crate
trait
FindAssignments
{
pub
trait
FindAssignments
{
// Finds all statements that assign directly to local (i.e., X = ...)
// and returns their locations.
fn
find_assignments
(
&
self
,
local
:
Local
)
->
Vec
<
Location
>
;
...
...
compiler/rustc_mir/src/util/mod.rs
浏览文件 @
31a61ccc
pub
mod
aggregate
;
pub
mod
borrowck_errors
;
pub
mod
elaborate_drops
;
pub
mod
patch
;
pub
mod
storage
;
...
...
@@ -10,7 +9,7 @@
mod
generic_graph
;
pub
(
crate
)
mod
generic_graphviz
;
mod
graphviz
;
pub
(
crate
)
mod
pretty
;
pub
mod
pretty
;
pub
(
crate
)
mod
spanview
;
pub
use
self
::
aggregate
::
expand_aggregate
;
...
...
compiler/rustc_mir/src/util/pretty.rs
浏览文件 @
31a61ccc
...
...
@@ -250,7 +250,7 @@ fn create_dump_file_with_basename(
/// bit of MIR-related data. Used by `mir-dump`, but also by other
/// bits of code (e.g., NLL inference) that dump graphviz data or
/// other things, and hence takes the extension as an argument.
pub
(
crate
)
fn
create_dump_file
(
pub
fn
create_dump_file
(
tcx
:
TyCtxt
<
'_
>
,
extension
:
&
str
,
pass_num
:
Option
<&
dyn
Display
>
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录