14
14
//! about type information, we want to avoid doing that.
15
15
16
16
use rustc_ast:: Mutability ;
17
- use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
17
+ use rustc_data_structures:: fx:: FxIndexMap ;
18
18
use rustc_errors:: ErrorGuaranteed ;
19
19
use rustc_hir as hir;
20
20
use rustc_middle:: mir:: interpret:: { CtfeProvenance , InterpResult } ;
@@ -127,9 +127,6 @@ pub fn intern_const_alloc_recursive<
127
127
let base_alloc_id = ret. ptr ( ) . provenance . unwrap ( ) . alloc_id ( ) ;
128
128
let mut todo: Vec < _ > =
129
129
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 ( ) ;
133
130
// Whether we encountered a bad mutable pointer.
134
131
// We want to first report "dangling" and then "mutable", so we need to delay reporting these
135
132
// errors.
@@ -150,22 +147,10 @@ pub fn intern_const_alloc_recursive<
150
147
debug_assert ! ( !ecx. memory. alloc_map. contains_key( & alloc_id) ) ;
151
148
continue ;
152
149
}
153
- just_interned. insert ( alloc_id) ;
154
150
if intern_kind != InternKind :: Promoted
155
151
&& inner_mutability == Mutability :: Not
156
152
&& !prov. immutable ( )
157
153
{
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
- }
169
154
// Found a mutable pointer inside a const where inner allocations should be
170
155
// immutable. We exclude promoteds from this, since things like `&mut []` and
171
156
// `&None::<Cell<i32>>` lead to promotion that can produce mutable pointers. We rely
0 commit comments