@@ -30,31 +30,31 @@ pub struct ConstProp;
30
30
impl MirPass for ConstProp {
31
31
fn run_pass < ' a , ' tcx > ( & self ,
32
32
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
33
- source : MirSource ,
33
+ source : MirSource < ' tcx > ,
34
34
mir : & mut Mir < ' tcx > ) {
35
35
// will be evaluated by miri and produce its errors there
36
36
if source. promoted . is_some ( ) {
37
37
return ;
38
38
}
39
39
40
40
use rustc:: hir:: map:: blocks:: FnLikeNode ;
41
- let node_id = tcx. hir ( ) . as_local_node_id ( source. def_id )
41
+ let node_id = tcx. hir ( ) . as_local_node_id ( source. def_id ( ) )
42
42
. expect ( "Non-local call to local provider is_const_fn" ) ;
43
43
44
44
let is_fn_like = FnLikeNode :: from_node ( tcx. hir ( ) . get ( node_id) ) . is_some ( ) ;
45
- let is_assoc_const = match tcx. describe_def ( source. def_id ) {
45
+ let is_assoc_const = match tcx. describe_def ( source. def_id ( ) ) {
46
46
Some ( Def :: AssociatedConst ( _) ) => true ,
47
47
_ => false ,
48
48
} ;
49
49
50
50
// Only run const prop on functions, methods, closures and associated constants
51
51
if !is_fn_like && !is_assoc_const {
52
52
// skip anon_const/statics/consts because they'll be evaluated by miri anyway
53
- trace ! ( "ConstProp skipped for {:?}" , source. def_id) ;
53
+ trace ! ( "ConstProp skipped for {:?}" , source. def_id( ) ) ;
54
54
return
55
55
}
56
56
57
- trace ! ( "ConstProp starting for {:?}" , source. def_id) ;
57
+ trace ! ( "ConstProp starting for {:?}" , source. def_id( ) ) ;
58
58
59
59
// FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
60
60
// constants, instead of just checking for const-folding succeeding.
@@ -63,7 +63,7 @@ impl MirPass for ConstProp {
63
63
let mut optimization_finder = ConstPropagator :: new ( mir, tcx, source) ;
64
64
optimization_finder. visit_mir ( mir) ;
65
65
66
- trace ! ( "ConstProp done for {:?}" , source. def_id) ;
66
+ trace ! ( "ConstProp done for {:?}" , source. def_id( ) ) ;
67
67
}
68
68
}
69
69
@@ -74,7 +74,7 @@ struct ConstPropagator<'a, 'mir, 'tcx:'a+'mir> {
74
74
ecx : EvalContext < ' a , ' mir , ' tcx , CompileTimeInterpreter < ' a , ' mir , ' tcx > > ,
75
75
mir : & ' mir Mir < ' tcx > ,
76
76
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
77
- source : MirSource ,
77
+ source : MirSource < ' tcx > ,
78
78
places : IndexVec < Local , Option < Const < ' tcx > > > ,
79
79
can_const_prop : IndexVec < Local , bool > ,
80
80
param_env : ParamEnv < ' tcx > ,
@@ -107,10 +107,10 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
107
107
fn new (
108
108
mir : & ' mir Mir < ' tcx > ,
109
109
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
110
- source : MirSource ,
110
+ source : MirSource < ' tcx > ,
111
111
) -> ConstPropagator < ' a , ' mir , ' tcx > {
112
- let param_env = tcx. param_env ( source. def_id ) ;
113
- let ecx = mk_eval_cx ( tcx, tcx. def_span ( source. def_id ) , param_env) ;
112
+ let param_env = tcx. param_env ( source. def_id ( ) ) ;
113
+ let ecx = mk_eval_cx ( tcx, tcx. def_span ( source. def_id ( ) ) , param_env) ;
114
114
ConstPropagator {
115
115
ecx,
116
116
mir,
@@ -284,13 +284,13 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
284
284
_ => None ,
285
285
} ,
286
286
Place :: Promoted ( ref promoted) => {
287
- let generics = self . tcx . generics_of ( self . source . def_id ) ;
287
+ let generics = self . tcx . generics_of ( self . source . def_id ( ) ) ;
288
288
if generics. requires_monomorphization ( self . tcx ) {
289
289
// FIXME: can't handle code with generics
290
290
return None ;
291
291
}
292
- let substs = Substs :: identity_for_item ( self . tcx , self . source . def_id ) ;
293
- let instance = Instance :: new ( self . source . def_id , substs) ;
292
+ let substs = Substs :: identity_for_item ( self . tcx , self . source . def_id ( ) ) ;
293
+ let instance = Instance :: new ( self . source . def_id ( ) , substs) ;
294
294
let cid = GlobalId {
295
295
instance,
296
296
promoted : Some ( promoted. 0 ) ,
@@ -358,10 +358,10 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
358
358
) ) )
359
359
}
360
360
Rvalue :: UnaryOp ( op, ref arg) => {
361
- let def_id = if self . tcx . is_closure ( self . source . def_id ) {
362
- self . tcx . closure_base_def_id ( self . source . def_id )
361
+ let def_id = if self . tcx . is_closure ( self . source . def_id ( ) ) {
362
+ self . tcx . closure_base_def_id ( self . source . def_id ( ) )
363
363
} else {
364
- self . source . def_id
364
+ self . source . def_id ( )
365
365
} ;
366
366
let generics = self . tcx . generics_of ( def_id) ;
367
367
if generics. requires_monomorphization ( self . tcx ) {
@@ -398,10 +398,10 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
398
398
Rvalue :: BinaryOp ( op, ref left, ref right) => {
399
399
trace ! ( "rvalue binop {:?} for {:?} and {:?}" , op, left, right) ;
400
400
let right = self . eval_operand ( right, source_info) ?;
401
- let def_id = if self . tcx . is_closure ( self . source . def_id ) {
402
- self . tcx . closure_base_def_id ( self . source . def_id )
401
+ let def_id = if self . tcx . is_closure ( self . source . def_id ( ) ) {
402
+ self . tcx . closure_base_def_id ( self . source . def_id ( ) )
403
403
} else {
404
- self . source . def_id
404
+ self . source . def_id ( )
405
405
} ;
406
406
let generics = self . tcx . generics_of ( def_id) ;
407
407
if generics. requires_monomorphization ( self . tcx ) {
@@ -608,7 +608,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
608
608
let node_id = self
609
609
. tcx
610
610
. hir ( )
611
- . as_local_node_id ( self . source . def_id )
611
+ . as_local_node_id ( self . source . def_id ( ) )
612
612
. expect ( "some part of a failing const eval must be local" ) ;
613
613
use rustc:: mir:: interpret:: EvalErrorKind :: * ;
614
614
let msg = match msg {
0 commit comments