@@ -19,22 +19,19 @@ use std::collections::hash_map::Entry;
19
19
use rustc:: hir:: { self , def_id:: DefId } ;
20
20
use rustc:: mir:: interpret:: ConstEvalErr ;
21
21
use rustc:: mir;
22
- use rustc:: ty:: { self , TyCtxt , Instance , query:: TyCtxtAt } ;
23
- use rustc:: ty:: layout:: { self , LayoutOf , TyLayout } ;
22
+ use rustc:: ty:: { self , Ty , TyCtxt , Instance , query:: TyCtxtAt } ;
23
+ use rustc:: ty:: layout:: { self , Size , LayoutOf , TyLayout } ;
24
24
use rustc:: ty:: subst:: Subst ;
25
25
use rustc_data_structures:: indexed_vec:: IndexVec ;
26
26
use rustc_data_structures:: fx:: FxHashMap ;
27
27
28
28
use syntax:: ast:: Mutability ;
29
29
use syntax:: source_map:: { Span , DUMMY_SP } ;
30
30
31
- use rustc:: mir:: interpret:: {
32
- EvalResult , EvalError , EvalErrorKind , GlobalId ,
33
- Scalar , Allocation , AllocId , ConstValue ,
34
- } ;
35
31
use interpret:: { self ,
36
- PlaceTy , MemPlace , OpTy , Operand , Value ,
37
- EvalContext , StackPopCleanup , MemoryKind ,
32
+ PlaceTy , MemPlace , OpTy , Operand , Value , Pointer , Scalar , ConstValue ,
33
+ EvalResult , EvalError , EvalErrorKind , GlobalId , EvalContext , StackPopCleanup ,
34
+ Allocation , AllocId , MemoryKind ,
38
35
snapshot,
39
36
} ;
40
37
@@ -53,7 +50,7 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
53
50
) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' mir , ' tcx > > {
54
51
debug ! ( "mk_borrowck_eval_cx: {:?}" , instance) ;
55
52
let param_env = tcx. param_env ( instance. def_id ( ) ) ;
56
- let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) , ( ) ) ;
53
+ let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
57
54
// insert a stack frame so any queries have the correct substs
58
55
// cannot use `push_stack_frame`; if we do `const_prop` explodes
59
56
ecx. stack . push ( interpret:: Frame {
@@ -76,7 +73,7 @@ pub fn mk_eval_cx<'a, 'tcx>(
76
73
) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' tcx , ' tcx > > {
77
74
debug ! ( "mk_eval_cx: {:?}, {:?}" , instance, param_env) ;
78
75
let span = tcx. def_span ( instance. def_id ( ) ) ;
79
- let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) , ( ) ) ;
76
+ let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
80
77
let mir = ecx. load_mir ( instance. def ) ?;
81
78
// insert a stack frame so any queries have the correct substs
82
79
ecx. push_stack_frame (
@@ -155,7 +152,7 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>(
155
152
// and try improving it down the road when more information is available
156
153
let span = tcx. def_span ( cid. instance . def_id ( ) ) ;
157
154
let span = mir. map ( |mir| mir. span ) . unwrap_or ( span) ;
158
- let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) , ( ) ) ;
155
+ let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
159
156
let r = eval_body_using_ecx ( & mut ecx, cid, mir, param_env) ;
160
157
( r, ecx)
161
158
}
@@ -333,16 +330,25 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
333
330
type CompileTimeEvalContext < ' a , ' mir , ' tcx > =
334
331
EvalContext < ' a , ' mir , ' tcx , CompileTimeInterpreter < ' a , ' mir , ' tcx > > ;
335
332
333
+ impl interpret:: MayLeak for ! {
334
+ #[ inline( always) ]
335
+ fn may_leak ( self ) -> bool {
336
+ // `self` is uninhabited
337
+ self
338
+ }
339
+ }
340
+
336
341
impl < ' a , ' mir , ' tcx > interpret:: Machine < ' a , ' mir , ' tcx >
337
342
for CompileTimeInterpreter < ' a , ' mir , ' tcx >
338
343
{
339
- type MemoryData = ( ) ;
340
344
type MemoryKinds = !;
345
+ type AllocExtra = ( ) ;
341
346
type PointerTag = ( ) ;
342
347
343
- type MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation < ( ) > ) > ;
348
+ type MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ;
344
349
345
350
const STATIC_KIND : Option < !> = None ; // no copying of statics allowed
351
+ const ENABLE_PTR_TRACKING_HOOKS : bool = false ; // we don't have no provenance
346
352
347
353
#[ inline( always) ]
348
354
fn enforce_validity ( _ecx : & EvalContext < ' a , ' mir , ' tcx , Self > ) -> bool {
@@ -456,6 +462,26 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
456
462
& ecx. stack [ ..] ,
457
463
)
458
464
}
465
+
466
+ #[ inline( always) ]
467
+ fn tag_reference (
468
+ _ecx : & mut EvalContext < ' a , ' mir , ' tcx , Self > ,
469
+ _ptr : Pointer < Self :: PointerTag > ,
470
+ _pointee_ty : Ty < ' tcx > ,
471
+ _pointee_size : Size ,
472
+ _borrow_kind : Option < mir:: BorrowKind > ,
473
+ ) -> EvalResult < ' tcx , Self :: PointerTag > {
474
+ Ok ( ( ) )
475
+ }
476
+
477
+ #[ inline( always) ]
478
+ fn tag_dereference (
479
+ _ecx : & EvalContext < ' a , ' mir , ' tcx , Self > ,
480
+ _ptr : Pointer < Self :: PointerTag > ,
481
+ _ptr_ty : Ty < ' tcx > ,
482
+ ) -> EvalResult < ' tcx , Self :: PointerTag > {
483
+ Ok ( ( ) )
484
+ }
459
485
}
460
486
461
487
/// Project to a field of a (variant of a) const
0 commit comments