rust/tests/ui/drop/lint-tail-expr-drop-order-gated.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
775 B
Rust
Raw Normal View History

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.
//@ check-pass
2024-10-20 15:47:02 -05:00
//@ edition: 2024
//@ compile-flags: -Z unstable-options
#![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() {}