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.
This commit is contained in:
Esteban Küber 2018-07-14 20:50:30 -07:00 committed by Esteban Küber
parent bc14d71622
commit f53c145ef1
14 changed files with 122 additions and 102 deletions

View file

@ -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);