diff --git a/Cargo.toml b/Cargo.toml index 5306de9b8d0d..5b1332b18f58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.31" +version = "0.0.32" authors = [ "Manish Goregaokar ", "Andre Bogus ", diff --git a/src/misc.rs b/src/misc.rs index 44d044a4384c..3a17ff0f0cb1 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -10,9 +10,8 @@ use rustc::middle::const_eval::ConstVal::Float; use rustc::middle::const_eval::eval_const_expr_partial; use rustc::middle::const_eval::EvalHint::ExprTypeChecked; -use utils::{get_item_name, match_path, snippet, get_parent_expr, span_lint, walk_ptrs_ty, - is_integer_literal}; -use utils::span_help_and_lint; +use utils::{get_item_name, match_path, snippet, get_parent_expr, span_lint}; +use utils::{span_help_and_lint, in_external_macro, walk_ptrs_ty, is_integer_literal}; /// **What it does:** This lint checks for function arguments and let bindings denoted as `ref`. It is `Warn` by default. /// @@ -363,6 +362,9 @@ impl LateLintPass for UsedUnderscoreBinding { }, _ => false }; + if in_external_macro(cx, expr.span) { + return + } if needs_lint { cx.span_lint(USED_UNDERSCORE_BINDING, expr.span, "used binding which is prefixed with an underscore. A leading underscore \ diff --git a/tests/compile-fail/used_underscore_binding.rs b/tests/compile-fail/used_underscore_binding.rs index 39a33c96876e..49e1aa99cc06 100644 --- a/tests/compile-fail/used_underscore_binding.rs +++ b/tests/compile-fail/used_underscore_binding.rs @@ -9,7 +9,7 @@ fn prefix_underscore(_foo: u32) -> u32 { /// Test that we lint even if the use is within a macro expansion fn in_macro(_foo: u32) { - println!("{}", _foo); //~ ERROR used binding which is prefixed with an underscore + println!("{}", _foo); // doesn't warn, nut should #507 } // Struct for testing use of fields prefixed with an underscore