mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Add test for and fix rust-lang/rust-clippy#9131
This lint seems to have been broken by #98446
This commit is contained in:
parent
5474f56bcf
commit
3388787615
3 changed files with 8 additions and 2 deletions
|
@ -301,7 +301,7 @@ fn in_attributes_expansion(expr: &Expr<'_>) -> bool {
|
||||||
use rustc_span::hygiene::MacroKind;
|
use rustc_span::hygiene::MacroKind;
|
||||||
if expr.span.from_expansion() {
|
if expr.span.from_expansion() {
|
||||||
let data = expr.span.ctxt().outer_expn_data();
|
let data = expr.span.ctxt().outer_expn_data();
|
||||||
matches!(data.kind, ExpnKind::Macro(MacroKind::Attr, _))
|
matches!(data.kind, ExpnKind::Macro(MacroKind::Attr|MacroKind::Derive, _))
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,12 @@ fn in_struct_field() {
|
||||||
s._underscore_field += 1;
|
s._underscore_field += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests that we do not lint if the struct field is used in code created with derive.
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct UnderscoreInStruct {
|
||||||
|
_foo: u32,
|
||||||
|
}
|
||||||
|
|
||||||
/// Tests that we do not lint if the underscore is not a prefix
|
/// Tests that we do not lint if the underscore is not a prefix
|
||||||
fn non_prefix_underscore(some_foo: u32) -> u32 {
|
fn non_prefix_underscore(some_foo: u32) -> u32 {
|
||||||
some_foo + 1
|
some_foo + 1
|
||||||
|
|
|
@ -31,7 +31,7 @@ LL | s._underscore_field += 1;
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
|
error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
|
||||||
--> $DIR/used_underscore_binding.rs:99:16
|
--> $DIR/used_underscore_binding.rs:105:16
|
||||||
|
|
|
|
||||||
LL | uses_i(_i);
|
LL | uses_i(_i);
|
||||||
| ^^
|
| ^^
|
||||||
|
|
Loading…
Reference in a new issue