File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
compiler/rustc_const_eval/src/interpret Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ pub fn intern_const_alloc_recursive<
148148 // better errors. Maybe we should consider doing validation before interning in the future.
149149 while let Some ( prov) = todo. pop ( ) {
150150 let alloc_id = prov. alloc_id ( ) ;
151+ // Crucially, we check this *before* checking whether the `alloc_id`
152+ // has already been interned. The point of this check is to ensure that when
153+ // there are multiple pointers to the same allocation, they are *all* immutable.
154+ // Therefore it would be bad if we only checked the first pointer to any given
155+ // allocation.
156+ // (It is likely not possible to actually have multiple pointers to the same allocation,
157+ // so alternatively we could also check that and ICE if there are multiple such pointers.)
151158 if intern_kind != InternKind :: Promoted
152159 && inner_mutability == Mutability :: Not
153160 && !prov. immutable ( )
You can’t perform that action at this time.
0 commit comments