summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/forget_non_drop.rs
blob: 7580cf95ebfa8214facad9f9338c14aa54dc7c68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#![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);

    struct Bar;
    impl Drop for Bar {
        fn drop(&mut self) {}
    }
    // Don't lint
    forget(Bar);

    struct Baz<T>(T);
    // Lint
    forget(Baz(Foo));
    // Don't lint
    forget(Baz(Bar));
}