4 #![warn(clippy::use_self)]
6 #![allow(clippy::should_implement_trait)]
22 impl Default for Foo {
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 #[allow(clippy::wrong_self_convention)]
75 fn into_bytes(&self) -> Vec<u8>;
78 // This should not be linted
79 impl IntoBytes for u8 {
80 fn into_bytes(&self) -> Vec<u8> {
90 fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> {
94 fn good(foos: &[Self]) -> impl Iterator<Item = &Self> {
104 pub fn ts() -> Self {
111 macro_rules! use_self_expand {
122 use_self_expand!(); // Should lint in local macros
130 #[allow(unused_imports)]
131 use self::Foo; // Can't use Self here
133 foo: Foo, // Foo != Self
142 // Can't use Self here
161 #[allow(unused_imports)]
162 use self::Enum::*; // Issue 3425
163 static STATIC: Enum = Enum::A; // Can't use Self as type
168 let _ = Enum::C { field: true };
183 impl Trait<Vec<A>> for Vec<B> {
188 #[allow(clippy::no_effect, path_statements)]
195 const A: bool = true;
211 fn from_something() -> Self {
217 fn test() -> TestStruct;
220 impl Test for TestStruct {
221 fn test() -> TestStruct {
222 TestStruct::from_something()
227 mod paths_created_by_lowering {
240 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
246 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8];
249 impl T for Range<u8> {
250 fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {