about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2021-03-01 13:28:36 -0500
committerJason Newcomb <jsnewcomb@pm.me>2021-03-16 12:10:40 -0400
commit4c1047167d20460dcb84e3d947787ce91d5fd0d4 (patch)
treea37040a58390c8aeed4d833ae2e742da30d488ac
parent4450c21f5125c363397d87ff74ed1a1d52a9f1a8 (diff)
downloadrust-4c1047167d20460dcb84e3d947787ce91d5fd0d4.tar.gz
rust-4c1047167d20460dcb84e3d947787ce91d5fd0d4.zip
More specific spans for `use_debug` lint
-rw-r--r--clippy_lints/src/write.rs2
-rw-r--r--tests/ui/print.stderr12
2 files changed, 7 insertions, 7 deletions
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs
index b5470c3bc70..210ddc7465f 100644
--- a/clippy_lints/src/write.rs
+++ b/clippy_lints/src/write.rs
@@ -456,7 +456,7 @@ impl Write {
 
             if !self.in_debug_impl && arg.format.ty == "?" {
                 // FIXME: modify rustc's fmt string parser to give us the current span
-                span_lint(cx, USE_DEBUG, str.span, "use of `Debug`-based formatting");
+                span_lint(cx, USE_DEBUG, span, "use of `Debug`-based formatting");
             }
 
             args.push(arg, span);
diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr
index 208d9532628..1754c418381 100644
--- a/tests/ui/print.stderr
+++ b/tests/ui/print.stderr
@@ -1,8 +1,8 @@
 error: use of `Debug`-based formatting
-  --> $DIR/print.rs:11:19
+  --> $DIR/print.rs:11:20
    |
 LL |         write!(f, "{:?}", 43.1415)
-   |                   ^^^^^^
+   |                    ^^^^
    |
    = note: `-D clippy::use-debug` implied by `-D warnings`
 
@@ -33,10 +33,10 @@ LL |     print!("Hello {:?}", "World");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of `Debug`-based formatting
-  --> $DIR/print.rs:28:12
+  --> $DIR/print.rs:28:19
    |
 LL |     print!("Hello {:?}", "World");
-   |            ^^^^^^^^^^^^
+   |                   ^^^^
 
 error: use of `print!`
   --> $DIR/print.rs:30:5
@@ -45,10 +45,10 @@ LL |     print!("Hello {:#?}", "#orld");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of `Debug`-based formatting
-  --> $DIR/print.rs:30:12
+  --> $DIR/print.rs:30:19
    |
 LL |     print!("Hello {:#?}", "#orld");
-   |            ^^^^^^^^^^^^^
+   |                   ^^^^^
 
 error: aborting due to 8 previous errors