about summary refs log tree commit diff
path: root/src/test/ui/array-slice-vec
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-02-14 23:11:03 +0000
committerbors <bors@rust-lang.org>2020-02-14 23:11:03 +0000
commitb92c6ee882853313698f1148512e8e992ba36b2d (patch)
tree8932cd3cddd9fe9a5c99eab6fae97fb7bf435e99 /src/test/ui/array-slice-vec
parent433aae93e4ef866a1fdfefad136b32ed89acd3e7 (diff)
parenta6ff1dbaa4c0ec5a75e6cfedf289ebd0bc66ae67 (diff)
downloadrust-b92c6ee882853313698f1148512e8e992ba36b2d.tar.gz
rust-b92c6ee882853313698f1148512e8e992ba36b2d.zip
Auto merge of #69172 - JohnTitor:rollup-6cbmwcw, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #68129 (Correct inference of primitive operand type behind binary operation)
 - #68475 (Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`)
 - #68856 (typeck: clarify def_bm adjustments & add tests for or-patterns)
 - #69051 (simplify_try: address some of eddyb's comments)
 - #69128 (Fix extra subslice lowering)
 - #69150 (Follow-up to #68848)
 - #69164 (Update pulldown-cmark dependency)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test/ui/array-slice-vec')
-rw-r--r--src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.rs18
-rw-r--r--src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.stderr26
2 files changed, 44 insertions, 0 deletions
diff --git a/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.rs b/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.rs
new file mode 100644
index 00000000000..061b0d675b3
--- /dev/null
+++ b/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.rs
@@ -0,0 +1,18 @@
+// We used to not lower the extra `b @ ..` into `b @ _` which meant that no type
+// was registered for the binding `b` although it passed through resolve.
+// This resulted in an ICE (#69103).
+
+fn main() {
+    let [a @ .., b @ ..] = &mut [1, 2];
+    //~^ ERROR `..` can only be used once per slice pattern
+    b;
+
+    let [.., c @ ..] = [1, 2];
+    //~^ ERROR `..` can only be used once per slice pattern
+    c;
+
+    // This never ICEd, but let's make sure it won't regress either.
+    let (.., d @ ..) = (1, 2);
+    //~^ ERROR `..` patterns are not allowed here
+    d;
+}
diff --git a/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.stderr b/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.stderr
new file mode 100644
index 00000000000..9432e2f0c9d
--- /dev/null
+++ b/src/test/ui/array-slice-vec/issue-69103-extra-binding-subslice.stderr
@@ -0,0 +1,26 @@
+error: `..` can only be used once per slice pattern
+  --> $DIR/issue-69103-extra-binding-subslice.rs:6:22
+   |
+LL |     let [a @ .., b @ ..] = &mut [1, 2];
+   |              --      ^^ can only be used once per slice pattern
+   |              |
+   |              previously used here
+
+error: `..` can only be used once per slice pattern
+  --> $DIR/issue-69103-extra-binding-subslice.rs:10:18
+   |
+LL |     let [.., c @ ..] = [1, 2];
+   |          --      ^^ can only be used once per slice pattern
+   |          |
+   |          previously used here
+
+error: `..` patterns are not allowed here
+  --> $DIR/issue-69103-extra-binding-subslice.rs:15:18
+   |
+LL |     let (.., d @ ..) = (1, 2);
+   |                  ^^
+   |
+   = note: only allowed in tuple, tuple struct, and slice patterns
+
+error: aborting due to 3 previous errors
+