about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcocodery <cocodery@outlook.com>2024-01-11 14:52:03 +0800
committercocodery <cocodery@outlook.com>2024-01-11 14:52:03 +0800
commit7c389acd277eada4d2e0856707361cce24c9b23f (patch)
tree23489b4b54a3e65e22796ac21e70c5eebc40cb66
parente89968425495ad99ce16bd00a6d7a3f63648271b (diff)
downloadrust-7c389acd277eada4d2e0856707361cce24c9b23f.tar.gz
rust-7c389acd277eada4d2e0856707361cce24c9b23f.zip
Fix error warning span for issue12045
-rw-r--r--clippy_lints/src/no_effect.rs2
-rw-r--r--tests/ui/no_effect.stderr16
2 files changed, 9 insertions, 9 deletions
diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs
index 6bbe427ea29..2a2c2b331ba 100644
--- a/clippy_lints/src/no_effect.rs
+++ b/clippy_lints/src/no_effect.rs
@@ -155,7 +155,7 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
                 cx,
                 NO_EFFECT_UNDERSCORE_BINDING,
                 init.hir_id,
-                stmt.span,
+                ident.span,
                 "binding to `_` prefixed variable with no side-effect",
             );
             return true;
diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr
index f5ba234b4cb..8140ba1feee 100644
--- a/tests/ui/no_effect.stderr
+++ b/tests/ui/no_effect.stderr
@@ -152,31 +152,31 @@ LL |     FooString { s: s };
    |     ^^^^^^^^^^^^^^^^^^^
 
 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;
-   |     ^^^^^^^^^^^^^^^^
+   |         ^^^^^^^
    |
    = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]`
 
 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");
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^
 
 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 };
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^
 
 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];
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^
 
 error: aborting due to 29 previous errors