Skip to content

Commit

Permalink
Add test for variable width in USELESS_FORMAT
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarton committed Oct 2, 2018
1 parent 11cc847 commit d18c7b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions tests/ui/format.rs
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/format.stderr
Expand Up @@ -15,41 +15,41 @@ 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
--> $DIR/format.rs:18:5
|
17 | 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:18:5
--> $DIR/format.rs:19:5
|
18 | format!("{:<}", "foo"); // warn when the format makes no difference
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:23:5
--> $DIR/format.rs:24:5
|
23 | format!("{}", arg);
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)
Expand Down

0 comments on commit d18c7b2

Please sign in to comment.