4 #![warn(clippy::use_self)]
6 #![allow(clippy::should_implement_trait)]
22 impl Default for Foo {
23 fn default() -> Self {
41 impl Default for Foo {
42 fn default() -> Self {
54 // Cannot use `Self` as return type, because the function is actually `fn foo<'b>(s: &'b str) ->
56 fn foo(s: &str) -> Foo {
59 // cannot replace with `Self`, because that's `Foo<'a>`
60 fn bar() -> Foo<'static> {
61 Foo { foo_str: "foo" }
64 // FIXME: the lint does not handle lifetimed struct
65 // `Self` should be applicable here
66 fn clone(&self) -> Foo<'a> {
67 Foo { foo_str: self.foo_str }
74 fn into_bytes(&self) -> Vec<u8>;
77 // This should not be linted
78 impl IntoBytes for u8 {
79 fn into_bytes(&self) -> Vec<u8> {
89 fn bad(foos: &[Self]) -> impl Iterator<Item = &Self> {
93 fn good(foos: &[Self]) -> impl Iterator<Item = &Self> {
103 pub fn ts() -> Self {
110 macro_rules! use_self_expand {
121 use_self_expand!(); // Should lint in local macros
129 #[allow(unused_imports)]
130 use self::Foo; // Can't use Self here
132 foo: Foo, // Foo != Self
141 // Can't use Self here
160 #[allow(unused_imports)]
161 use self::Enum::*; // Issue 3425
162 static STATIC: Enum = Enum::A; // Can't use Self as type
167 let _ = Self::C { field: true };
182 impl Trait<Vec<A>> for Vec<B> {
187 #[allow(clippy::no_effect, path_statements)]
194 const A: bool = true;
210 fn from_something() -> Self {
216 fn test() -> TestStruct;
219 impl Test for TestStruct {
220 fn test() -> TestStruct {
221 Self::from_something()
226 mod paths_created_by_lowering {
235 async fn g() -> Self {
239 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
245 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8];
248 impl T for Range<u8> {
249 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {