]> git.lizzy.rs Git - rust.git/commitdiff
Don't trigger `Self` suggestion inside derives
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 21 Aug 2017 10:58:06 +0000 (12:58 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 21 Aug 2017 10:58:06 +0000 (12:58 +0200)
clippy_lints/src/use_self.rs
tests/ui/methods.stderr

index 2a94d8fe9cc5104602ff83603c88fc971eff30c9..b1e46e17f13e7bb7f2ae3ed2cc986e490a51661a 100644 (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 @@ fn get_lints(&self) -> LintArray {
 
 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,
index 99d4ee9d6634c257ff8e414fdaff0ede38acfce8..65975c5177c47a088ae390c005603fb1635541ba 100644 (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