@@ -25,19 +25,20 @@ use rustc_target::abi::Size;
2525use rustc_ast:: Mutability ;
2626
2727use super :: { AllocId , Allocation , InterpCx , MPlaceTy , Machine , MemoryKind , Scalar , ValueVisitor } ;
28+ use crate :: const_eval;
2829
29- pub trait CompileTimeMachine < ' mir , ' tcx > = Machine <
30+ pub trait CompileTimeMachine < ' mir , ' tcx , T > = Machine <
3031 ' mir ,
3132 ' tcx ,
32- MemoryKind = ! ,
33+ MemoryKind = T ,
3334 PointerTag = ( ) ,
3435 ExtraFnVal = !,
3536 FrameExtra = ( ) ,
3637 AllocExtra = ( ) ,
37- MemoryMap = FxHashMap < AllocId , ( MemoryKind < ! > , Allocation ) > ,
38+ MemoryMap = FxHashMap < AllocId , ( MemoryKind < T > , Allocation ) > ,
3839> ;
3940
40- struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > {
41+ struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx , const_eval :: MemoryKind > > {
4142 /// The ectx from which we intern.
4243 ecx: & ' rt mut InterpCx < ' mir , ' tcx , M > ,
4344 /// Previously encountered safe references.
@@ -74,7 +75,7 @@ struct IsStaticOrFn;
7475/// `immutable` things might become mutable if `ty` is not frozen.
7576/// `ty` can be `None` if there is no potential interior mutability
7677/// to account for (e.g. for vtables).
77- fn intern_shallow < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > (
78+ fn intern_shallow < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx , const_eval :: MemoryKind > > (
7879 ecx : & ' rt mut InterpCx < ' mir , ' tcx , M > ,
7980 leftover_allocations : & ' rt mut FxHashSet < AllocId > ,
8081 alloc_id : AllocId ,
@@ -105,7 +106,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
105106 // changes in this function.
106107 match kind {
107108 MemoryKind :: Stack
108- | MemoryKind :: ConstHeap
109+ | MemoryKind :: Machine ( const_eval :: MemoryKind :: Heap )
109110 | MemoryKind :: Vtable
110111 | MemoryKind :: CallerLocation => { }
111112 }
@@ -141,7 +142,9 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
141142 None
142143}
143144
144- impl < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > InternVisitor < ' rt , ' mir , ' tcx , M > {
145+ impl < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx , const_eval:: MemoryKind > >
146+ InternVisitor < ' rt , ' mir , ' tcx , M >
147+ {
145148 fn intern_shallow (
146149 & mut self ,
147150 alloc_id : AllocId ,
@@ -152,8 +155,8 @@ impl<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>> InternVisitor<'rt, 'mir
152155 }
153156}
154157
155- impl < ' rt , ' mir , ' tcx : ' mir , M : CompileTimeMachine < ' mir , ' tcx > > ValueVisitor < ' mir , ' tcx , M >
156- for InternVisitor < ' rt , ' mir , ' tcx , M >
158+ impl < ' rt , ' mir , ' tcx : ' mir , M : CompileTimeMachine < ' mir , ' tcx , const_eval :: MemoryKind > >
159+ ValueVisitor < ' mir , ' tcx , M > for InternVisitor < ' rt , ' mir , ' tcx , M >
157160{
158161 type V = MPlaceTy < ' tcx > ;
159162
@@ -290,7 +293,7 @@ pub enum InternKind {
290293/// Any errors here would anyway be turned into `const_err` lints, whereas validation failures
291294/// are hard errors.
292295#[ tracing:: instrument( skip( ecx) ) ]
293- pub fn intern_const_alloc_recursive < M : CompileTimeMachine < ' mir , ' tcx > > (
296+ pub fn intern_const_alloc_recursive < M : CompileTimeMachine < ' mir , ' tcx , const_eval :: MemoryKind > > (
294297 ecx : & mut InterpCx < ' mir , ' tcx , M > ,
295298 intern_kind : InternKind ,
296299 ret : MPlaceTy < ' tcx > ,
@@ -421,7 +424,9 @@ where
421424 Ok ( ( ) )
422425}
423426
424- impl < ' mir , ' tcx : ' mir , M : super :: intern:: CompileTimeMachine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
427+ impl < ' mir , ' tcx : ' mir , M : super :: intern:: CompileTimeMachine < ' mir , ' tcx , !> >
428+ InterpCx < ' mir , ' tcx , M >
429+ {
425430 /// A helper function that allocates memory for the layout given and gives you access to mutate
426431 /// it. Once your own mutation code is done, the backing `Allocation` is removed from the
427432 /// current `Memory` and returned.
0 commit comments