@@ -8,7 +8,7 @@ use rustc::hir::def::DefKind;
8
8
use rustc:: hir:: def_id:: DefId ;
9
9
use rustc:: mir:: {
10
10
AggregateKind , Constant , Location , Place , PlaceBase , Body , Operand , Rvalue ,
11
- Local , NullOp , UnOp , StatementKind , Statement , LocalKind , Static ,
11
+ Local , NullOp , UnOp , StatementKind , Statement , LocalKind ,
12
12
TerminatorKind , Terminator , ClearCrossCrate , SourceInfo , BinOp ,
13
13
SourceScope , SourceScopeLocalData , LocalDecl , BasicBlock ,
14
14
} ;
@@ -17,6 +17,7 @@ use rustc::mir::visit::{
17
17
} ;
18
18
use rustc:: mir:: interpret:: { Scalar , InterpResult , PanicInfo } ;
19
19
use rustc:: ty:: { self , Instance , ParamEnv , Ty , TyCtxt } ;
20
+ use syntax:: ast:: Mutability ;
20
21
use syntax_pos:: { Span , DUMMY_SP } ;
21
22
use rustc:: ty:: subst:: InternalSubsts ;
22
23
use rustc_data_structures:: fx:: FxHashMap ;
@@ -229,11 +230,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
229
230
l. access ( )
230
231
}
231
232
232
- fn before_eval_static (
233
- _ecx : & InterpCx < ' mir , ' tcx , Self > ,
234
- _place_static : & Static < ' tcx > ,
233
+ fn before_access_static (
234
+ allocation : & Allocation < Self :: PointerTag , Self :: AllocExtra > ,
235
235
) -> InterpResult < ' tcx > {
236
- throw_unsup_format ! ( "can't eval statics in ConstProp" ) ;
236
+ // if the static allocation is mutable or if it has relocations (it may be legal to mutate
237
+ // the memory behind that in the future), then we can't const prop it
238
+ if allocation. mutability == Mutability :: Mutable || allocation. relocations ( ) . len ( ) > 0 {
239
+ throw_unsup_format ! ( "can't eval mutable statics in ConstProp" ) ;
240
+ }
241
+
242
+ Ok ( ( ) )
237
243
}
238
244
239
245
fn before_terminator ( _ecx : & mut InterpCx < ' mir , ' tcx , Self > ) -> InterpResult < ' tcx > {
0 commit comments