1414//! about type information, we want to avoid doing that.
1515
1616use rustc_ast:: Mutability ;
17- use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
17+ use rustc_data_structures:: fx:: FxIndexMap ;
1818use rustc_errors:: ErrorGuaranteed ;
1919use rustc_hir as hir;
2020use rustc_middle:: mir:: interpret:: { CtfeProvenance , InterpResult } ;
@@ -127,9 +127,6 @@ pub fn intern_const_alloc_recursive<
127127 let base_alloc_id = ret. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
128128 let mut todo: Vec < _ > =
129129 intern_shallow ( ecx, base_alloc_id, base_mutability) . unwrap ( ) . map ( |prov| prov) . collect ( ) ;
130- // We need to distinguish "has just been interned" from "was already in `tcx`",
131- // so we track this in a separate set.
132- let mut just_interned = FxHashSet :: default ( ) ;
133130 // Whether we encountered a bad mutable pointer.
134131 // We want to first report "dangling" and then "mutable", so we need to delay reporting these
135132 // errors.
@@ -150,22 +147,10 @@ pub fn intern_const_alloc_recursive<
150147 debug_assert ! ( !ecx. memory. alloc_map. contains_key( & alloc_id) ) ;
151148 continue ;
152149 }
153- just_interned. insert ( alloc_id) ;
154150 if intern_kind != InternKind :: Promoted
155151 && inner_mutability == Mutability :: Not
156152 && !prov. immutable ( )
157153 {
158- if ecx. tcx . try_get_global_alloc ( alloc_id) . is_some ( )
159- && !just_interned. contains ( & alloc_id)
160- {
161- // This is a pointer to some memory from another constant. We encounter mutable
162- // pointers to such memory since we do not always track immutability through
163- // these "global" pointers. Allowing them is harmless; the point of these checks
164- // during interning is to justify why we intern the *new* allocations immutably,
165- // so we can completely ignore existing allocations. We also don't need to add
166- // this to the todo list, since after all it is already interned.
167- continue ;
168- }
169154 // Found a mutable pointer inside a const where inner allocations should be
170155 // immutable. We exclude promoteds from this, since things like `&mut []` and
171156 // `&None::<Cell<i32>>` lead to promotion that can produce mutable pointers. We rely
0 commit comments