Remove 'apostrophes' from rustc_parse_format

This commit is contained in:
Lieselotte 2024-10-14 23:22:51 +02:00
parent 9322d183f4
commit dda3066805
No known key found for this signature in database
GPG Key ID: 68A9A951C7E1F283
21 changed files with 83 additions and 83 deletions

View File

@ -7,7 +7,7 @@ edition = "2021"
proc-macro = true
[dependencies]
syn = { version = "2.0.9", features = ["full"] }
syn = { version = "2.0.9", features = ["full", "extra-traits"] }
proc-macro2 = "1"
quote = "1"

View File

@ -473,19 +473,19 @@ impl<'a> Parser<'a> {
}
pos = peek_pos;
description = format!("expected `'}}'`, found `{maybe:?}`");
description = format!("expected `}}`, found `{}`", maybe.escape_debug());
} else {
description = "expected `'}'` but string was terminated".to_owned();
description = "expected `}` but string was terminated".to_owned();
// point at closing `"`
pos = self.input.len() - if self.append_newline { 1 } else { 0 };
}
let pos = self.to_span_index(pos);
let label = "expected `'}'`".to_owned();
let label = "expected `}`".to_owned();
let (note, secondary_label) = if arg.format.fill == Some('}') {
(
Some("the character `'}'` is interpreted as a fill character because of the `:` that precedes it".to_owned()),
Some("the character `}` is interpreted as a fill character because of the `:` that precedes it".to_owned()),
arg.format.fill_span.map(|sp| ("this is not interpreted as a formatting closing brace".to_owned(), sp)),
)
} else {

View File

@ -178,7 +178,7 @@ struct ErrorWithNonexistentField {
}
#[derive(Diagnostic)]
//~^ ERROR invalid format string: expected `'}'`
//~^ ERROR invalid format string: expected `}`
#[diag(no_crate_example, code = E0123)]
struct ErrorMissingClosingBrace {
#[suggestion(no_crate_suggestion, code = "{name")]

View File

@ -184,11 +184,11 @@ error: `name` doesn't refer to a field on this type
LL | #[suggestion(no_crate_suggestion, code = "{name}")]
| ^^^^^^^^
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/diagnostic-derive.rs:180:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ expected `'}'` in format string
| ^^^^^^^^^^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -19,8 +19,8 @@ trait ImportantTrait3 {}
trait ImportantTrait4 {}
#[diagnostic::on_unimplemented(message = "Test {Self:!}")]
//~^WARN expected `'}'`, found `'!'`
//~|WARN expected `'}'`, found `'!'`
//~^WARN expected `}`, found `!`
//~|WARN expected `}`, found `!`
//~|WARN unmatched `}` found
//~|WARN unmatched `}` found
trait ImportantTrait5 {}

View File

@ -30,7 +30,7 @@ LL | #[diagnostic::on_unimplemented(message = "Test {Self:123}")]
|
= help: no format specifier are supported in this position
warning: expected `'}'`, found `'!'`
warning: expected `}`, found `!`
--> $DIR/broken_format.rs:21:32
|
LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")]
@ -153,7 +153,7 @@ note: required by a bound in `check_4`
LL | fn check_4(_: impl ImportantTrait4) {}
| ^^^^^^^^^^^^^^^ required by this bound in `check_4`
warning: expected `'}'`, found `'!'`
warning: expected `}`, found `!`
--> $DIR/broken_format.rs:21:32
|
LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")]

View File

@ -4,5 +4,5 @@
fn main() {
println!("Hello, world! {0:}<3", 2);
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
}

View File

@ -1,12 +1,12 @@
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/closing-brace-as-fill.rs:6:35
|
LL | println!("Hello, world! {0:}<3", 2);
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| this is not interpreted as a formatting closing brace
|
= note: the character `'}'` is interpreted as a fill character because of the `:` that precedes it
= note: the character `}` is interpreted as a fill character because of the `:` that precedes it
error: aborting due to 1 previous error

View File

@ -72,7 +72,7 @@ raw { \n
// note: `\x7B` is `{`
println!("\x7B}\u{8} {", 1);
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
println!("\x7B}\u8 {", 1);
//~^ ERROR incorrect unicode escape sequence

View File

@ -9,138 +9,138 @@ help: format of unicode escape sequences uses braces
LL | println!("\x7B}\u{8} {", 1);
| ~~~~~
error: invalid format string: expected `'}'`, found `'a'`
error: invalid format string: expected `}`, found `a`
--> $DIR/format-string-error-2.rs:5:5
|
LL | format!("{
| - because of this opening brace
LL | a");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'b'`
error: invalid format string: expected `}`, found `b`
--> $DIR/format-string-error-2.rs:9:5
|
LL | format!("{ \
| - because of this opening brace
LL | \
LL | b");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'\'`
error: invalid format string: expected `}`, found `\`
--> $DIR/format-string-error-2.rs:11:18
|
LL | format!(r#"{ \
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'\'`
error: invalid format string: expected `}`, found `\`
--> $DIR/format-string-error-2.rs:15:18
|
LL | format!(r#"{ \n
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'e'`
error: invalid format string: expected `}`, found `e`
--> $DIR/format-string-error-2.rs:21:5
|
LL | format!("{ \n
| - because of this opening brace
LL | \n
LL | e");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'a'`
error: invalid format string: expected `}`, found `a`
--> $DIR/format-string-error-2.rs:25:5
|
LL | {
| - because of this opening brace
LL | a");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'a'`
error: invalid format string: expected `}`, found `a`
--> $DIR/format-string-error-2.rs:29:5
|
LL | {
| - because of this opening brace
LL | a
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'b'`
error: invalid format string: expected `}`, found `b`
--> $DIR/format-string-error-2.rs:35:5
|
LL | { \
| - because of this opening brace
LL | \
LL | b");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'b'`
error: invalid format string: expected `}`, found `b`
--> $DIR/format-string-error-2.rs:40:5
|
LL | { \
| - because of this opening brace
LL | \
LL | b \
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'\'`
error: invalid format string: expected `}`, found `\`
--> $DIR/format-string-error-2.rs:45:8
|
LL | raw { \
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'\'`
error: invalid format string: expected `}`, found `\`
--> $DIR/format-string-error-2.rs:50:8
|
LL | raw { \n
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'e'`
error: invalid format string: expected `}`, found `e`
--> $DIR/format-string-error-2.rs:57:5
|
LL | { \n
| - because of this opening brace
LL | \n
LL | e");
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'a'`
error: invalid format string: expected `}`, found `a`
--> $DIR/format-string-error-2.rs:67:5
|
LL | {
| - because of this opening brace
LL | asdf}
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
@ -150,11 +150,11 @@ error: 1 positional argument in format string, but no arguments were given
LL | println!("\t{}");
| ^^
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error-2.rs:74:27
|
LL | println!("\x7B}\u{8} {", 1);
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|

View File

@ -2,7 +2,7 @@
fn main() {
println!("{");
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
println!("{{}}");
println!("}");
//~^ ERROR invalid format string: unmatched `}` found
@ -13,11 +13,11 @@ fn main() {
let _ = format!("{a:._$}", a = "", _ = 0);
//~^ ERROR invalid format string: invalid argument name `_`
let _ = format!("{");
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
let _ = format!("}");
//~^ ERROR invalid format string: unmatched `}` found
let _ = format!("{\\}");
//~^ ERROR invalid format string: expected `'}'`, found `'\'`
//~^ ERROR invalid format string: expected `}`, found `\`
let _ = format!("\n\n\n{\n\n\n");
//~^ ERROR invalid format string
let _ = format!(r###"

View File

@ -1,8 +1,8 @@
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error.rs:4:16
|
LL | println!("{");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
@ -40,11 +40,11 @@ LL | let _ = format!("{a:._$}", a = "", _ = 0);
|
= note: argument name cannot be a single underscore
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error.rs:15:23
|
LL | let _ = format!("{");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
@ -58,44 +58,44 @@ LL | let _ = format!("}");
|
= note: if you intended to print `}`, you can escape it using `}}`
error: invalid format string: expected `'}'`, found `'\'`
error: invalid format string: expected `}`, found `\`
--> $DIR/format-string-error.rs:19:23
|
LL | let _ = format!("{\}");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error.rs:21:35
|
LL | let _ = format!("\n\n\n{\n\n\n");
| - ^ expected `'}'` in format string
| - ^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error.rs:27:3
|
LL | {"###);
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/format-string-error.rs:35:1
|
LL | {
| - because of this opening brace
LL |
LL | "###);
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`

View File

@ -7,9 +7,9 @@ fn main() {
format!("{?:?}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("{??}", bar);
//~^ ERROR invalid format string: expected `'}'`, found `'?'`
//~^ ERROR invalid format string: expected `}`, found `?`
format!("{?;bar}");
//~^ ERROR invalid format string: expected `'}'`, found `'?'`
//~^ ERROR invalid format string: expected `}`, found `?`
format!("{?:#?}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("Hello {<5:}!", "x");

View File

@ -22,21 +22,21 @@ LL | format!("{?:?}", bar);
|
= note: `?` comes after `:`, try `:?` instead
error: invalid format string: expected `'}'`, found `'?'`
error: invalid format string: expected `}`, found `?`
--> $DIR/format-string-wrong-order.rs:9:15
|
LL | format!("{??}", bar);
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'`, found `'?'`
error: invalid format string: expected `}`, found `?`
--> $DIR/format-string-wrong-order.rs:11:15
|
LL | format!("{?;bar}");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|

View File

@ -48,7 +48,7 @@ fn main() {
// bad syntax of the format string
format!("{"); //~ ERROR: expected `'}'` but string was terminated
format!("{"); //~ ERROR: expected `}` but string was terminated
format!("foo } bar"); //~ ERROR: unmatched `}` found
format!("foo }"); //~ ERROR: unmatched `}` found

View File

@ -136,11 +136,11 @@ LL | format!("{valuea} {valueb}", valuea=5, valuec=7);
| |
| formatting specifier missing
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/ifmt-bad-arg.rs:51:15
|
LL | format!("{");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
@ -172,13 +172,13 @@ LL | format!("foo %s baz", "bar");
|
= note: printf formatting is not supported; see the documentation for `std::fmt`
error: invalid format string: expected `'}'`, found `'t'`
error: invalid format string: expected `}`, found `t`
--> $DIR/ifmt-bad-arg.rs:75:1
|
LL | ninth number: {
| - because of this opening brace
LL | tenth number: {}",
| ^ expected `'}'` in format string
| ^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`

View File

@ -1,8 +1,8 @@
fn main() {
let _ = format!(concat!("{0}𝖳𝖾𝗌𝗍{"), i);
//~^ ERROR: invalid format string: expected `'}'` but string was terminated
//~^ ERROR: invalid format string: expected `}` but string was terminated
//~| NOTE: if you intended to print `{`, you can escape it using `{{`
//~| NOTE: in this expansion of concat!
//~| NOTE: in this expansion of concat!
//~| NOTE: expected `'}'` in format string
//~| NOTE: expected `}` in format string
}

View File

@ -1,8 +1,8 @@
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/issue-91556.rs:2:19
|
LL | let _ = format!(concat!("{0}𝖳𝖾𝗌𝗍{"), i);
| ^^^^^^^^^^^^^^^^^^^ expected `'}'` in format string
| ^^^^^^^^^^^^^^^^^^^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
= note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -4,7 +4,7 @@ extern crate format_string_proc_macro;
fn main() {
format_string_proc_macro::respan_to_invalid_format_literal!("¡");
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
format_args!(r#concat!("¡ {"));
//~^ ERROR invalid format string: expected `'}'` but string was terminated
//~^ ERROR invalid format string: expected `}` but string was terminated
}

View File

@ -1,16 +1,16 @@
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/respanned-literal-issue-106191.rs:6:65
|
LL | format_string_proc_macro::respan_to_invalid_format_literal!("¡");
| ^^^ expected `'}'` in format string
| ^^^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/respanned-literal-issue-106191.rs:8:18
|
LL | format_args!(r#concat!("¡ {"));
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `'}'` in format string
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
= note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,8 +1,8 @@
error: invalid format string: expected `'}'` but string was terminated
error: invalid format string: expected `}` but string was terminated
--> $DIR/issue-51848.rs:6:20
|
LL | println!("{");
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
...