Improve tests and exclude nested impls

This commit is contained in:
Wilco Kusee 2019-01-07 14:11:53 +01:00
parent 7230768998
commit 351688db78
No known key found for this signature in database
GPG key ID: D5B2BB5CDC3334BC
3 changed files with 24 additions and 3 deletions

View file

@ -246,7 +246,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
| ItemKind::Static(..)
| ItemKind::Enum(..)
| ItemKind::Struct(..)
| ItemKind::Union(..) => {
| ItemKind::Union(..)
| ItemKind::Impl(..) => {
// Don't check statements that shadow `Self` or where `Self` can't be used
},
_ => walk_item(self, item),

View file

@ -250,6 +250,14 @@ mod nesting {
struct Bar {
foo: Foo, // Foo != Self
}
impl Bar {
fn bar() -> Bar {
Bar {
foo: Foo{},
}
}
}
}
}
@ -258,7 +266,7 @@ mod nesting {
}
impl Enum {
fn method() {
use self::Enum::*;
use self::Enum::*; // Issue 3425
static STATIC: Enum = Enum::A; // Can't use Self as type
}
}

View file

@ -150,5 +150,17 @@ LL | Foo {}
LL | use_self_expand!(); // Should lint in local macros
| ------------------- 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