@@ -15,9 +15,8 @@ use super::{
1515 AllocId , Allocation , InterpCx , Machine , MemoryKind , MPlaceTy , Scalar , ValueVisitor ,
1616} ;
1717
18- struct InternVisitor < ' rt , ' mir , ' tcx , M >
19- where
20- M : Machine <
18+ pub trait CompileTimeMachine < ' mir , ' tcx > =
19+ Machine <
2120 ' mir ,
2221 ' tcx ,
2322 MemoryKinds = !,
2726 MemoryExtra = ( ) ,
2827 AllocExtra = ( ) ,
2928 MemoryMap = FxHashMap < AllocId , ( MemoryKind < !> , Allocation ) > ,
30- > ,
31- {
29+ > ;
30+
31+ struct InternVisitor < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > > {
3232 /// The ectx from which we intern.
3333 ecx: & ' rt mut InterpCx < ' mir , ' tcx , M > ,
3434 /// Previously encountered safe references.
@@ -70,27 +70,14 @@ struct IsStaticOrFn;
7070/// `immutable` things might become mutable if `ty` is not frozen.
7171/// `ty` can be `None` if there is no potential interior mutability
7272/// 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 > > (
7474 ecx : & ' rt mut InterpCx < ' mir , ' tcx , M > ,
7575 leftover_allocations : & ' rt mut FxHashSet < AllocId > ,
7676 mode : InternMode ,
7777 alloc_id : AllocId ,
7878 mutability : Mutability ,
7979 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 > > {
9481 trace ! ( "InternVisitor::intern {:?} with {:?}" , alloc_id, mutability, ) ;
9582 // remove allocation
9683 let tcx = ecx. tcx ;
@@ -152,20 +139,7 @@ where
152139 Ok ( None )
153140}
154141
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 > {
169143 fn intern_shallow (
170144 & mut self ,
171145 alloc_id : AllocId ,
@@ -183,22 +157,10 @@ where
183157 }
184158}
185159
186- impl < ' rt , ' mir , ' tcx , M >
160+ impl < ' rt , ' mir , ' tcx , M : CompileTimeMachine < ' mir , ' tcx > >
187161 ValueVisitor < ' mir , ' tcx , M >
188162for
189163 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- > ,
202164{
203165 type V = MPlaceTy < ' tcx > ;
204166
@@ -312,25 +274,12 @@ where
312274 }
313275}
314276
315- pub fn intern_const_alloc_recursive < M > (
277+ pub fn intern_const_alloc_recursive < M : CompileTimeMachine < ' mir , ' tcx > > (
316278 ecx : & mut InterpCx < ' mir , ' tcx , M > ,
317279 // The `mutability` of the place, ignoring the type.
318280 place_mut : Option < hir:: Mutability > ,
319281 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 > {
334283 let tcx = ecx. tcx ;
335284 let ( base_mutability, base_intern_mode) = match place_mut {
336285 Some ( hir:: Mutability :: Immutable ) => ( Mutability :: Immutable , InternMode :: Static ) ,
0 commit comments