Fix index of the remaining positional arguments

This commit is contained in:
koka 2023-09-28 17:12:00 +09:00
parent 124f1b0659
commit b413bf6c4e
No known key found for this signature in database
GPG key ID: A5917A40697774CD
9 changed files with 164 additions and 205 deletions

View file

@ -39,18 +39,14 @@ fn main() {
// throw a warning
println!("hello world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
println!("world hello");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// named args shouldn't change anything either
println!("hello world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
println!("world hello");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// The string literal from `file!()` has a callsite span that isn't marked as coming from an
// expansion

View file

@ -39,18 +39,14 @@ fn main() {
// throw a warning
println!("{0} {1}", "hello", "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
println!("{1} {0}", "hello", "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// named args shouldn't change anything either
println!("{foo} {bar}", foo = "hello", bar = "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
println!("{bar} {foo}", foo = "hello", bar = "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// The string literal from `file!()` has a callsite span that isn't marked as coming from an
// expansion

View file

@ -52,97 +52,49 @@ error: literal with an empty format string
--> $DIR/print_literal.rs:40:25
|
LL | println!("{0} {1}", "hello", "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^
|
help: try
|
LL - println!("{0} {1}", "hello", "world");
LL + println!("hello {1}", "world");
LL + println!("hello world");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:40:34
|
LL | println!("{0} {1}", "hello", "world");
| ^^^^^^^
|
help: try
|
LL - println!("{0} {1}", "hello", "world");
LL + println!("{0} world", "hello");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:43:34
--> $DIR/print_literal.rs:42:25
|
LL | println!("{1} {0}", "hello", "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^
|
help: try
|
LL - println!("{1} {0}", "hello", "world");
LL + println!("world {0}", "hello");
LL + println!("world hello");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:43:25
--> $DIR/print_literal.rs:46:35
|
LL | println!("{1} {0}", "hello", "world");
| ^^^^^^^
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - println!("{1} {0}", "hello", "world");
LL + println!("{1} hello", "world");
LL - println!("{foo} {bar}", foo = "hello", bar = "world");
LL + println!("hello world");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:48:35
|
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^
|
help: try
|
LL - println!("{foo} {bar}", foo = "hello", bar = "world");
LL + println!("hello {bar}", bar = "world");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:48:50
|
LL | println!("{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^
|
help: try
|
LL - println!("{foo} {bar}", foo = "hello", bar = "world");
LL + println!("{foo} world", foo = "hello");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:51:50
|
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - println!("{bar} {foo}", foo = "hello", bar = "world");
LL + println!("world {foo}", foo = "hello");
LL + println!("world hello");
|
error: literal with an empty format string
--> $DIR/print_literal.rs:51:35
|
LL | println!("{bar} {foo}", foo = "hello", bar = "world");
| ^^^^^^^
|
help: try
|
LL - println!("{bar} {foo}", foo = "hello", bar = "world");
LL + println!("{bar} hello", bar = "world");
|
error: aborting due to 12 previous errors
error: aborting due to 8 previous errors

View file

@ -43,16 +43,22 @@ fn main() {
// throw a warning
writeln!(v, "hello world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
writeln!(v, "world hello");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// named args shouldn't change anything either
writeln!(v, "hello world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
writeln!(v, "world hello");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// #10128
writeln!(v, "hello {0} world", 2);
//~^ ERROR: literal with an empty format string
writeln!(v, "world {0} hello", 2);
//~^ ERROR: literal with an empty format string
writeln!(v, "hello {0} {1}, {bar}", 2, 3, bar = 4);
//~^ ERROR: literal with an empty format string
writeln!(v, "hello {0} {1}, world {2}", 2, 3, 4);
//~^ ERROR: literal with an empty format string
}

View file

@ -43,16 +43,22 @@ fn main() {
// throw a warning
writeln!(v, "{0} {1}", "hello", "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
writeln!(v, "{1} {0}", "hello", "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// named args shouldn't change anything either
writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// #10128
writeln!(v, "{0} {1} {2}", "hello", 2, "world");
//~^ ERROR: literal with an empty format string
writeln!(v, "{2} {1} {0}", "hello", 2, "world");
//~^ ERROR: literal with an empty format string
writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4);
//~^ ERROR: literal with an empty format string
writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4);
//~^ ERROR: literal with an empty format string
}

View file

@ -52,96 +52,96 @@ error: literal with an empty format string
--> $DIR/write_literal.rs:44:28
|
LL | writeln!(v, "{0} {1}", "hello", "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{0} {1}", "hello", "world");
LL + writeln!(v, "hello {1}", "world");
LL + writeln!(v, "hello world");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:44:37
|
LL | writeln!(v, "{0} {1}", "hello", "world");
| ^^^^^^^
|
help: try
|
LL - writeln!(v, "{0} {1}", "hello", "world");
LL + writeln!(v, "{0} world", "hello");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:47:37
--> $DIR/write_literal.rs:46:28
|
LL | writeln!(v, "{1} {0}", "hello", "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{1} {0}", "hello", "world");
LL + writeln!(v, "world {0}", "hello");
LL + writeln!(v, "world hello");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:47:28
--> $DIR/write_literal.rs:50:38
|
LL | writeln!(v, "{1} {0}", "hello", "world");
| ^^^^^^^
LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{1} {0}", "hello", "world");
LL + writeln!(v, "{1} hello", "world");
LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
LL + writeln!(v, "hello world");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:52:38
|
LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^
|
help: try
|
LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
LL + writeln!(v, "hello {bar}", bar = "world");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:52:53
|
LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
| ^^^^^^^
|
help: try
|
LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world");
LL + writeln!(v, "{foo} world", foo = "hello");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:55:53
|
LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
LL + writeln!(v, "world {foo}", foo = "hello");
LL + writeln!(v, "world hello");
|
error: literal with an empty format string
--> $DIR/write_literal.rs:55:38
--> $DIR/write_literal.rs:56:32
|
LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
| ^^^^^^^
LL | writeln!(v, "{0} {1} {2}", "hello", 2, "world");
| ^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world");
LL + writeln!(v, "{bar} hello", bar = "world");
LL - writeln!(v, "{0} {1} {2}", "hello", 2, "world");
LL + writeln!(v, "hello {0} world", 2);
|
error: literal with an empty format string
--> $DIR/write_literal.rs:58:32
|
LL | writeln!(v, "{2} {1} {0}", "hello", 2, "world");
| ^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{2} {1} {0}", "hello", 2, "world");
LL + writeln!(v, "world {0} hello", 2);
|
error: literal with an empty format string
--> $DIR/write_literal.rs:60:39
|
LL | writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4);
| ^^^^^^^
|
help: try
|
LL - writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4);
LL + writeln!(v, "hello {0} {1}, {bar}", 2, 3, bar = 4);
|
error: literal with an empty format string
--> $DIR/write_literal.rs:62:41
|
LL | writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4);
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4);
LL + writeln!(v, "hello {0} {1}, world {2}", 2, 3, 4);
|
error: aborting due to 12 previous errors

View file

@ -31,10 +31,7 @@ fn main() {
v,
"some {}\
{} \\ {}",
"1",
"2",
"3",
//~^ ERROR: literal with an empty format string
"1", "2", "3",
);
writeln!(v, "{}", "\\");
//~^ ERROR: literal with an empty format string
@ -49,7 +46,6 @@ fn main() {
// hard mode
writeln!(v, r#"{}{}"#, '#', '"');
//~^ ERROR: literal with an empty format string
//~| ERROR: literal with an empty format string
// should not lint
writeln!(v, r"{}", "\r");
}

View file

@ -82,42 +82,17 @@ LL ~ world!",
error: literal with an empty format string
--> $DIR/write_literal_2.rs:34:9
|
LL | "1",
| ^^^
LL | "1", "2", "3",
| ^^^^^^^^^^^^^
|
help: try
|
LL ~ "some 1\
LL ~ {} \\ {}",
LL ~ 2 \\ 3",
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:35:9
|
LL | "2",
| ^^^
|
help: try
|
LL ~ 2 \\ {}",
LL ~ "1",
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:36:9
|
LL | "3",
| ^^^
|
help: try
|
LL ~ {} \\ 3",
LL | "1",
LL ~ "2",
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:39:23
--> $DIR/write_literal_2.rs:36:23
|
LL | writeln!(v, "{}", "\\");
| ^^^^
@ -129,7 +104,7 @@ LL + writeln!(v, "\\");
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:41:24
--> $DIR/write_literal_2.rs:38:24
|
LL | writeln!(v, r"{}", "\\");
| ^^^^
@ -141,7 +116,7 @@ LL + writeln!(v, r"\");
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:43:26
--> $DIR/write_literal_2.rs:40:26
|
LL | writeln!(v, r#"{}"#, "\\");
| ^^^^
@ -153,7 +128,7 @@ LL + writeln!(v, r#"\"#);
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:45:23
--> $DIR/write_literal_2.rs:42:23
|
LL | writeln!(v, "{}", r"\");
| ^^^^
@ -165,7 +140,7 @@ LL + writeln!(v, "\\");
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:47:23
--> $DIR/write_literal_2.rs:44:23
|
LL | writeln!(v, "{}", "\r");
| ^^^^
@ -177,16 +152,10 @@ LL + writeln!(v, "\r");
|
error: literal with an empty format string
--> $DIR/write_literal_2.rs:50:28
--> $DIR/write_literal_2.rs:47:28
|
LL | writeln!(v, r#"{}{}"#, '#', '"');
| ^^^
| ^^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal_2.rs:50:33
|
LL | writeln!(v, r#"{}{}"#, '#', '"');
| ^^^
error: aborting due to 17 previous errors
error: aborting due to 14 previous errors