@@ -15,9 +15,8 @@ use super::{
15
15
AllocId , Allocation , InterpCx , Machine , MemoryKind , MPlaceTy , Scalar , ValueVisitor ,
16
16
} ;
17
17
18
- struct InternVisitor < ' rt , ' mir , ' tcx , M >
19
- where
20
- M : Machine <
18
+ pub trait CompileTimeMachine < ' mir , ' tcx > =
19
+ Machine <
21
20
' mir ,
22
21
' tcx ,
23
22
MemoryKinds = !,
27
26
MemoryExtra = ( ) ,
28
27
AllocExtra = ( ) ,
29
28
MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
30
- > ,
31
- {
29
+ > ;
30
+
31
+ struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > {
32
32
/// The ectx from which we intern.
33
33
ecx: & ' rt mut InterpCx < ' mir , ' tcx , M > ,
34
34
/// Previously encountered safe references.
@@ -70,27 +70,14 @@ struct IsStaticOrFn;
70
70
/// `immutable` things might become mutable if `ty` is not frozen.
71
71
/// `ty` can be `None` if there is no potential interior mutability
72
72
/// to account for (e.g. for vtables).
73
- fn intern_shallow < ' rt , ' mir , ' tcx , M > (
73
+ fn intern_shallow < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > (
74
74
ecx : & ' rt mut InterpCx < ' mir , ' tcx , M > ,
75
75
leftover_allocations : & ' rt mut FxHashSet < AllocId > ,
76
76
mode : InternMode ,
77
77
alloc_id : AllocId ,
78
78
mutability : Mutability ,
79
79
ty : Option < Ty < ' tcx > > ,
80
- ) -> InterpResult < ' tcx , Option < IsStaticOrFn > >
81
- where
82
- M : Machine <
83
- ' mir ,
84
- ' tcx ,
85
- MemoryKinds = !,
86
- PointerTag = ( ) ,
87
- ExtraFnVal = !,
88
- FrameExtra = ( ) ,
89
- MemoryExtra = ( ) ,
90
- AllocExtra = ( ) ,
91
- MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
92
- > ,
93
- {
80
+ ) -> InterpResult < ' tcx , Option < IsStaticOrFn > > {
94
81
trace ! ( "InternVisitor::intern {:?} with {:?}" , alloc_id, mutability, ) ;
95
82
// remove allocation
96
83
let tcx = ecx. tcx ;
@@ -152,20 +139,7 @@ where
152
139
Ok ( None )
153
140
}
154
141
155
- impl < ' rt , ' mir , ' tcx , M > InternVisitor < ' rt , ' mir , ' tcx , M >
156
- where
157
- M : Machine <
158
- ' mir ,
159
- ' tcx ,
160
- MemoryKinds = !,
161
- PointerTag = ( ) ,
162
- ExtraFnVal = !,
163
- FrameExtra = ( ) ,
164
- MemoryExtra = ( ) ,
165
- AllocExtra = ( ) ,
166
- MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
167
- > ,
168
- {
142
+ impl < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > InternVisitor < ' rt , ' mir , ' tcx , M > {
169
143
fn intern_shallow (
170
144
& mut self ,
171
145
alloc_id : AllocId ,
@@ -183,22 +157,10 @@ where
183
157
}
184
158
}
185
159
186
- impl < ' rt , ' mir , ' tcx , M >
160
+ impl < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > >
187
161
ValueVisitor < ' mir , ' tcx , M >
188
162
for
189
163
InternVisitor < ' rt , ' mir , ' tcx , M >
190
- where
191
- M : Machine <
192
- ' mir ,
193
- ' tcx ,
194
- MemoryKinds = !,
195
- PointerTag = ( ) ,
196
- ExtraFnVal = !,
197
- FrameExtra = ( ) ,
198
- MemoryExtra = ( ) ,
199
- AllocExtra = ( ) ,
200
- MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
201
- > ,
202
164
{
203
165
type V = MPlaceTy < ' tcx > ;
204
166
@@ -312,25 +274,12 @@ where
312
274
}
313
275
}
314
276
315
- pub fn intern_const_alloc_recursive < M > (
277
+ pub fn intern_const_alloc_recursive < M : CompileTimeMachine < ' mir , ' tcx > > (
316
278
ecx : & mut InterpCx < ' mir , ' tcx , M > ,
317
279
// The `mutability` of the place, ignoring the type.
318
280
place_mut : Option < hir:: Mutability > ,
319
281
ret : MPlaceTy < ' tcx > ,
320
- ) -> InterpResult < ' tcx >
321
- where
322
- M : Machine <
323
- ' mir ,
324
- ' tcx ,
325
- MemoryKinds = !,
326
- PointerTag = ( ) ,
327
- ExtraFnVal = !,
328
- FrameExtra = ( ) ,
329
- MemoryExtra = ( ) ,
330
- AllocExtra = ( ) ,
331
- MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
332
- > ,
333
- {
282
+ ) -> InterpResult < ' tcx > {
334
283
let tcx = ecx. tcx ;
335
284
let ( base_mutability, base_intern_mode) = match place_mut {
336
285
Some ( hir:: Mutability :: Immutable ) => ( Mutability :: Immutable , InternMode :: Static ) ,
0 commit comments