Don't trigger `Self` suggestion inside derives

This commit is contained in:
Oliver Schneider 2017-08-21 12:58:06 +02:00
parent 56068b1b67
commit 3eab44acb1
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
2 changed files with 5 additions and 28 deletions

View File

@ -1,7 +1,7 @@
use rustc::lint::{LintArray, LateLintPass, LateContext, LintPass};
use rustc::hir::*;
use rustc::hir::intravisit::{Visitor, walk_path, NestedVisitorMap};
use utils::span_lint_and_then;
use utils::{span_lint_and_then, in_macro};
use syntax::ast::NodeId;
use syntax_pos::symbol::keywords::SelfType;
@ -48,6 +48,9 @@ impl LintPass for UseSelf {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if in_macro(item.span) {
return;
}
if_let_chain!([
let ItemImpl(.., ref item_type, ref refs) = item.node,
let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node,

View File

@ -96,12 +96,6 @@ error: unnecessary structure name repetition
58 | pub fn new() -> Lt3<'static> { unimplemented!() }
| ^^^^^^^^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition
--> $DIR/methods.rs:61:10
|
61 | #[derive(Clone,Copy)]
| ^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition
--> $DIR/methods.rs:74:24
|
@ -190,18 +184,6 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo
125 | | );
| |_________________^
error: unnecessary structure name repetition
--> $DIR/methods.rs:131:16
|
131 | #[derive(Copy, Clone)]
| ^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition
--> $DIR/methods.rs:145:16
|
145 | #[derive(Copy, Clone)]
| ^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition
--> $DIR/methods.rs:151:24
|
@ -220,12 +202,6 @@ error: unnecessary structure name repetition
175 | fn skip(self, _: usize) -> IteratorFalsePositives {
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
error: unnecessary structure name repetition
--> $DIR/methods.rs:180:16
|
180 | #[derive(Copy, Clone)]
| ^^^^^ help: use the applicable keyword: `Self`
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
--> $DIR/methods.rs:194:13
|
@ -560,8 +536,6 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly
413 | res6.ok().expect("meh");
| ^^^^^^^^^^^^^^^^^^^^^^^
error: unnecessary structure name repetition
error: you should use the `starts_with` method
--> $DIR/methods.rs:425:5
|
@ -756,5 +730,5 @@ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec
|
= note: `-D iter-cloned-collect` implied by `-D warnings`
error: aborting due to 111 previous errors
error: aborting due to 106 previous errors