@@ -18,7 +18,7 @@ use super::validity::RefTracking;
1818use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
1919use rustc_errors:: ErrorGuaranteed ;
2020use rustc_hir as hir;
21- use rustc_middle:: mir:: interpret:: InterpResult ;
21+ use rustc_middle:: mir:: interpret:: { CtfeProvenance , InterpResult } ;
2222use rustc_middle:: ty:: { self , layout:: TyAndLayout , Ty } ;
2323
2424use rustc_ast:: Mutability ;
@@ -34,7 +34,7 @@ pub trait CompileTimeMachine<'mir, 'tcx: 'mir, T> = Machine<
3434 ' mir ,
3535 ' tcx ,
3636 MemoryKind = T ,
37- Provenance = AllocId ,
37+ Provenance = CtfeProvenance ,
3838 ExtraFnVal = !,
3939 FrameExtra = ( ) ,
4040 AllocExtra = ( ) ,
@@ -135,7 +135,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
135135 alloc. mutability = Mutability :: Not ;
136136 } ;
137137 // link the alloc id to the actual allocation
138- leftover_allocations. extend ( alloc. provenance ( ) . ptrs ( ) . iter ( ) . map ( |& ( _, alloc_id ) | alloc_id) ) ;
138+ leftover_allocations. extend ( alloc. provenance ( ) . ptrs ( ) . iter ( ) . map ( |& ( _, prov ) | prov . alloc_id ( ) ) ) ;
139139 let alloc = tcx. mk_const_alloc ( alloc) ;
140140 tcx. set_alloc_id_memory ( alloc_id, alloc) ;
141141 None
@@ -178,10 +178,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
178178 tcx. struct_tail_erasing_lifetimes ( referenced_ty, self . ecx . param_env ) . kind ( )
179179 {
180180 let ptr = mplace. meta ( ) . unwrap_meta ( ) . to_pointer ( & tcx) ?;
181- if let Some ( alloc_id ) = ptr. provenance {
181+ if let Some ( prov ) = ptr. provenance {
182182 // Explicitly choose const mode here, since vtables are immutable, even
183183 // if the reference of the fat pointer is mutable.
184- self . intern_shallow ( alloc_id, InternMode :: Const , None ) ;
184+ self . intern_shallow ( prov . alloc_id ( ) , InternMode :: Const , None ) ;
185185 } else {
186186 // Validation will error (with a better message) on an invalid vtable pointer.
187187 // Let validation show the error message, but make sure it *does* error.
@@ -191,7 +191,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
191191 }
192192 // Check if we have encountered this pointer+layout combination before.
193193 // Only recurse for allocation-backed pointers.
194- if let Some ( alloc_id ) = mplace. ptr ( ) . provenance {
194+ if let Some ( prov ) = mplace. ptr ( ) . provenance {
195195 // Compute the mode with which we intern this. Our goal here is to make as many
196196 // statics as we can immutable so they can be placed in read-only memory by LLVM.
197197 let ref_mode = match self . mode {
@@ -234,7 +234,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
234234 InternMode :: Const
235235 }
236236 } ;
237- match self . intern_shallow ( alloc_id, ref_mode, Some ( referenced_ty) ) {
237+ match self . intern_shallow ( prov . alloc_id ( ) , ref_mode, Some ( referenced_ty) ) {
238238 // No need to recurse, these are interned already and statics may have
239239 // cycles, so we don't want to recurse there
240240 Some ( IsStaticOrFn ) => { }
@@ -353,7 +353,7 @@ pub fn intern_const_alloc_recursive<
353353 leftover_allocations,
354354 // The outermost allocation must exist, because we allocated it with
355355 // `Memory::allocate`.
356- ret. ptr ( ) . provenance . unwrap ( ) ,
356+ ret. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ,
357357 base_intern_mode,
358358 Some ( ret. layout . ty ) ,
359359 ) ;
@@ -431,7 +431,8 @@ pub fn intern_const_alloc_recursive<
431431 }
432432 let alloc = tcx. mk_const_alloc ( alloc) ;
433433 tcx. set_alloc_id_memory ( alloc_id, alloc) ;
434- for & ( _, alloc_id) in alloc. inner ( ) . provenance ( ) . ptrs ( ) . iter ( ) {
434+ for & ( _, prov) in alloc. inner ( ) . provenance ( ) . ptrs ( ) . iter ( ) {
435+ let alloc_id = prov. alloc_id ( ) ;
435436 if leftover_allocations. insert ( alloc_id) {
436437 todo. push ( alloc_id) ;
437438 }
@@ -503,10 +504,11 @@ impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>>
503504 // `allocate` picks a fresh AllocId that we will associate with its data below.
504505 let dest = self . allocate ( layout, MemoryKind :: Stack ) ?;
505506 f ( self , & dest. clone ( ) . into ( ) ) ?;
506- let mut alloc = self . memory . alloc_map . remove ( & dest. ptr ( ) . provenance . unwrap ( ) ) . unwrap ( ) . 1 ;
507+ let mut alloc =
508+ self . memory . alloc_map . remove ( & dest. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ) . unwrap ( ) . 1 ;
507509 alloc. mutability = Mutability :: Not ;
508510 let alloc = self . tcx . mk_const_alloc ( alloc) ;
509- let alloc_id = dest. ptr ( ) . provenance . unwrap ( ) ; // this was just allocated, it must have provenance
511+ let alloc_id = dest. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ; // this was just allocated, it must have provenance
510512 self . tcx . set_alloc_id_memory ( alloc_id, alloc) ;
511513 Ok ( alloc_id)
512514 }
0 commit comments