Skip to content

Commit 4a32445

Browse files
committed
Add macro check to used_underscore
1 parent a65a777 commit 4a32445

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.31"
3+
version = "0.0.32"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/misc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ use rustc::middle::const_eval::ConstVal::Float;
1010
use rustc::middle::const_eval::eval_const_expr_partial;
1111
use rustc::middle::const_eval::EvalHint::ExprTypeChecked;
1212

13-
use utils::{get_item_name, match_path, snippet, get_parent_expr, span_lint, walk_ptrs_ty,
14-
is_integer_literal};
15-
use utils::span_help_and_lint;
13+
use utils::{get_item_name, match_path, snippet, get_parent_expr, span_lint};
14+
use utils::{span_help_and_lint, in_external_macro, walk_ptrs_ty, is_integer_literal};
1615

1716
/// **What it does:** This lint checks for function arguments and let bindings denoted as `ref`. It is `Warn` by default.
1817
///
@@ -363,6 +362,9 @@ impl LateLintPass for UsedUnderscoreBinding {
363362
},
364363
_ => false
365364
};
365+
if in_external_macro(cx, expr.span) {
366+
return
367+
}
366368
if needs_lint {
367369
cx.span_lint(USED_UNDERSCORE_BINDING, expr.span,
368370
"used binding which is prefixed with an underscore. A leading underscore \

tests/compile-fail/used_underscore_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn prefix_underscore(_foo: u32) -> u32 {
99

1010
/// Test that we lint even if the use is within a macro expansion
1111
fn in_macro(_foo: u32) {
12-
println!("{}", _foo); //~ ERROR used binding which is prefixed with an underscore
12+
println!("{}", _foo); // doesn't warn, nut should #507
1313
}
1414

1515
// Struct for testing use of fields prefixed with an underscore

0 commit comments

Comments
 (0)