Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
63481a57
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
63481a57
编写于
6月 08, 2017
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: make InferCtxt optional in MemCategorizationContext.
上级
1f874ded
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
105 addition
and
91 deletion
+105
-91
src/librustc/infer/mod.rs
src/librustc/infer/mod.rs
+0
-21
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+26
-11
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+53
-28
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/check_loans.rs
+1
-2
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
+1
-2
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/check_match.rs
+8
-10
src/librustc_passes/consts.rs
src/librustc_passes/consts.rs
+8
-9
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionck.rs
+3
-3
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/check/upvar.rs
+5
-5
未找到文件。
src/librustc/infer/mod.rs
浏览文件 @
63481a57
...
...
@@ -393,27 +393,6 @@ pub fn infer_ctxt<E: InferEnv<'a, 'gcx>>(self, env: E) -> InferCtxtBuilder<'a, '
fresh_tables
:
env
.fresh_tables
()
.map
(
RefCell
::
new
),
}
}
/// Fake InferCtxt with the global tcx. Used by pre-MIR borrowck
/// for MemCategorizationContext/ExprUseVisitor.
/// If any inference functionality is used, ICEs will occur.
pub
fn
borrowck_fake_infer_ctxt
(
self
)
->
InferCtxt
<
'a
,
'gcx
,
'gcx
>
{
InferCtxt
{
tcx
:
self
,
tables
:
InferTables
::
Missing
,
type_variables
:
RefCell
::
new
(
type_variable
::
TypeVariableTable
::
new
()),
int_unification_table
:
RefCell
::
new
(
UnificationTable
::
new
()),
float_unification_table
:
RefCell
::
new
(
UnificationTable
::
new
()),
region_vars
:
RegionVarBindings
::
new
(
self
),
selection_cache
:
traits
::
SelectionCache
::
new
(),
evaluation_cache
:
traits
::
EvaluationCache
::
new
(),
projection_cache
:
RefCell
::
new
(
traits
::
ProjectionCache
::
new
()),
reported_trait_errors
:
RefCell
::
new
(
FxHashSet
()),
tainted_by_errors_flag
:
Cell
::
new
(
false
),
err_count_on_creation
:
self
.sess
.err_count
(),
in_snapshot
:
Cell
::
new
(
false
),
}
}
}
impl
<
'a
,
'gcx
,
'tcx
>
InferCtxtBuilder
<
'a
,
'gcx
,
'tcx
>
{
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
63481a57
...
...
@@ -261,16 +261,32 @@ pub struct ExprUseVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
)
}
impl
<
'a
,
'
gcx
,
'tcx
>
ExprUseVisitor
<
'a
,
'g
cx
,
'tcx
>
{
impl
<
'a
,
'
tcx
>
ExprUseVisitor
<
'a
,
't
cx
,
'tcx
>
{
pub
fn
new
(
delegate
:
&
'a
mut
(
Delegate
<
'tcx
>+
'a
),
infcx
:
&
'a
InferCtxt
<
'a
,
'g
cx
,
'tcx
>
,
tcx
:
TyCtxt
<
'a
,
't
cx
,
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
region_maps
:
&
'a
RegionMaps
,
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
)
->
Self
{
ExprUseVisitor
{
mc
:
mc
::
MemCategorizationContext
::
new
(
infcx
,
region_maps
,
tables
),
mc
:
mc
::
MemCategorizationContext
::
new
(
tcx
,
region_maps
,
tables
),
delegate
,
param_env
,
}
}
}
impl
<
'a
,
'gcx
,
'tcx
>
ExprUseVisitor
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
with_infer
(
delegate
:
&
'a
mut
(
Delegate
<
'tcx
>+
'a
),
infcx
:
&
'a
InferCtxt
<
'a
,
'gcx
,
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
region_maps
:
&
'a
RegionMaps
,
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
)
->
Self
{
ExprUseVisitor
{
mc
:
mc
::
MemCategorizationContext
::
with_infer
(
infcx
,
region_maps
,
tables
),
delegate
,
param_env
,
}
...
...
@@ -296,7 +312,7 @@ pub fn consume_body(&mut self, body: &hir::Body) {
}
fn
tcx
(
&
self
)
->
TyCtxt
<
'a
,
'gcx
,
'tcx
>
{
self
.mc.
infcx.
tcx
self
.mc.tcx
}
fn
delegate_consume
(
&
mut
self
,
...
...
@@ -306,7 +322,7 @@ fn delegate_consume(&mut self,
debug!
(
"delegate_consume(consume_id={}, cmt={:?})"
,
consume_id
,
cmt
);
let
mode
=
copy_or_move
(
self
.mc.infcx
,
self
.param_env
,
&
cmt
,
DirectRefMove
);
let
mode
=
copy_or_move
(
&
self
.mc
,
self
.param_env
,
&
cmt
,
DirectRefMove
);
self
.delegate
.consume
(
consume_id
,
consume_span
,
cmt
,
mode
);
}
...
...
@@ -784,7 +800,7 @@ fn determine_pat_move_mode(&mut self,
PatKind
::
Binding
(
hir
::
BindByRef
(
..
),
..
)
=>
mode
.lub
(
BorrowingMatch
),
PatKind
::
Binding
(
hir
::
BindByValue
(
..
),
..
)
=>
{
match
copy_or_move
(
self
.mc.infcx
,
self
.param_env
,
&
cmt_pat
,
PatBindingMove
)
{
match
copy_or_move
(
&
self
.mc
,
self
.param_env
,
&
cmt_pat
,
PatBindingMove
)
{
Copy
=>
mode
.lub
(
CopyingMatch
),
Move
(
..
)
=>
mode
.lub
(
MovingMatch
),
}
...
...
@@ -801,7 +817,6 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
debug!
(
"walk_pat cmt_discr={:?} pat={:?}"
,
cmt_discr
,
pat
);
let
tcx
=
self
.tcx
();
let
infcx
=
self
.mc.infcx
;
let
ExprUseVisitor
{
ref
mc
,
ref
mut
delegate
,
param_env
}
=
*
self
;
return_if_err!
(
mc
.cat_pattern
(
cmt_discr
.clone
(),
pat
,
|
cmt_pat
,
pat
|
{
if
let
PatKind
::
Binding
(
bmode
,
def_id
,
..
)
=
pat
.node
{
...
...
@@ -826,7 +841,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
}
}
hir
::
BindByValue
(
..
)
=>
{
let
mode
=
copy_or_move
(
infcx
,
param_env
,
&
cmt_pat
,
PatBindingMove
);
let
mode
=
copy_or_move
(
mc
,
param_env
,
&
cmt_pat
,
PatBindingMove
);
debug!
(
"walk_pat binding consuming pat"
);
delegate
.consume_pat
(
pat
,
cmt_pat
,
mode
);
}
...
...
@@ -885,7 +900,7 @@ fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
freevar
.def
));
match
upvar_capture
{
ty
::
UpvarCapture
::
ByValue
=>
{
let
mode
=
copy_or_move
(
self
.mc.infcx
,
let
mode
=
copy_or_move
(
&
self
.mc
,
self
.param_env
,
&
cmt_var
,
CaptureMove
);
...
...
@@ -917,13 +932,13 @@ fn cat_captured_var(&mut self,
}
}
fn
copy_or_move
<
'a
,
'gcx
,
'tcx
>
(
infcx
:
&
InferCt
xt
<
'a
,
'gcx
,
'tcx
>
,
fn
copy_or_move
<
'a
,
'gcx
,
'tcx
>
(
mc
:
&
mc
::
MemCategorizationConte
xt
<
'a
,
'gcx
,
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
cmt
:
&
mc
::
cmt
<
'tcx
>
,
move_reason
:
MoveReason
)
->
ConsumeMode
{
if
infcx
.type_moves_by_default
(
param_env
,
cmt
.ty
,
cmt
.span
)
{
if
mc
.type_moves_by_default
(
param_env
,
cmt
.ty
,
cmt
.span
)
{
Move
(
move_reason
)
}
else
{
Copy
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
63481a57
...
...
@@ -282,9 +282,10 @@ fn span(&self) -> Span { self.span }
#[derive(Clone)]
pub
struct
MemCategorizationContext
<
'a
,
'gcx
:
'a
+
'tcx
,
'tcx
:
'a
>
{
pub
infcx
:
&
'a
Infer
Ctxt
<
'a
,
'gcx
,
'tcx
>
,
pub
tcx
:
Ty
Ctxt
<
'a
,
'gcx
,
'tcx
>
,
pub
region_maps
:
&
'a
RegionMaps
,
pub
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
,
infcx
:
Option
<&
'a
InferCtxt
<
'a
,
'gcx
,
'tcx
>>
,
}
pub
type
McResult
<
T
>
=
Result
<
T
,
()
>
;
...
...
@@ -385,27 +386,51 @@ pub fn to_user_str(&self) -> &'static str {
}
}
impl
<
'a
,
'gcx
,
'tcx
>
MemCategorizationContext
<
'a
,
'gcx
,
'tcx
>
{
/// Context should be the `DefId` we use to fetch region-maps.
pub
fn
new
(
infcx
:
&
'a
InferCtxt
<
'a
,
'gcx
,
'tcx
>
,
impl
<
'a
,
'tcx
>
MemCategorizationContext
<
'a
,
'tcx
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
region_maps
:
&
'a
RegionMaps
,
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
)
->
MemCategorizationContext
<
'a
,
'
g
cx
,
'tcx
>
{
MemCategorizationContext
{
infcx
,
region_maps
,
tables
}
->
MemCategorizationContext
<
'a
,
'
t
cx
,
'tcx
>
{
MemCategorizationContext
{
tcx
,
region_maps
,
tables
,
infcx
:
None
}
}
}
fn
tcx
(
&
self
)
->
TyCtxt
<
'a
,
'gcx
,
'tcx
>
{
self
.infcx.tcx
impl
<
'a
,
'gcx
,
'tcx
>
MemCategorizationContext
<
'a
,
'gcx
,
'tcx
>
{
pub
fn
with_infer
(
infcx
:
&
'a
InferCtxt
<
'a
,
'gcx
,
'tcx
>
,
region_maps
:
&
'a
RegionMaps
,
tables
:
&
'a
ty
::
TypeckTables
<
'tcx
>
)
->
MemCategorizationContext
<
'a
,
'gcx
,
'tcx
>
{
MemCategorizationContext
{
tcx
:
infcx
.tcx
,
region_maps
,
tables
,
infcx
:
Some
(
infcx
),
}
}
pub
fn
type_moves_by_default
(
&
self
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
,
span
:
Span
)
->
bool
{
self
.infcx
.map
(|
infcx
|
infcx
.type_moves_by_default
(
param_env
,
ty
,
span
))
.or_else
(||
{
self
.tcx
.lift_to_global
(
&
(
param_env
,
ty
))
.map
(|(
param_env
,
ty
)|
{
ty
.moves_by_default
(
self
.tcx
.global_tcx
(),
param_env
,
span
)
})
})
.unwrap_or
(
true
)
}
fn
resolve_type_vars_if_possible
<
T
>
(
&
self
,
value
:
&
T
)
->
T
where
T
:
TypeFoldable
<
'tcx
>
{
self
.infcx
.resolve_type_vars_if_possible
(
value
)
self
.infcx
.map
(|
infcx
|
infcx
.resolve_type_vars_if_possible
(
value
))
.unwrap_or_else
(||
value
.clone
())
}
fn
is_tainted_by_errors
(
&
self
)
->
bool
{
self
.infcx
.
is_tainted_by_errors
(
)
self
.infcx
.
map_or
(
false
,
|
infcx
|
infcx
.is_tainted_by_errors
()
)
}
fn
resolve_type_vars_or_error
(
&
self
,
...
...
@@ -426,7 +451,7 @@ fn resolve_type_vars_or_error(&self,
None
if
self
.is_tainted_by_errors
()
=>
Err
(()),
None
=>
{
bug!
(
"no type for node {}: {} in mem_categorization"
,
id
,
self
.tcx
()
.hir
.node_to_string
(
id
));
id
,
self
.tcx.hir
.node_to_string
(
id
));
}
}
}
...
...
@@ -506,7 +531,7 @@ fn cat_expr_adjusted_with<F>(&self, expr: &hir::Expr,
adjustment
::
Adjust
::
Deref
(
overloaded
)
=>
{
// Equivalent to *expr or something similar.
let
base
=
if
let
Some
(
deref
)
=
overloaded
{
let
ref_ty
=
self
.tcx
()
.mk_ref
(
deref
.region
,
ty
::
TypeAndMut
{
let
ref_ty
=
self
.tcx
.mk_ref
(
deref
.region
,
ty
::
TypeAndMut
{
ty
:
target
,
mutbl
:
deref
.mutbl
,
});
...
...
@@ -624,17 +649,17 @@ pub fn cat_def(&self,
}
Def
::
Upvar
(
def_id
,
_
,
fn_node_id
)
=>
{
let
var_id
=
self
.tcx
()
.hir
.as_local_node_id
(
def_id
)
.unwrap
();
let
var_id
=
self
.tcx.hir
.as_local_node_id
(
def_id
)
.unwrap
();
self
.cat_upvar
(
id
,
span
,
var_id
,
fn_node_id
)
}
Def
::
Local
(
def_id
)
=>
{
let
vid
=
self
.tcx
()
.hir
.as_local_node_id
(
def_id
)
.unwrap
();
let
vid
=
self
.tcx.hir
.as_local_node_id
(
def_id
)
.unwrap
();
Ok
(
Rc
::
new
(
cmt_
{
id
:
id
,
span
:
span
,
cat
:
Categorization
::
Local
(
vid
),
mutbl
:
MutabilityCategory
::
from_local
(
self
.tcx
()
,
vid
),
mutbl
:
MutabilityCategory
::
from_local
(
self
.tcx
,
vid
),
ty
:
expr_ty
,
note
:
NoteNone
}))
...
...
@@ -686,7 +711,7 @@ fn cat_upvar(&self,
let
var_ty
=
self
.node_ty
(
var_id
)
?
;
// Mutability of original variable itself
let
var_mutbl
=
MutabilityCategory
::
from_local
(
self
.tcx
()
,
var_id
);
let
var_mutbl
=
MutabilityCategory
::
from_local
(
self
.tcx
,
var_id
);
// Construct the upvar. This represents access to the field
// from the environment (perhaps we should eventually desugar
...
...
@@ -753,11 +778,11 @@ fn env_deref(&self,
->
cmt_
<
'tcx
>
{
// Region of environment pointer
let
env_region
=
self
.tcx
()
.mk_region
(
ty
::
ReFree
(
ty
::
FreeRegion
{
let
env_region
=
self
.tcx
.mk_region
(
ty
::
ReFree
(
ty
::
FreeRegion
{
// The environment of a closure is guaranteed to
// outlive any bindings introduced in the body of the
// closure itself.
scope
:
self
.tcx
()
.hir
.local_def_id
(
upvar_id
.closure_expr_id
),
scope
:
self
.tcx.hir
.local_def_id
(
upvar_id
.closure_expr_id
),
bound_region
:
ty
::
BrEnv
}));
...
...
@@ -774,7 +799,7 @@ fn env_deref(&self,
// one.
let
cmt_result
=
cmt_
{
mutbl
:
McImmutable
,
ty
:
self
.tcx
()
.types.err
,
ty
:
self
.tcx.types.err
,
..
cmt_result
};
...
...
@@ -806,7 +831,7 @@ fn env_deref(&self,
pub
fn
temporary_scope
(
&
self
,
id
:
ast
::
NodeId
)
->
ty
::
Region
<
'tcx
>
{
let
scope
=
self
.region_maps
.temporary_scope
(
id
);
self
.tcx
()
.mk_region
(
match
scope
{
self
.tcx
.mk_region
(
match
scope
{
Some
(
scope
)
=>
ty
::
ReScope
(
scope
),
None
=>
ty
::
ReStatic
})
...
...
@@ -817,20 +842,20 @@ pub fn cat_rvalue_node(&self,
span
:
Span
,
expr_ty
:
Ty
<
'tcx
>
)
->
cmt
<
'tcx
>
{
let
promotable
=
self
.tcx
()
.rvalue_promotable_to_static
.borrow
()
.get
(
&
id
)
.cloned
()
let
promotable
=
self
.tcx.rvalue_promotable_to_static
.borrow
()
.get
(
&
id
)
.cloned
()
.unwrap_or
(
false
);
// When the corresponding feature isn't toggled, only promote `[T; 0]`.
let
promotable
=
match
expr_ty
.sty
{
ty
::
TyArray
(
_
,
0
)
=>
true
,
_
=>
promotable
&&
self
.tcx
()
.sess.features
.borrow
()
.rvalue_static_promotion
,
_
=>
promotable
&&
self
.tcx.sess.features
.borrow
()
.rvalue_static_promotion
,
};
// Compute maximum lifetime of this rvalue. This is 'static if
// we can promote to a constant, otherwise equal to enclosing temp
// lifetime.
let
re
=
if
promotable
{
self
.tcx
()
.types.re_static
self
.tcx.types.re_static
}
else
{
self
.temporary_scope
(
id
)
};
...
...
@@ -911,7 +936,7 @@ fn cat_overloaded_lvalue(&self,
span_bug!
(
expr
.span
,
"cat_overloaded_lvalue: base is not a reference"
)
}
};
let
ref_ty
=
self
.tcx
()
.mk_ref
(
region
,
ty
::
TypeAndMut
{
let
ref_ty
=
self
.tcx
.mk_ref
(
region
,
ty
::
TypeAndMut
{
ty
:
lvalue_ty
,
mutbl
,
});
...
...
@@ -1098,8 +1123,8 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McResul
Def
::
Variant
(
variant_did
)
|
Def
::
VariantCtor
(
variant_did
,
..
)
=>
{
// univariant enums do not need downcasts
let
enum_did
=
self
.tcx
()
.parent_def_id
(
variant_did
)
.unwrap
();
if
!
self
.tcx
()
.adt_def
(
enum_did
)
.is_univariant
()
{
let
enum_did
=
self
.tcx
.parent_def_id
(
variant_did
)
.unwrap
();
if
!
self
.tcx
.adt_def
(
enum_did
)
.is_univariant
()
{
self
.cat_downcast
(
pat
,
cmt
.clone
(),
cmt
.ty
,
variant_did
)
}
else
{
cmt
...
...
@@ -1116,8 +1141,8 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McResul
let
def
=
self
.tables
.qpath_def
(
qpath
,
pat
.id
);
let
expected_len
=
match
def
{
Def
::
VariantCtor
(
def_id
,
CtorKind
::
Fn
)
=>
{
let
enum_def
=
self
.tcx
()
.parent_def_id
(
def_id
)
.unwrap
();
self
.tcx
()
.adt_def
(
enum_def
)
.variant_with_id
(
def_id
)
.fields
.len
()
let
enum_def
=
self
.tcx
.parent_def_id
(
def_id
)
.unwrap
();
self
.tcx
.adt_def
(
enum_def
)
.variant_with_id
(
def_id
)
.fields
.len
()
}
Def
::
StructCtor
(
_
,
CtorKind
::
Fn
)
=>
{
match
self
.pat_ty
(
&
pat
)
?
.sty
{
...
...
src/librustc_borrowck/borrowck/check_loans.rs
浏览文件 @
63481a57
...
...
@@ -200,8 +200,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
all_loans
:
all_loans
,
param_env
,
};
let
infcx
=
bccx
.tcx
.borrowck_fake_infer_ctxt
();
euv
::
ExprUseVisitor
::
new
(
&
mut
clcx
,
&
infcx
,
param_env
,
&
bccx
.region_maps
,
bccx
.tables
)
euv
::
ExprUseVisitor
::
new
(
&
mut
clcx
,
bccx
.tcx
,
param_env
,
&
bccx
.region_maps
,
bccx
.tables
)
.consume_body
(
body
);
}
...
...
src/librustc_borrowck/borrowck/gather_loans/mod.rs
浏览文件 @
63481a57
...
...
@@ -49,8 +49,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
};
let
body
=
glcx
.bccx.tcx.hir
.body
(
body
);
let
infcx
=
bccx
.tcx
.borrowck_fake_infer_ctxt
();
euv
::
ExprUseVisitor
::
new
(
&
mut
glcx
,
&
infcx
,
param_env
,
&
bccx
.region_maps
,
bccx
.tables
)
euv
::
ExprUseVisitor
::
new
(
&
mut
glcx
,
bccx
.tcx
,
param_env
,
&
bccx
.region_maps
,
bccx
.tables
)
.consume_body
(
body
);
glcx
.report_potential_errors
();
...
...
src/librustc_const_eval/check_match.rs
浏览文件 @
63481a57
...
...
@@ -493,20 +493,18 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
///
/// FIXME: this should be done by borrowck.
fn
check_for_mutation_in_guard
(
cx
:
&
MatchVisitor
,
guard
:
&
hir
::
Expr
)
{
cx
.tcx
.infer_ctxt
(())
.enter
(|
infcx
|
{
let
mut
checker
=
MutationChecker
{
cx
:
cx
,
};
ExprUseVisitor
::
new
(
&
mut
checker
,
&
infcx
,
cx
.param_env
,
cx
.region_maps
,
cx
.tables
)
.walk_expr
(
guard
);
});
let
mut
checker
=
MutationChecker
{
cx
:
cx
,
};
ExprUseVisitor
::
new
(
&
mut
checker
,
cx
.tcx
,
cx
.param_env
,
cx
.region_maps
,
cx
.tables
)
.walk_expr
(
guard
);
}
struct
MutationChecker
<
'a
,
'
g
cx
:
'a
>
{
cx
:
&
'a
MatchVisitor
<
'a
,
'
g
cx
>
,
struct
MutationChecker
<
'a
,
'
t
cx
:
'a
>
{
cx
:
&
'a
MatchVisitor
<
'a
,
'
t
cx
>
,
}
impl
<
'a
,
'
gcx
,
'tcx
>
Delegate
<
'tcx
>
for
MutationChecker
<
'a
,
'g
cx
>
{
impl
<
'a
,
'
tcx
>
Delegate
<
'tcx
>
for
MutationChecker
<
'a
,
't
cx
>
{
fn
matched_pat
(
&
mut
self
,
_
:
&
Pat
,
_
:
cmt
,
_
:
euv
::
MatchMode
)
{}
fn
consume
(
&
mut
self
,
_
:
ast
::
NodeId
,
_
:
Span
,
_
:
cmt
,
_
:
ConsumeMode
)
{}
fn
consume_pat
(
&
mut
self
,
_
:
&
Pat
,
_
:
cmt
,
_
:
ConsumeMode
)
{}
...
...
src/librustc_passes/consts.rs
浏览文件 @
63481a57
...
...
@@ -51,7 +51,6 @@
use
std
::
collections
::
hash_map
::
Entry
;
use
std
::
cmp
::
Ordering
;
use
std
::
mem
;
struct
CheckCrateVisitor
<
'a
,
'tcx
:
'a
>
{
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
...
...
@@ -138,14 +137,14 @@ fn visit_nested_body(&mut self, body_id: hir::BodyId) {
self
.check_const_eval
(
&
body
.value
);
}
let
outer_penv
=
self
.
tcx
.infer_ctxt
(())
.enter
(|
infcx
|
{
let
param_env
=
self
.tcx
.param_env
(
item_def_id
);
let
outer_penv
=
mem
::
replace
(
&
mut
self
.param_env
,
param_env
);
let
region_maps
=
&
self
.tcx
.region_maps
(
item_def_id
)
;
euv
::
ExprUseVisitor
::
new
(
self
,
&
infcx
,
param_env
,
region_maps
,
self
.tables
)
.consume_body
(
body
);
outer_penv
}
);
let
outer_penv
=
self
.
param_env
;
self
.
param_env
=
self
.tcx
.param_env
(
item_def_id
);
let
tcx
=
self
.tcx
;
let
param_env
=
self
.param_env
;
let
region_maps
=
self
.tcx
.region_maps
(
item_def_id
);
euv
::
ExprUseVisitor
::
new
(
self
,
tcx
,
param_env
,
&
region_maps
,
self
.tables
)
.consume_body
(
body
);
self
.visit_body
(
body
);
...
...
src/librustc_typeck/check/regionck.rs
浏览文件 @
63481a57
...
...
@@ -828,9 +828,9 @@ fn constrain_call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
fn
with_mc
<
F
,
R
>
(
&
self
,
f
:
F
)
->
R
where
F
:
for
<
'b
>
FnOnce
(
mc
::
MemCategorizationContext
<
'b
,
'gcx
,
'tcx
>
)
->
R
{
f
(
mc
::
MemCategorizationContext
::
new
(
&
self
.infcx
,
&
self
.region_maps
,
&
self
.tables
.borrow
()))
f
(
mc
::
MemCategorizationContext
::
with_infer
(
&
self
.infcx
,
&
self
.region_maps
,
&
self
.tables
.borrow
()))
}
/// Invoked on any adjustments that occur. Checks that if this is a region pointer being
...
...
src/librustc_typeck/check/upvar.rs
浏览文件 @
63481a57
...
...
@@ -142,11 +142,11 @@ fn analyze_closure(&self,
adjust_closure_kinds
:
NodeMap
(),
adjust_upvar_captures
:
ty
::
UpvarCaptureMap
::
default
(),
};
euv
::
ExprUseVisitor
::
new
(
&
mut
delegate
,
&
self
.infcx
,
self
.param_env
,
region_maps
,
&
self
.tables
.borrow
())
euv
::
ExprUseVisitor
::
with_infer
(
&
mut
delegate
,
&
self
.infcx
,
self
.param_env
,
region_maps
,
&
self
.tables
.borrow
())
.consume_body
(
body
);
// Write the adjusted values back into the main tables.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录