diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-07-14 20:50:30 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@commure.com> | 2018-07-19 23:18:07 -0700 |
| commit | f53c145ef18db6543e8e5420e172e04b6054db2e (patch) | |
| tree | 9de9b0c1f029e7dfac14b0ab50181868f46bd9df /src/test/ui/fmt | |
| parent | bc14d71622378cf942a834e7c2b5358b9901f775 (diff) | |
| download | rust-f53c145ef18db6543e8e5420e172e04b6054db2e.tar.gz rust-f53c145ef18db6543e8e5420e172e04b6054db2e.zip | |
Improve suggestion for missing fmt str in println
Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal.
Diffstat (limited to 'src/test/ui/fmt')
| -rw-r--r-- | src/test/ui/fmt/format-string-error.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/fmt/format-string-error.stderr | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/test/ui/fmt/format-string-error.rs b/src/test/ui/fmt/format-string-error.rs index 5b13686240e..e48aa489f43 100644 --- a/src/test/ui/fmt/format-string-error.rs +++ b/src/test/ui/fmt/format-string-error.rs @@ -10,8 +10,10 @@ fn main() { println!("{"); + //~^ ERROR invalid format string: expected `'}'` but string was terminated println!("{{}}"); println!("}"); + //~^ ERROR invalid format string: unmatched `}` found let _ = format!("{_foo}", _foo = 6usize); //~^ ERROR invalid format string: invalid argument name `_foo` let _ = format!("{_}", _ = 6usize); diff --git a/src/test/ui/fmt/format-string-error.stderr b/src/test/ui/fmt/format-string-error.stderr index ff766ddc8fa..4c7ef11b29e 100644 --- a/src/test/ui/fmt/format-string-error.stderr +++ b/src/test/ui/fmt/format-string-error.stderr @@ -1,23 +1,21 @@ error: invalid format string: expected `'}'` but string was terminated - --> $DIR/format-string-error.rs:12:5 + --> $DIR/format-string-error.rs:12:16 | LL | println!("{"); - | ^^^^^^^^^^^^^^ expected `'}'` in format string + | ^ expected `'}'` in format string | = note: if you intended to print `{`, you can escape it using `{{` - = 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: invalid format string: unmatched `}` found - --> $DIR/format-string-error.rs:14:5 + --> $DIR/format-string-error.rs:15:15 | LL | println!("}"); - | ^^^^^^^^^^^^^^ unmatched `}` in format string + | ^ unmatched `}` in format string | = note: if you intended to print `}`, you can escape it using `}}` - = 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: invalid format string: invalid argument name `_foo` - --> $DIR/format-string-error.rs:15:23 + --> $DIR/format-string-error.rs:17:23 | LL | let _ = format!("{_foo}", _foo = 6usize); | ^^^^ invalid argument name in format string @@ -25,7 +23,7 @@ LL | let _ = format!("{_foo}", _foo = 6usize); = note: argument names cannot start with an underscore error: invalid format string: invalid argument name `_` - --> $DIR/format-string-error.rs:17:23 + --> $DIR/format-string-error.rs:19:23 | LL | let _ = format!("{_}", _ = 6usize); | ^ invalid argument name in format string @@ -33,7 +31,7 @@ LL | let _ = format!("{_}", _ = 6usize); = note: argument names cannot start with an underscore error: invalid format string: expected `'}'` but string was terminated - --> $DIR/format-string-error.rs:19:23 + --> $DIR/format-string-error.rs:21:23 | LL | let _ = format!("{"); | ^ expected `'}'` in format string @@ -41,7 +39,7 @@ LL | let _ = format!("{"); = note: if you intended to print `{`, you can escape it using `{{` error: invalid format string: unmatched `}` found - --> $DIR/format-string-error.rs:21:22 + --> $DIR/format-string-error.rs:23:22 | LL | let _ = format!("}"); | ^ unmatched `}` in format string @@ -49,7 +47,7 @@ LL | let _ = format!("}"); = note: if you intended to print `}`, you can escape it using `}}` error: invalid format string: expected `'}'`, found `'/'` - --> $DIR/format-string-error.rs:23:23 + --> $DIR/format-string-error.rs:25:23 | LL | let _ = format!("{/}"); | ^ expected `}` in format string |
