-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #90168 - tmiasko:const-qualif-storage, r=matthewjasper
Reset qualifs when a storage of a local ends Reset qualifs when a storage of a local ends to ensure that the local qualifs are affected by the state from previous loop iterations only if the local is kept alive. The change should be forward compatible with a stricter handling of indirect assignments, since storage dead invalidates all existing pointers to the local.
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Check that storage statements reset local qualification. | ||
// check-pass | ||
use std::cell::Cell; | ||
|
||
const C: Option<Cell<u32>> = { | ||
let mut c = None; | ||
let mut i = 0; | ||
while i == 0 { | ||
let mut x = None; | ||
c = x; | ||
x = Some(Cell::new(0)); | ||
let _ = x; | ||
i += 1; | ||
} | ||
c | ||
}; | ||
|
||
fn main() { | ||
let _: &'static _ = &C; | ||
} |