Improve tests and exclude nested impls
This commit is contained in:
parent
7230768998
commit
351688db78
@ -246,7 +246,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
|
|||||||
| ItemKind::Static(..)
|
| ItemKind::Static(..)
|
||||||
| ItemKind::Enum(..)
|
| ItemKind::Enum(..)
|
||||||
| ItemKind::Struct(..)
|
| ItemKind::Struct(..)
|
||||||
| ItemKind::Union(..) => {
|
| ItemKind::Union(..)
|
||||||
|
| ItemKind::Impl(..) => {
|
||||||
// Don't check statements that shadow `Self` or where `Self` can't be used
|
// Don't check statements that shadow `Self` or where `Self` can't be used
|
||||||
},
|
},
|
||||||
_ => walk_item(self, item),
|
_ => walk_item(self, item),
|
||||||
|
@ -250,6 +250,14 @@ mod nesting {
|
|||||||
struct Bar {
|
struct Bar {
|
||||||
foo: Foo, // Foo != Self
|
foo: Foo, // Foo != Self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Bar {
|
||||||
|
fn bar() -> Bar {
|
||||||
|
Bar {
|
||||||
|
foo: Foo{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +266,7 @@ mod nesting {
|
|||||||
}
|
}
|
||||||
impl Enum {
|
impl Enum {
|
||||||
fn method() {
|
fn method() {
|
||||||
use self::Enum::*;
|
use self::Enum::*; // Issue 3425
|
||||||
static STATIC: Enum = Enum::A; // Can't use Self as type
|
static STATIC: Enum = Enum::A; // Can't use Self as type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,5 +150,17 @@ LL | Foo {}
|
|||||||
LL | use_self_expand!(); // Should lint in local macros
|
LL | use_self_expand!(); // Should lint in local macros
|
||||||
| ------------------- in this macro invocation
|
| ------------------- in this macro invocation
|
||||||
|
|
||||||
error: aborting due to 24 previous errors
|
error: unnecessary structure name repetition
|
||||||
|
--> $DIR/use_self.rs:255:29
|
||||||
|
|
|
||||||
|
LL | fn bar() -> Bar {
|
||||||
|
| ^^^ help: use the applicable keyword: `Self`
|
||||||
|
|
||||||
|
error: unnecessary structure name repetition
|
||||||
|
--> $DIR/use_self.rs:256:21
|
||||||
|
|
|
||||||
|
LL | Bar {
|
||||||
|
| ^^^ help: use the applicable keyword: `Self`
|
||||||
|
|
||||||
|
error: aborting due to 26 previous errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user