Add test for variable width in USELESS_FORMAT

This commit is contained in:
mcarton 2018-10-02 23:54:50 +02:00
parent 11cc8472a9
commit d18c7b2722
2 changed files with 17 additions and 15 deletions

View file

@ -14,6 +14,7 @@ fn main() {
format!("{}", "foo");
format!("{:?}", "foo"); // don't warn about debug
format!("{:8}", "foo");
format!("{:width$}", "foo", width = 8);
format!("{:+}", "foo"); // warn when the format makes no difference
format!("{:<}", "foo"); // warn when the format makes no difference
format!("foo {}", "bar");
@ -23,6 +24,7 @@ fn main() {
format!("{}", arg);
format!("{:?}", arg); // don't warn about debug
format!("{:8}", arg);
format!("{:width$}", arg, width = 8);
format!("{:+}", arg); // warn when the format makes no difference
format!("{:<}", arg); // warn when the format makes no difference
format!("foo {}", arg);

View file

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