about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorTomoaki Kobayashi <tomoaki.kobayashi.t3@alumni.tohoku.ac.jp>2025-09-18 14:42:56 +0900
committerTomoaki Kobayashi <tomoaki.kobayashi.t3@alumni.tohoku.ac.jp>2025-09-30 17:20:51 +0900
commitb13b87a1c3ee3c61b21c4273a87f0b65ccabdde8 (patch)
treedfac0b196a2dc5b5bcdacdf232a95ea91a83fb71 /tests
parent0fd6f1113b7209d24d4954ef99165aba09ed27f7 (diff)
downloadrust-b13b87a1c3ee3c61b21c4273a87f0b65ccabdde8.tar.gz
rust-b13b87a1c3ee3c61b21c4273a87f0b65ccabdde8.zip
Fix unuseful span in type error in some format_args!() invocations
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/errors/span-format_args-issue-140578.rs3
-rw-r--r--tests/ui/errors/span-format_args-issue-140578.stderr42
-rw-r--r--tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr6
3 files changed, 23 insertions, 28 deletions
diff --git a/tests/ui/errors/span-format_args-issue-140578.rs b/tests/ui/errors/span-format_args-issue-140578.rs
index d086fde09f7..8c91ded8337 100644
--- a/tests/ui/errors/span-format_args-issue-140578.rs
+++ b/tests/ui/errors/span-format_args-issue-140578.rs
@@ -19,11 +19,12 @@ fn check_multi2() {
 }
 
 fn check_unformatted() {
-  println!(" //~ ERROR type annotations needed
+  println!("
   {:?} {:?}
 {a}
 {a:?}",
         [],
+        //~^ ERROR type annotations needed
  [],
 a = 1 + 1);
 }
diff --git a/tests/ui/errors/span-format_args-issue-140578.stderr b/tests/ui/errors/span-format_args-issue-140578.stderr
index 4c19b491959..6a273e5cd51 100644
--- a/tests/ui/errors/span-format_args-issue-140578.stderr
+++ b/tests/ui/errors/span-format_args-issue-140578.stderr
@@ -1,48 +1,42 @@
 error[E0282]: type annotations needed
-  --> $DIR/span-format_args-issue-140578.rs:2:3
+  --> $DIR/span-format_args-issue-140578.rs:2:28
    |
 LL |   print!("{:?} {a} {a:?}", [], a = 1 + 1);
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |                            ^^ cannot infer type
    |
-   = note: this error originates in the macro `print` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `print` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0282]: type annotations needed
-  --> $DIR/span-format_args-issue-140578.rs:7:3
+  --> $DIR/span-format_args-issue-140578.rs:7:30
    |
 LL |   println!("{:?} {a} {a:?}", [], a = 1 + 1);
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |                              ^^ cannot infer type
    |
-   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0282]: type annotations needed
-  --> $DIR/span-format_args-issue-140578.rs:12:3
+  --> $DIR/span-format_args-issue-140578.rs:12:35
    |
 LL |   println!("{:?} {:?} {a} {a:?}", [], [], a = 1 + 1);
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |                                   ^^ cannot infer type
    |
-   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0282]: type annotations needed
-  --> $DIR/span-format_args-issue-140578.rs:17:3
+  --> $DIR/span-format_args-issue-140578.rs:17:41
    |
 LL |   println!("{:?} {:?} {a} {a:?} {b:?}", [], [], a = 1 + 1, b = []);
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |                                         ^^ cannot infer type
    |
-   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0282]: type annotations needed
-  --> $DIR/span-format_args-issue-140578.rs:22:3
-   |
-LL | /   println!("
-LL | |   {:?} {:?}
-LL | | {a}
-LL | | {a:?}",
-LL | |         [],
-LL | |  [],
-LL | | a = 1 + 1);
-   | |__________^ cannot infer type
-   |
-   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+  --> $DIR/span-format_args-issue-140578.rs:26:9
+   |
+LL |         [],
+   |         ^^ cannot infer type
+   |
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr
index a78941f9e11..3de317d2af6 100644
--- a/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr
+++ b/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.stderr
@@ -1,10 +1,10 @@
 error[E0282]: type annotations needed
-  --> $DIR/issue-107745-avoid-expr-from-macro-expansion.rs:17:5
+  --> $DIR/issue-107745-avoid-expr-from-macro-expansion.rs:17:22
    |
 LL |     println!("{:?}", []);
-   |     ^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |                      ^^ cannot infer type
    |
-   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 1 previous error