2024-10-20 15:47:02 -05:00
|
|
|
// This test is to demonstrate that the lint is gated behind Edition and
|
|
|
|
// is triggered only for Edition 2021 and before.
|
2024-08-04 14:50:15 -05:00
|
|
|
|
|
|
|
//@ check-pass
|
2024-10-20 15:47:02 -05:00
|
|
|
//@ edition: 2024
|
|
|
|
//@ compile-flags: -Z unstable-options
|
2024-08-04 14:50:15 -05:00
|
|
|
|
|
|
|
#![deny(tail_expr_drop_order)]
|
|
|
|
|
|
|
|
struct LoudDropper;
|
|
|
|
impl Drop for LoudDropper {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
// This destructor should be considered significant because it is a custom destructor
|
|
|
|
// and we will assume that the destructor can generate side effects arbitrarily so that
|
|
|
|
// a change in drop order is visible.
|
|
|
|
println!("loud drop");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl LoudDropper {
|
|
|
|
fn get(&self) -> i32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn should_not_lint() -> i32 {
|
|
|
|
let x = LoudDropper;
|
|
|
|
x.get() + LoudDropper.get()
|
|
|
|
// Lint should not action
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|