diff options
| author | Chris Simpkins <git.simpkins@gmail.com> | 2020-05-29 16:03:46 -0400 |
|---|---|---|
| committer | Chris Simpkins <git.simpkins@gmail.com> | 2020-05-29 16:03:46 -0400 |
| commit | 27ed143ba9bb96e907f56c9f294c904a2cb26123 (patch) | |
| tree | 327245c07af5148d64002d77e934959b95215a4c /src/test/ui | |
| parent | 2873165725c15e96dae521a412065c144d9c7a25 (diff) | |
| download | rust-27ed143ba9bb96e907f56c9f294c904a2cb26123.tar.gz rust-27ed143ba9bb96e907f56c9f294c904a2cb26123.zip | |
fix diagnostics for `@ ..` binding pattern in tuples and tuple structs
fix comment add newline for tidy fmt error... edit suggestion message change the suggestion message to better handle cases with binding modes Apply suggestions from estebank code review Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> edits to address source review Apply suggestions from estebank code review #2 Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> update test files
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/issues/issue-72574-1.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-72574-1.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-72574-2.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-72574-2.stderr | 14 |
4 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-72574-1.rs b/src/test/ui/issues/issue-72574-1.rs new file mode 100644 index 00000000000..efbb0bfb150 --- /dev/null +++ b/src/test/ui/issues/issue-72574-1.rs @@ -0,0 +1,8 @@ +fn main() { + let x = (1, 2, 3); + match x { + (_a, _x @ ..) => {} + _ => {} + } +} +//~^^^^ ERROR `_x @` is not allowed in a tuple diff --git a/src/test/ui/issues/issue-72574-1.stderr b/src/test/ui/issues/issue-72574-1.stderr new file mode 100644 index 00000000000..329f7d008d4 --- /dev/null +++ b/src/test/ui/issues/issue-72574-1.stderr @@ -0,0 +1,14 @@ +error: `_x @` is not allowed in a tuple + --> $DIR/issue-72574-1.rs:4:14 + | +LL | (_a, _x @ ..) => {} + | ^^^^^^^ this is only allowed in slice patterns + | + = help: remove this and bind each tuple field independently +help: if you don't need to use the contents of _x, discard the tuple's remaining fields + | +LL | (_a, ..) => {} + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-72574-2.rs b/src/test/ui/issues/issue-72574-2.rs new file mode 100644 index 00000000000..0c8f6fcc508 --- /dev/null +++ b/src/test/ui/issues/issue-72574-2.rs @@ -0,0 +1,10 @@ +struct Binder(i32, i32, i32); + +fn main() { + let x = Binder(1, 2, 3); + match x { + Binder(_a, _x @ ..) => {} + _ => {} + } +} +//~^^^^ ERROR `_x @` is not allowed in a tuple struct diff --git a/src/test/ui/issues/issue-72574-2.stderr b/src/test/ui/issues/issue-72574-2.stderr new file mode 100644 index 00000000000..6faa57bcca6 --- /dev/null +++ b/src/test/ui/issues/issue-72574-2.stderr @@ -0,0 +1,14 @@ +error: `_x @` is not allowed in a tuple struct + --> $DIR/issue-72574-2.rs:6:20 + | +LL | Binder(_a, _x @ ..) => {} + | ^^^^^^^ this is only allowed in slice patterns + | + = help: remove this and bind each tuple field independently +help: if you don't need to use the contents of _x, discard the tuple's remaining fields + | +LL | Binder(_a, ..) => {} + | ^^ + +error: aborting due to previous error + |
