Skip to content

Commit 9e3fbcf

Browse files
committed
Merge StaticMut and Static logic
1 parent d6fa407 commit 9e3fbcf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/librustc_mir/interpret/intern.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ struct InternVisitor<'rt, 'a: 'rt, 'mir: 'rt, 'tcx: 'a+'rt+'mir> {
4444

4545
#[derive(Copy, Clone, Debug, PartialEq, Hash, Eq)]
4646
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.
5050
Static,
5151
/// UnsafeCell is OK in the value of a constant, but not behind references in a constant
5252
ConstBase,
@@ -171,10 +171,10 @@ for
171171
// This is not an inherent limitation, but one that we know to be true, because
172172
// const qualification enforces it. We can lift it in the future.
173173
match (self.mode, mutability) {
174-
// all is "good and well" in the unsoundness of `static mut`
175-
(InternMode::StaticMut, _) => {},
176174
// immutable references are fine everywhere
177175
(_, hir::Mutability::MutImmutable) => {},
176+
// all is "good and well" in the unsoundness of `static mut`
177+
178178
// mutable references are ok in `static`. Either they are treated as immutable
179179
// because they are behind an immutable one, or they are behind an `UnsafeCell`
180180
// and thus ok.
@@ -251,7 +251,7 @@ pub fn intern_const_alloc_recursive(
251251
Some(hir::Mutability::MutImmutable) => (Mutability::Immutable, InternMode::Static),
252252
None => (Mutability::Immutable, InternMode::ConstBase),
253253
// `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),
255255
};
256256

257257
// type based interning

0 commit comments

Comments
 (0)