@@ -147,13 +147,13 @@ for
147
147
// Handle trait object vtables
148
148
if let Ok ( meta) = value. to_meta ( ) {
149
149
if let ty:: Dynamic ( ..) = self . ecx . tcx . struct_tail ( referenced_ty) . sty {
150
- if let Ok ( vtable) = meta. unwrap ( ) . to_ptr ( ) {
151
- // explitly choose `Immutable` here, since vtables are immutable, even
152
- // if the reference of the fat pointer is mutable
153
- self . intern_shallow ( vtable, Mutability :: Immutable ) ?;
154
- }
150
+ if let Ok ( vtable) = meta. unwrap ( ) . to_ptr ( ) {
151
+ // explitly choose `Immutable` here, since vtables are immutable, even
152
+ // if the reference of the fat pointer is mutable
153
+ self . intern_shallow ( vtable, Mutability :: Immutable ) ?;
155
154
}
156
155
}
156
+ }
157
157
let mplace = self . ecx . ref_to_mplace ( value) ?;
158
158
// Check if we have encountered this pointer+layout combination before.
159
159
// Only recurse for allocation-backed pointers.
174
174
( InternMode :: Static , hir:: Mutability :: MutMutable ) => { } ,
175
175
// we statically prevent `&mut T` via `const_qualif` and double check this here
176
176
( InternMode :: ConstBase , hir:: Mutability :: MutMutable ) |
177
- ( InternMode :: Const , hir:: Mutability :: MutMutable ) =>
178
- bug ! ( "const qualif failed to prevent mutable references" ) ,
177
+ ( InternMode :: Const , hir:: Mutability :: MutMutable ) => {
178
+ match referenced_ty. sty {
179
+ ty:: Array ( _, n) if n. unwrap_usize ( self . ecx . tcx . tcx ) == 0 => { }
180
+ ty:: Slice ( _)
181
+ if value. to_meta ( ) . unwrap ( ) . unwrap ( ) . to_usize ( self . ecx ) ? == 0 => { }
182
+ _ => bug ! ( "const qualif failed to prevent mutable references" ) ,
183
+ }
184
+ } ,
179
185
}
180
186
// Compute the mutability with which we'll start visiting the allocation. This is
181
187
// what gets changed when we encounter an `UnsafeCell`
0 commit comments