2022-04-04 10:56:56 -05:00
|
|
|
#![warn(clippy::forget_non_drop)]
|
|
|
|
|
|
|
|
use core::mem::forget;
|
|
|
|
|
|
|
|
fn forget_generic<T>(t: T) {
|
|
|
|
// Don't lint
|
|
|
|
forget(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
struct Foo;
|
|
|
|
// Lint
|
|
|
|
forget(Foo);
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: call to `std::mem::forget` with a value that does not implement `Drop`. Fo
|
2022-04-04 10:56:56 -05:00
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
impl Drop for Bar {
|
|
|
|
fn drop(&mut self) {}
|
|
|
|
}
|
|
|
|
// Don't lint
|
|
|
|
forget(Bar);
|
|
|
|
|
|
|
|
struct Baz<T>(T);
|
|
|
|
// Lint
|
|
|
|
forget(Baz(Foo));
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: call to `std::mem::forget` with a value that does not implement `Drop`. Fo
|
2022-04-04 10:56:56 -05:00
|
|
|
// Don't lint
|
|
|
|
forget(Baz(Bar));
|
|
|
|
}
|