Fix error warning span for issue12045

This commit is contained in:
cocodery 2024-01-11 14:52:03 +08:00
parent e899684254
commit 7c389acd27
2 changed files with 9 additions and 9 deletions

View file

@ -155,7 +155,7 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
cx, cx,
NO_EFFECT_UNDERSCORE_BINDING, NO_EFFECT_UNDERSCORE_BINDING,
init.hir_id, init.hir_id,
stmt.span, ident.span,
"binding to `_` prefixed variable with no side-effect", "binding to `_` prefixed variable with no side-effect",
); );
return true; return true;

View file

@ -152,31 +152,31 @@ LL | FooString { s: s };
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
error: binding to `_` prefixed variable with no side-effect error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:175:5 --> $DIR/no_effect.rs:175:9
| |
LL | let _unused = 1; LL | let _unused = 1;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^
| |
= note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]`
error: binding to `_` prefixed variable with no side-effect error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:178:5 --> $DIR/no_effect.rs:178:9
| |
LL | let _penguin = || println!("Some helpful closure"); LL | let _penguin = || println!("Some helpful closure");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^
error: binding to `_` prefixed variable with no side-effect error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:180:5 --> $DIR/no_effect.rs:180:9
| |
LL | let _duck = Struct { field: 0 }; LL | let _duck = Struct { field: 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^
error: binding to `_` prefixed variable with no side-effect error: binding to `_` prefixed variable with no side-effect
--> $DIR/no_effect.rs:182:5 --> $DIR/no_effect.rs:182:9
| |
LL | let _cat = [2, 4, 6, 8][2]; LL | let _cat = [2, 4, 6, 8][2];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^
error: aborting due to 29 previous errors error: aborting due to 29 previous errors