summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.rs
blob: 00871f9f450ca715ad6e1e0cf01cceefee68be44 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@aux-build:proc_macro_attr.rs

#![warn(clippy::needless_arbitrary_self_type)]

#[macro_use]
extern crate proc_macro_attr;

mod issue_6089 {
    // Check that we don't lint if the `self` parameter comes from expansion

    macro_rules! test_from_expansion {
        () => {
            trait T1 {
                fn test(self: &Self);
            }

            struct S1;

            impl T1 for S1 {
                fn test(self: &Self) {}
            }
        };
    }

    test_from_expansion!();

    // If only the lifetime name comes from expansion we will lint, but the suggestion will have
    // placeholders and will not be applied automatically, as we can't reliably know the original name.
    // This specific case happened with async_trait.

    trait T2 {
        fn call_with_mut_self(&mut self);
    }

    struct S2;

    // The method's signature will be expanded to:
    //  fn call_with_mut_self<'life0>(self: &'life0 mut Self) {}
    #[rename_my_lifetimes]
    impl T2 for S2 {
        #[allow(clippy::needless_lifetimes)]
        fn call_with_mut_self(self: &mut Self) {}
    }
}

fn main() {}