]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/needless_arbitrary_self_type_unfixable.rs
Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
[rust.git] / src / tools / clippy / tests / ui / needless_arbitrary_self_type_unfixable.rs
1 // aux-build:proc_macro_attr.rs
2
3 #![warn(clippy::needless_arbitrary_self_type)]
4
5 #[macro_use]
6 extern crate proc_macro_attr;
7
8 mod issue_6089 {
9     // Check that we don't lint if the `self` parameter comes from expansion
10
11     macro_rules! test_from_expansion {
12         () => {
13             trait T1 {
14                 fn test(self: &Self);
15             }
16
17             struct S1;
18
19             impl T1 for S1 {
20                 fn test(self: &Self) {}
21             }
22         };
23     }
24
25     test_from_expansion!();
26
27     // If only the lifetime name comes from expansion we will lint, but the suggestion will have
28     // placeholders and will not be applied automatically, as we can't reliably know the original name.
29     // This specific case happened with async_trait.
30
31     trait T2 {
32         fn call_with_mut_self(&mut self);
33     }
34
35     struct S2;
36
37     // The method's signature will be expanded to:
38     //  fn call_with_mut_self<'life0>(self: &'life0 mut Self) {}
39     #[rename_my_lifetimes]
40     impl T2 for S2 {
41         #[allow(clippy::needless_lifetimes)]
42         fn call_with_mut_self(self: &mut Self) {}
43     }
44 }
45
46 fn main() {}