2022-04-04 15:56:56 +00: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 19:35:48 +00:00
|
|
|
//~^ ERROR: call to `std::mem::forget` with a value that does not implement `Drop`. Fo
|
2022-04-04 15:56:56 +00: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 19:35:48 +00:00
|
|
|
//~^ ERROR: call to `std::mem::forget` with a value that does not implement `Drop`. Fo
|
2022-04-04 15:56:56 +00:00
|
|
|
// Don't lint
|
|
|
|
forget(Baz(Bar));
|
|
|
|
}
|