mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Improve tests and exclude nested impls
This commit is contained in:
parent
7230768998
commit
351688db78
3 changed files with 24 additions and 3 deletions
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue