]> git.lizzy.rs Git - rust.git/blob - tests/ui/drop_non_drop.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / drop_non_drop.rs
1 #![warn(clippy::drop_non_drop)]
2
3 use core::mem::drop;
4
5 fn make_result<T>(t: T) -> Result<T, ()> {
6     Ok(t)
7 }
8
9 #[must_use]
10 fn must_use<T>(t: T) -> T {
11     t
12 }
13
14 fn drop_generic<T>(t: T) {
15     // Don't lint
16     drop(t)
17 }
18
19 fn main() {
20     struct Foo;
21     // Lint
22     drop(Foo);
23     // Don't lint
24     drop(make_result(Foo));
25     // Don't lint
26     drop(must_use(Foo));
27
28     struct Bar;
29     impl Drop for Bar {
30         fn drop(&mut self) {}
31     }
32     // Don't lint
33     drop(Bar);
34
35     struct Baz<T>(T);
36     // Lint
37     drop(Baz(Foo));
38     // Don't lint
39     drop(Baz(Bar));
40 }