1616use hir:: def:: DefKind ;
1717use rustc_ast:: Mutability ;
1818use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
19- use rustc_hir:: definitions:: { DefPathData , PerParentDisambiguatorState } ;
19+ use rustc_hir:: definitions:: DefPathData ;
2020use rustc_hir:: { self as hir} ;
2121use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrs ;
2222use rustc_middle:: mir:: interpret:: {
@@ -105,7 +105,6 @@ fn intern_shallow<'tcx, M: CompileTimeMachine<'tcx>>(
105105 ecx : & mut InterpCx < ' tcx , M > ,
106106 alloc_id : AllocId ,
107107 mutability : Mutability ,
108- disambiguator : Option < & mut PerParentDisambiguatorState > ,
109108) -> Result < impl Iterator < Item = CtfeProvenance > + ' tcx , InternError > {
110109 trace ! ( "intern_shallow {:?}" , alloc_id) ;
111110 // remove allocation
@@ -124,13 +123,7 @@ fn intern_shallow<'tcx, M: CompileTimeMachine<'tcx>>(
124123 // link the alloc id to the actual allocation
125124 let alloc = ecx. tcx . mk_const_alloc ( alloc) ;
126125 if let Some ( static_id) = ecx. machine . static_def_id ( ) {
127- intern_as_new_static (
128- ecx. tcx ,
129- static_id,
130- alloc_id,
131- alloc,
132- disambiguator. expect ( "disambiguator needed" ) ,
133- ) ;
126+ intern_as_new_static ( ecx. tcx , static_id, alloc_id, alloc) ;
134127 } else {
135128 ecx. tcx . set_alloc_id_memory ( alloc_id, alloc) ;
136129 }
@@ -144,18 +137,12 @@ fn intern_as_new_static<'tcx>(
144137 static_id : LocalDefId ,
145138 alloc_id : AllocId ,
146139 alloc : ConstAllocation < ' tcx > ,
147- disambiguator : & mut PerParentDisambiguatorState ,
148140) {
149- // `intern_const_alloc_recursive` is called once per static and it contains the `PerParentDisambiguatorState`.
150- // The `<static_id>::{{nested}}` path is thus unique to `intern_const_alloc_recursive` and the
151- // `PerParentDisambiguatorState` ensures the generated path is unique for this call as we generate
152- // `<static_id>::{{nested#n}}` where `n` is the `n`th `intern_as_new_static` call.
153141 let feed = tcx. create_def (
154142 static_id,
155143 None ,
156144 DefKind :: Static { safety : hir:: Safety :: Safe , mutability : alloc. 0 . mutability , nested : true } ,
157145 Some ( DefPathData :: NestedStatic ) ,
158- disambiguator,
159146 ) ;
160147 tcx. set_nested_alloc_id_static ( alloc_id, feed. def_id ( ) ) ;
161148
@@ -205,10 +192,6 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx>>(
205192 intern_kind : InternKind ,
206193 ret : & MPlaceTy < ' tcx > ,
207194) -> Result < ( ) , InternError > {
208- let mut disambiguator =
209- ecx. machine . static_def_id ( ) . map ( |id| PerParentDisambiguatorState :: new ( id) ) ;
210- let mut disambiguator = disambiguator. as_mut ( ) ;
211-
212195 // We are interning recursively, and for mutability we are distinguishing the "root" allocation
213196 // that we are starting in, and all other allocations that we are encountering recursively.
214197 let ( base_mutability, inner_mutability, is_static) = match intern_kind {
@@ -246,15 +229,13 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx>>(
246229 // This gives us the initial set of nested allocations, which will then all be processed
247230 // recursively in the loop below.
248231 let mut todo: Vec < _ > = if is_static {
249- assert ! ( disambiguator. is_some( ) ) ;
250232 // Do not steal the root allocation, we need it later to create the return value of `eval_static_initializer`.
251233 // But still change its mutability to match the requested one.
252234 let ( kind, alloc) = ecx. memory . alloc_map . get_mut ( & base_alloc_id) . unwrap ( ) ;
253235 prepare_alloc ( * ecx. tcx , * kind, alloc, base_mutability) ?;
254236 alloc. provenance ( ) . ptrs ( ) . iter ( ) . map ( |& ( _, prov) | prov) . collect ( )
255237 } else {
256- assert ! ( disambiguator. is_none( ) ) ;
257- intern_shallow ( ecx, base_alloc_id, base_mutability, None ) ?. collect ( )
238+ intern_shallow ( ecx, base_alloc_id, base_mutability) ?. collect ( )
258239 } ;
259240 // We need to distinguish "has just been interned" from "was already in `tcx`",
260241 // so we track this in a separate set.
@@ -336,7 +317,7 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx>>(
336317 // okay with losing some potential for immutability here. This can anyway only affect
337318 // `static mut`.
338319 just_interned. insert ( alloc_id) ;
339- let next = intern_shallow ( ecx, alloc_id, inner_mutability, disambiguator . as_deref_mut ( ) ) ?;
320+ let next = intern_shallow ( ecx, alloc_id, inner_mutability) ?;
340321 todo. extend ( next) ;
341322 }
342323 if found_bad_mutable_ptr {
@@ -366,7 +347,7 @@ pub fn intern_const_alloc_for_constprop<'tcx, M: CompileTimeMachine<'tcx>>(
366347 return interp_ok ( ( ) ) ;
367348 }
368349 // Move allocation to `tcx`.
369- if let Some ( _) = intern_shallow ( ecx, alloc_id, Mutability :: Not , None ) . unwrap ( ) . next ( ) {
350+ if let Some ( _) = intern_shallow ( ecx, alloc_id, Mutability :: Not ) . unwrap ( ) . next ( ) {
370351 // We are not doing recursive interning, so we don't currently support provenance.
371352 // (If this assertion ever triggers, we should just implement a
372353 // proper recursive interning loop -- or just call `intern_const_alloc_recursive`.
@@ -391,7 +372,7 @@ impl<'tcx> InterpCx<'tcx, DummyMachine> {
391372 let dest = self . allocate ( layout, MemoryKind :: Stack ) ?;
392373 f ( self , & dest. clone ( ) . into ( ) ) ?;
393374 let alloc_id = dest. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ; // this was just allocated, it must have provenance
394- for prov in intern_shallow ( self , alloc_id, Mutability :: Not , None ) . unwrap ( ) {
375+ for prov in intern_shallow ( self , alloc_id, Mutability :: Not ) . unwrap ( ) {
395376 // We are not doing recursive interning, so we don't currently support provenance.
396377 // (If this assertion ever triggers, we should just implement a
397378 // proper recursive interning loop -- or just call `intern_const_alloc_recursive`.
0 commit comments