@@ -19,22 +19,19 @@ use std::collections::hash_map::Entry;
1919use rustc:: hir:: { self , def_id:: DefId } ;
2020use rustc:: mir:: interpret:: ConstEvalErr ;
2121use 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 } ;
2424use rustc:: ty:: subst:: Subst ;
2525use rustc_data_structures:: indexed_vec:: IndexVec ;
2626use rustc_data_structures:: fx:: FxHashMap ;
2727
2828use syntax:: ast:: Mutability ;
2929use syntax:: source_map:: { Span , DUMMY_SP } ;
3030
31- use rustc:: mir:: interpret:: {
32- EvalResult , EvalError , EvalErrorKind , GlobalId ,
33- Scalar , Allocation , AllocId , ConstValue ,
34- } ;
3531use 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 ,
3835 snapshot,
3936} ;
4037
@@ -53,7 +50,7 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
5350) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' mir , ' tcx > > {
5451 debug ! ( "mk_borrowck_eval_cx: {:?}" , instance) ;
5552 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 ( ) ) ;
5754 // insert a stack frame so any queries have the correct substs
5855 // cannot use `push_stack_frame`; if we do `const_prop` explodes
5956 ecx. stack . push ( interpret:: Frame {
@@ -76,7 +73,7 @@ pub fn mk_eval_cx<'a, 'tcx>(
7673) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' tcx , ' tcx > > {
7774 debug ! ( "mk_eval_cx: {:?}, {:?}" , instance, param_env) ;
7875 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 ( ) ) ;
8077 let mir = ecx. load_mir ( instance. def ) ?;
8178 // insert a stack frame so any queries have the correct substs
8279 ecx. push_stack_frame (
@@ -155,7 +152,7 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>(
155152 // and try improving it down the road when more information is available
156153 let span = tcx. def_span ( cid. instance . def_id ( ) ) ;
157154 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 ( ) ) ;
159156 let r = eval_body_using_ecx ( & mut ecx, cid, mir, param_env) ;
160157 ( r, ecx)
161158}
@@ -333,16 +330,25 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
333330type CompileTimeEvalContext < ' a , ' mir , ' tcx > =
334331 EvalContext < ' a , ' mir , ' tcx , CompileTimeInterpreter < ' a , ' mir , ' tcx > > ;
335332
333+ impl interpret:: MayLeak for ! {
334+ #[ inline( always) ]
335+ fn may_leak ( self ) -> bool {
336+ // `self` is uninhabited
337+ self
338+ }
339+ }
340+
336341impl < ' a , ' mir , ' tcx > interpret:: Machine < ' a , ' mir , ' tcx >
337342 for CompileTimeInterpreter < ' a , ' mir , ' tcx >
338343{
339- type MemoryData = ( ) ;
340344 type MemoryKinds = !;
345+ type AllocExtra = ( ) ;
341346 type PointerTag = ( ) ;
342347
343- type MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation < ( ) > ) > ;
348+ type MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ;
344349
345350 const STATIC_KIND : Option < !> = None ; // no copying of statics allowed
351+ const ENABLE_PTR_TRACKING_HOOKS : bool = false ; // we don't have no provenance
346352
347353 #[ inline( always) ]
348354 fn enforce_validity ( _ecx : & EvalContext < ' a , ' mir , ' tcx , Self > ) -> bool {
@@ -456,6 +462,26 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
456462 & ecx. stack [ ..] ,
457463 )
458464 }
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+ }
459485}
460486
461487/// Project to a field of a (variant of a) const
0 commit comments