diff --git a/.travis.yml b/.travis.yml index 8f9c5e8f636..13ffb09a686 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,14 +56,14 @@ matrix: if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-lang-nursery/chalk if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - # - env: INTEGRATION=rust-lang/rls - # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) + - env: INTEGRATION=rust-lang/rls + if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=Geal/nom if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-lang/rustfmt if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - # - env: INTEGRATION=hyperium/hyper - # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) + - env: INTEGRATION=hyperium/hyper + if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=bluss/rust-itertools if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=serde-rs/serde @@ -72,8 +72,8 @@ matrix: if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-random/rand if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - # - env: INTEGRATION=rust-lang-nursery/futures-rs - # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) + - env: INTEGRATION=rust-lang-nursery/futures-rs + if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=Marwes/combine if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - env: INTEGRATION=rust-lang-nursery/failure diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index b0925737702..35e154aeaee 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -10,7 +10,7 @@ use rustc_errors::Applicability; use syntax_pos::symbol::kw; -use crate::utils::span_lint_and_sugg; +use crate::utils::{differing_macro_contexts, span_lint_and_sugg}; declare_clippy_lint! { /// **What it does:** Checks for unnecessary repetition of structure name when a @@ -56,6 +56,11 @@ fn span_use_self_lint(cx: &LateContext<'_, '_>, path: &Path, last_segment: Optio // Path segments only include actual path, no methods or fields. let last_path_span = last_segment.ident.span; + + if differing_macro_contexts(path.span, last_path_span) { + return; + } + // Only take path up to the end of last_path_span. let span = path.span.with_hi(last_path_span.hi()); diff --git a/tests/ui/auxiliary/use_self_macro.rs b/tests/ui/auxiliary/use_self_macro.rs new file mode 100644 index 00000000000..a8a85b4baef --- /dev/null +++ b/tests/ui/auxiliary/use_self_macro.rs @@ -0,0 +1,15 @@ +macro_rules! use_self { + ( + impl $ty:ident { + fn func(&$this:ident) { + [fields($($field:ident)*)] + } + } + ) => ( + impl $ty { + fn func(&$this) { + let $ty { $($field),* } = $this; + } + } + ) +} diff --git a/tests/ui/ice-4671.rs b/tests/ui/ice-4671.rs new file mode 100644 index 00000000000..64e8e776941 --- /dev/null +++ b/tests/ui/ice-4671.rs @@ -0,0 +1,21 @@ +#![warn(clippy::use_self)] + +#[macro_use] +#[path = "auxiliary/use_self_macro.rs"] +mod use_self_macro; + +struct Foo { + a: u32, +} + +use_self! { + impl Foo { + fn func(&self) { + [fields( + a + )] + } + } +} + +fn main() {}