diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-19 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-19 00:00:00 +0000 |
| commit | 7581bae99615f0b7b3dd973a59448659d2946656 (patch) | |
| tree | a0e987f850373d178c2e330f9e7e53edae1e35e5 /src/test/ui | |
| parent | 1af55d19c7a9189374d89472f97dc119659bb67e (diff) | |
| download | rust-7581bae99615f0b7b3dd973a59448659d2946656.tar.gz rust-7581bae99615f0b7b3dd973a59448659d2946656.zip | |
Fix const qualification when executed after promotion
The const qualification was so far performed before the promotion and the implementation assumed that it will never encounter a promoted. With `const_precise_live_drops` feature, checking for live drops is delayed until after drop elaboration, which in turn runs after promotion. so the assumption is no longer true. When evaluating `NeedsNonConstDrop` it is now possible to encounter promoteds. Use type base qualification for the promoted. It is a sound approximation in general, and in the specific case of promoteds and `NeedsNonConstDrop` it is precise.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/consts/precise-drop-with-promoted.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/ui/consts/precise-drop-with-promoted.rs b/src/test/ui/consts/precise-drop-with-promoted.rs new file mode 100644 index 00000000000..6f2317a5a27 --- /dev/null +++ b/src/test/ui/consts/precise-drop-with-promoted.rs @@ -0,0 +1,9 @@ +// Regression test for issue #89938. +// check-pass +// compile-flags: --crate-type=lib +#![feature(const_precise_live_drops)] + +pub const fn f() { + let _: Option<String> = None; + let _: &'static Option<String> = &None; +} |
