@@ -25,19 +25,20 @@ use rustc_target::abi::Size;
25
25
use rustc_ast:: Mutability ;
26
26
27
27
use super :: { AllocId , Allocation , InterpCx , MPlaceTy , Machine , MemoryKind , Scalar , ValueVisitor } ;
28
+ use crate :: const_eval;
28
29
29
- pub trait CompileTimeMachine < ' mir , ' tcx > = Machine <
30
+ pub trait CompileTimeMachine < ' mir , ' tcx , T > = Machine <
30
31
' mir ,
31
32
' tcx ,
32
- MemoryKind = ! ,
33
+ MemoryKind = T ,
33
34
PointerTag = ( ) ,
34
35
ExtraFnVal = !,
35
36
FrameExtra = ( ) ,
36
37
AllocExtra = ( ) ,
37
- MemoryMap = FxHashMap < AllocId , ( MemoryKind < ! > , Allocation ) > ,
38
+ MemoryMap = FxHashMap < AllocId , ( MemoryKind < T > , Allocation ) > ,
38
39
> ;
39
40
40
- struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > {
41
+ struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx , const_eval :: MemoryKind > > {
41
42
/// The ectx from which we intern.
42
43
ecx: & ' rt mut InterpCx < ' mir , ' tcx , M > ,
43
44
/// Previously encountered safe references.
@@ -74,7 +75,7 @@ struct IsStaticOrFn;
74
75
/// `immutable` things might become mutable if `ty` is not frozen.
75
76
/// `ty` can be `None` if there is no potential interior mutability
76
77
/// 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 > > (
78
79
ecx : & ' rt mut InterpCx < ' mir , ' tcx , M > ,
79
80
leftover_allocations : & ' rt mut FxHashSet < AllocId > ,
80
81
alloc_id : AllocId ,
@@ -105,7 +106,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
105
106
// changes in this function.
106
107
match kind {
107
108
MemoryKind :: Stack
108
- | MemoryKind :: ConstHeap
109
+ | MemoryKind :: Machine ( const_eval :: MemoryKind :: Heap )
109
110
| MemoryKind :: Vtable
110
111
| MemoryKind :: CallerLocation => { }
111
112
}
@@ -141,7 +142,9 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
141
142
None
142
143
}
143
144
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
+ {
145
148
fn intern_shallow (
146
149
& mut self ,
147
150
alloc_id : AllocId ,
@@ -152,8 +155,8 @@ impl<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>> InternVisitor<'rt, 'mir
152
155
}
153
156
}
154
157
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 >
157
160
{
158
161
type V = MPlaceTy < ' tcx > ;
159
162
@@ -290,7 +293,7 @@ pub enum InternKind {
290
293
/// Any errors here would anyway be turned into `const_err` lints, whereas validation failures
291
294
/// are hard errors.
292
295
#[ 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 > > (
294
297
ecx : & mut InterpCx < ' mir , ' tcx , M > ,
295
298
intern_kind : InternKind ,
296
299
ret : MPlaceTy < ' tcx > ,
@@ -421,7 +424,9 @@ where
421
424
Ok ( ( ) )
422
425
}
423
426
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
+ {
425
430
/// A helper function that allocates memory for the layout given and gives you access to mutate
426
431
/// it. Once your own mutation code is done, the backing `Allocation` is removed from the
427
432
/// current `Memory` and returned.
0 commit comments