diff options
| author | francorbacho <francorbacho@proton.me> | 2023-10-05 15:46:34 +0200 |
|---|---|---|
| committer | francorbacho <francorbacho@proton.me> | 2023-10-05 16:11:31 +0200 |
| commit | c8ee7db6ea272b42e90602007807be6c2191f96b (patch) | |
| tree | bae892a09b1ed076fe05a28a80bcfb93e34b6701 /tests/ui | |
| parent | 38b01828328014708feb48f9cdc065460e651098 (diff) | |
| download | rust-c8ee7db6ea272b42e90602007807be6c2191f96b.tar.gz rust-c8ee7db6ea272b42e90602007807be6c2191f96b.zip | |
Only give autofix suggestion when no named args are present
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/did_you_mean/issue-105225-named-args.rs | 10 | ||||
| -rw-r--r-- | tests/ui/did_you_mean/issue-105225-named-args.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/did_you_mean/issue-105225.fixed | 4 | ||||
| -rw-r--r-- | tests/ui/did_you_mean/issue-105225.rs | 4 |
4 files changed, 36 insertions, 4 deletions
diff --git a/tests/ui/did_you_mean/issue-105225-named-args.rs b/tests/ui/did_you_mean/issue-105225-named-args.rs new file mode 100644 index 00000000000..38e81776576 --- /dev/null +++ b/tests/ui/did_you_mean/issue-105225-named-args.rs @@ -0,0 +1,10 @@ +fn main() { + let x = "x"; + let y = "y"; + + println!("{x}", x, x = y); + //~^ ERROR: redundant argument + + println!("{x}", x = y, x = y); + //~^ ERROR: duplicate argument named `x` +} diff --git a/tests/ui/did_you_mean/issue-105225-named-args.stderr b/tests/ui/did_you_mean/issue-105225-named-args.stderr new file mode 100644 index 00000000000..72204102ef6 --- /dev/null +++ b/tests/ui/did_you_mean/issue-105225-named-args.stderr @@ -0,0 +1,22 @@ +error: redundant argument + --> $DIR/issue-105225-named-args.rs:5:21 + | +LL | println!("{x}", x, x = y); + | ^ + | +note: the formatting specifier is referencing the binding already + --> $DIR/issue-105225-named-args.rs:5:16 + | +LL | println!("{x}", x, x = y); + | ^ + +error: duplicate argument named `x` + --> $DIR/issue-105225-named-args.rs:8:28 + | +LL | println!("{x}", x = y, x = y); + | - ^ duplicate argument + | | + | previously here + +error: aborting due to 2 previous errors + diff --git a/tests/ui/did_you_mean/issue-105225.fixed b/tests/ui/did_you_mean/issue-105225.fixed index 30c99221912..f756be615a1 100644 --- a/tests/ui/did_you_mean/issue-105225.fixed +++ b/tests/ui/did_you_mean/issue-105225.fixed @@ -1,8 +1,8 @@ // run-rustfix fn main() { - let x = 0; - let y = 0; + let x = "x"; + let y = "y"; println!("{x}", ); //~^ ERROR: redundant argument diff --git a/tests/ui/did_you_mean/issue-105225.rs b/tests/ui/did_you_mean/issue-105225.rs index a69c90a6490..91cdf0eb28f 100644 --- a/tests/ui/did_you_mean/issue-105225.rs +++ b/tests/ui/did_you_mean/issue-105225.rs @@ -1,8 +1,8 @@ // run-rustfix fn main() { - let x = 0; - let y = 0; + let x = "x"; + let y = "y"; println!("{x}", x); //~^ ERROR: redundant argument |
