diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 2a94d8fe9cc..b1e46e17f13 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -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, diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 99d4ee9d663..65975c5177c 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -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