Skip to content

Commit d18c7b2

Browse files
committed
Add test for variable width in USELESS_FORMAT
1 parent 11cc847 commit d18c7b2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

tests/ui/format.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fn main() {
1414
format!("{}", "foo");
1515
format!("{:?}", "foo"); // don't warn about debug
1616
format!("{:8}", "foo");
17+
format!("{:width$}", "foo", width = 8);
1718
format!("{:+}", "foo"); // warn when the format makes no difference
1819
format!("{:<}", "foo"); // warn when the format makes no difference
1920
format!("foo {}", "bar");
@@ -23,6 +24,7 @@ fn main() {
2324
format!("{}", arg);
2425
format!("{:?}", arg); // don't warn about debug
2526
format!("{:8}", arg);
27+
format!("{:width$}", arg, width = 8);
2628
format!("{:+}", arg); // warn when the format makes no difference
2729
format!("{:<}", arg); // warn when the format makes no difference
2830
format!("foo {}", arg);

tests/ui/format.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@ error: useless use of `format!`
1515
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1616

1717
error: useless use of `format!`
18-
--> $DIR/format.rs:17:5
18+
--> $DIR/format.rs:18:5
1919
|
20-
17 | format!("{:+}", "foo"); // warn when the format makes no difference
20+
18 | format!("{:+}", "foo"); // warn when the format makes no difference
2121
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
2222
|
2323
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2424

2525
error: useless use of `format!`
26-
--> $DIR/format.rs:18:5
26+
--> $DIR/format.rs:19:5
2727
|
28-
18 | format!("{:<}", "foo"); // warn when the format makes no difference
28+
19 | format!("{:<}", "foo"); // warn when the format makes no difference
2929
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()`
3030
|
3131
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
3232

3333
error: useless use of `format!`
34-
--> $DIR/format.rs:23:5
34+
--> $DIR/format.rs:24:5
3535
|
36-
23 | format!("{}", arg);
36+
24 | format!("{}", arg);
3737
| ^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
3838
|
3939
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
4040

4141
error: useless use of `format!`
42-
--> $DIR/format.rs:26:5
42+
--> $DIR/format.rs:28:5
4343
|
44-
26 | format!("{:+}", arg); // warn when the format makes no difference
44+
28 | format!("{:+}", arg); // warn when the format makes no difference
4545
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
4646
|
4747
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
4848

4949
error: useless use of `format!`
50-
--> $DIR/format.rs:27:5
50+
--> $DIR/format.rs:29:5
5151
|
52-
27 | format!("{:<}", arg); // warn when the format makes no difference
52+
29 | format!("{:<}", arg); // warn when the format makes no difference
5353
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `arg.to_string()`
5454
|
5555
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

0 commit comments

Comments
 (0)