Add test for unuseful span in type error in some format_args!() invocations
This commit is contained in:
parent
c5dc558e6c
commit
0fd6f1113b
2 changed files with 80 additions and 0 deletions
31
tests/ui/errors/span-format_args-issue-140578.rs
Normal file
31
tests/ui/errors/span-format_args-issue-140578.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
fn check_format_args() {
|
||||
print!("{:?} {a} {a:?}", [], a = 1 + 1);
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn check_format_args_nl() {
|
||||
println!("{:?} {a} {a:?}", [], a = 1 + 1);
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn check_multi1() {
|
||||
println!("{:?} {:?} {a} {a:?}", [], [], a = 1 + 1);
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn check_multi2() {
|
||||
println!("{:?} {:?} {a} {a:?} {b:?}", [], [], a = 1 + 1, b = []);
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn check_unformatted() {
|
||||
println!(" //~ ERROR type annotations needed
|
||||
{:?} {:?}
|
||||
{a}
|
||||
{a:?}",
|
||||
[],
|
||||
[],
|
||||
a = 1 + 1);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
49
tests/ui/errors/span-format_args-issue-140578.stderr
Normal file
49
tests/ui/errors/span-format_args-issue-140578.stderr
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/span-format_args-issue-140578.rs:2:3
|
||||
|
|
||||
LL | print!("{:?} {a} {a:?}", [], a = 1 + 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
|
|
||||
= note: this error originates in 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
|
||||
|
|
||||
LL | println!("{:?} {a} {a:?}", [], 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)
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/span-format_args-issue-140578.rs:12:3
|
||||
|
|
||||
LL | println!("{:?} {:?} {a} {a:?}", [], [], 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)
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/span-format_args-issue-140578.rs:17:3
|
||||
|
|
||||
LL | println!("{:?} {:?} {a} {a:?} {b:?}", [], [], a = 1 + 1, b = []);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
|
|
||||
= note: this error originates in 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)
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue