Use correct spans for format string errors

When encountering format string errors in a raw string, or regular
string literal with embedded newlines, account for the positional
change to use correct spans.

:drive by fix: 🚗
This commit is contained in:
Esteban Küber
2018-07-19 23:14:00 -07:00
parent 154dee2dcc
commit f4306ffbfc
7 changed files with 123 additions and 21 deletions

View File

@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-tidy-tab
fn main() {
println!("{");
//~^ ERROR invalid format string: expected `'}'` but string was terminated
@@ -24,4 +26,36 @@ fn main() {
//~^ ERROR invalid format string: unmatched `}` found
let _ = format!("{\\}");
//~^ ERROR invalid format string: expected `'}'`, found `'\\'`
let _ = format!("\n\n\n{\n\n\n");
//~^ ERROR invalid format string
let _ = format!(r###"
{"###);
//~^ ERROR invalid format string
let _ = format!(r###"
{
"###);
//~^^ ERROR invalid format string
let _ = format!(r###"
}
"###);
//~^^^ ERROR invalid format string
let _ = format!(r###"
}
"###);
//~^^^ ERROR invalid format string: unmatched `}` found
}