2023-01-24 02:06:35 -06:00
|
|
|
// This test checks that the lint `if_let_rescope` only actions
|
2024-10-20 16:06:30 -05:00
|
|
|
// when Edition 2021 or prior is targeted here because the lint should work especially
|
|
|
|
// when edition migration towards 2024 is executed.
|
2023-01-24 02:06:35 -06:00
|
|
|
|
2024-10-20 16:06:30 -05:00
|
|
|
//@ revisions: edition2021 edition2024
|
|
|
|
//@ [edition2021] edition: 2021
|
|
|
|
//@ [edition2024] edition: 2024
|
|
|
|
//@ [edition2024] compile-flags: -Zunstable-options
|
|
|
|
//@ [edition2024] check-pass
|
2023-01-24 02:06:35 -06:00
|
|
|
|
|
|
|
#![deny(if_let_rescope)]
|
|
|
|
#![allow(irrefutable_let_patterns)]
|
|
|
|
|
|
|
|
struct Droppy;
|
|
|
|
impl Drop for Droppy {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
println!("dropped");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Droppy {
|
|
|
|
fn get(&self) -> Option<u8> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if let Some(_value) = Droppy.get() {
|
2024-10-20 16:06:30 -05:00
|
|
|
//[edition2021]~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
|
|
|
//[edition2021]~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
|
|
//[edition2021]~| WARN: this changes meaning in Rust 2024
|
2024-09-05 14:03:10 -05:00
|
|
|
} else {
|
2024-10-20 16:06:30 -05:00
|
|
|
//[edition2021]~^ HELP: the value is now dropped here in Edition 2024
|
2024-09-05 14:03:10 -05:00
|
|
|
}
|
2023-01-24 02:06:35 -06:00
|
|
|
}
|