@@ -44,9 +44,9 @@ struct InternVisitor<'rt, 'a: 'rt, 'mir: 'rt, 'tcx: 'a+'rt+'mir> {
44
44
45
45
#[ derive( Copy , Clone , Debug , PartialEq , Hash , Eq ) ]
46
46
enum InternMode {
47
- /// Mutable references don't change the `mutability` field to `Immutable`
48
- StaticMut ,
49
- /// Mutable references must in fact be immutable due to their surrounding immutability
47
+ /// Mutable references must in fact be immutable due to their surrounding immutability in a
48
+ /// `static`. In a `static mut` we start out as mutable and thus can also contain further `&mtu`
49
+ /// that will actually be treated as mutable.
50
50
Static ,
51
51
/// UnsafeCell is OK in the value of a constant, but not behind references in a constant
52
52
ConstBase ,
@@ -171,10 +171,10 @@ for
171
171
// This is not an inherent limitation, but one that we know to be true, because
172
172
// const qualification enforces it. We can lift it in the future.
173
173
match ( self . mode , mutability) {
174
- // all is "good and well" in the unsoundness of `static mut`
175
- ( InternMode :: StaticMut , _) => { } ,
176
174
// immutable references are fine everywhere
177
175
( _, hir:: Mutability :: MutImmutable ) => { } ,
176
+ // all is "good and well" in the unsoundness of `static mut`
177
+
178
178
// mutable references are ok in `static`. Either they are treated as immutable
179
179
// because they are behind an immutable one, or they are behind an `UnsafeCell`
180
180
// and thus ok.
@@ -251,7 +251,7 @@ pub fn intern_const_alloc_recursive(
251
251
Some ( hir:: Mutability :: MutImmutable ) => ( Mutability :: Immutable , InternMode :: Static ) ,
252
252
None => ( Mutability :: Immutable , InternMode :: ConstBase ) ,
253
253
// `static mut` doesn't care about interior mutability, it's mutable anyway
254
- Some ( hir:: Mutability :: MutMutable ) => ( Mutability :: Mutable , InternMode :: StaticMut ) ,
254
+ Some ( hir:: Mutability :: MutMutable ) => ( Mutability :: Mutable , InternMode :: Static ) ,
255
255
} ;
256
256
257
257
// type based interning
0 commit comments