From 873ca5fa04b79da80ca779e0e577f06a07cea8d3 Mon Sep 17 00:00:00 2001 From: xizheyin Date: Fri, 2 May 2025 22:34:30 +0800 Subject: Just suggest positional arg and adjust issue0139104 ui test Signed-off-by: xizheyin --- .../issues/invalid-parse-format-issue-139104.rs | 17 ++-- .../invalid-parse-format-issue-139104.stderr | 96 ++++++++++++++++------ 2 files changed, 84 insertions(+), 29 deletions(-) (limited to 'tests/ui/parser') diff --git a/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs b/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs index 0809235bb6d..7644df8be49 100644 --- a/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs +++ b/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs @@ -1,8 +1,13 @@ fn main() { - println!("{foo:_1.4}", foo = 3.14); //~ ERROR invalid format string: invalid format string for argument `foo` - println!("{foo:1.4_1.4}", foo = 3.14); //~ ERROR invalid format string: invalid format string for argument `foo` - println!("xxx{0:_1.4}", 1.11); //~ ERROR invalid format string: invalid format string for argument at index `0` - println!("{foo:_1.4", foo = 3.14); //~ ERROR invalid format string: invalid format string for argument `foo` - println!("xxx{0:_1.4", 1.11); //~ ERROR invalid format string: invalid format string for argument at index `0` - println!("xxx{ 0", 1.11); //~ ERROR invalid format string: expected `}`, found `0` + println!("{foo:_1.4}", foo = 3.14); //~ ERROR invalid format string: expected `}`, found `.` + println!("{0:_1.4}", 1.11); //~ ERROR invalid format string: expected `}`, found `.` + println!("{:_1.4}", 3.14); //~ ERROR invalid format string: expected `}`, found `.` + + println!("{foo:_1.4", foo = 3.14); //~ ERROR invalid format string: expected `}`, found `.` + println!("{0:_1.4", 1.11); //~ ERROR invalid format string: expected `}`, found `.` + println!("{:_1.4", 3.14); //~ ERROR invalid format string: expected `}`, found `.` + + println!("{ 0", 1.11); //~ ERROR invalid format string: expected `}`, found `0` + println!("{foo:1.4_1.4}", foo = 3.14); //~ ERROR invalid format string: expected `}`, found `.` + println!("{0:1.4_1.4}", 3.14); //~ ERROR invalid format string: expected `}`, found `.` } diff --git a/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr b/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr index ceae8d051e5..202aa450cab 100644 --- a/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr +++ b/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr @@ -1,42 +1,92 @@ -error: invalid format string: invalid format string for argument `foo` - --> $DIR/invalid-parse-format-issue-139104.rs:2:16 +error: invalid format string: expected `}`, found `.` + --> $DIR/invalid-parse-format-issue-139104.rs:2:22 | LL | println!("{foo:_1.4}", foo = 3.14); - | ^^^ invalid format specifier for this argument 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: invalid format string for argument `foo` - --> $DIR/invalid-parse-format-issue-139104.rs:3:16 +error: invalid format string: expected `}`, found `.` + --> $DIR/invalid-parse-format-issue-139104.rs:3:20 | -LL | println!("{foo:1.4_1.4}", foo = 3.14); - | ^^^ invalid format specifier for this argument in format string +LL | println!("{0:_1.4}", 1.11); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: if you intended to print `{`, you can escape it using `{{` -error: invalid format string: invalid format string for argument at index `0` +error: invalid format string: expected `}`, found `.` --> $DIR/invalid-parse-format-issue-139104.rs:4:19 | -LL | println!("xxx{0:_1.4}", 1.11); - | ^ invalid format specifier for this argument in format string +LL | println!("{:_1.4}", 3.14); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: if you intended to print `{`, you can escape it using `{{` -error: invalid format string: invalid format string for argument `foo` - --> $DIR/invalid-parse-format-issue-139104.rs:5:16 +error: invalid format string: expected `}`, found `.` + --> $DIR/invalid-parse-format-issue-139104.rs:6:22 | LL | println!("{foo:_1.4", foo = 3.14); - | ^^^ invalid format specifier for this argument 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 `.` + --> $DIR/invalid-parse-format-issue-139104.rs:7:20 + | +LL | println!("{0:_1.4", 1.11); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: if you intended to print `{`, you can escape it using `{{` -error: invalid format string: invalid format string for argument at index `0` - --> $DIR/invalid-parse-format-issue-139104.rs:6:19 +error: invalid format string: expected `}`, found `.` + --> $DIR/invalid-parse-format-issue-139104.rs:8:19 + | +LL | println!("{:_1.4", 3.14); + | - ^ expected `}` in format string + | | + | because of this opening brace | -LL | println!("xxx{0:_1.4", 1.11); - | ^ invalid format specifier for this argument in format string + = note: if you intended to print `{`, you can escape it using `{{` error: invalid format string: expected `}`, found `0` - --> $DIR/invalid-parse-format-issue-139104.rs:7:21 + --> $DIR/invalid-parse-format-issue-139104.rs:10:18 + | +LL | println!("{ 0", 1.11); + | - ^ 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 `.` + --> $DIR/invalid-parse-format-issue-139104.rs:11:25 + | +LL | println!("{foo:1.4_1.4}", foo = 3.14); + | - ^ 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 `.` + --> $DIR/invalid-parse-format-issue-139104.rs:12:23 | -LL | println!("xxx{ 0", 1.11); - | - ^ expected `}` in format string - | | - | because of this opening brace +LL | println!("{0:1.4_1.4}", 3.14); + | - ^ expected `}` in format string + | | + | because of this opening brace | = note: if you intended to print `{`, you can escape it using `{{` -error: aborting due to 6 previous errors +error: aborting due to 9 previous errors -- cgit 1.4.1-3-g733a5