about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2021-04-04 19:40:40 -0700
committerJubilee Young <workingjubilee@gmail.com>2021-06-03 20:49:27 -0700
commita3bb9fb8c50b69acf2c8326519a6642e195066a5 (patch)
tree137079bed1f66f3e3479c8639ee73b92c364509e /src
parent91bc117e53bc97cdc60192d16a9ade253d87deb6 (diff)
downloadrust-a3bb9fb8c50b69acf2c8326519a6642e195066a5.tar.gz
rust-a3bb9fb8c50b69acf2c8326519a6642e195066a5.zip
Add & bless tests
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs8
-rw-r--r--src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr33
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions0.rs32
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions1.rs29
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions1.stderr36
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions2.rs21
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions2.stderr17
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions3.rs24
-rw-r--r--src/test/ui/half-open-range-patterns/range_pat_interactions3.stderr57
9 files changed, 221 insertions, 36 deletions
diff --git a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs
index 1733012b9c5..9281dda678d 100644
--- a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs
+++ b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs
@@ -11,12 +11,8 @@ fn foo() {
     //~| ERROR range-to patterns with `...` are not allowed
     if let ..5 = 0 {}
     //~^ ERROR half-open range patterns are unstable
-    if let 5.. = 0 {}
-    //~^ ERROR half-open range patterns are unstable
     if let 5..= = 0 {}
-    //~^ ERROR half-open range patterns are unstable
-    //~| ERROR inclusive range with no end
+    //~^ ERROR inclusive range with no end
     if let 5... = 0 {}
-    //~^ ERROR half-open range patterns are unstable
-    //~| ERROR inclusive range with no end
+    //~^ ERROR inclusive range with no end
 }
diff --git a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr
index 62d54463a43..a04883ae147 100644
--- a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr
+++ b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr
@@ -5,7 +5,7 @@ LL |     if let ...5 = 0 {}
    |            ^^^ help: use `..=` instead
 
 error[E0586]: inclusive range with no end
-  --> $DIR/feature-gate-half-open-range-patterns.rs:16:13
+  --> $DIR/feature-gate-half-open-range-patterns.rs:14:13
    |
 LL |     if let 5..= = 0 {}
    |             ^^^ help: use `..` instead
@@ -13,7 +13,7 @@ LL |     if let 5..= = 0 {}
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
 
 error[E0586]: inclusive range with no end
-  --> $DIR/feature-gate-half-open-range-patterns.rs:19:13
+  --> $DIR/feature-gate-half-open-range-patterns.rs:16:13
    |
 LL |     if let 5... = 0 {}
    |             ^^^ help: use `..` instead
@@ -47,34 +47,7 @@ LL |     if let ..5 = 0 {}
    = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
    = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
 
-error[E0658]: half-open range patterns are unstable
-  --> $DIR/feature-gate-half-open-range-patterns.rs:14:12
-   |
-LL |     if let 5.. = 0 {}
-   |            ^^^
-   |
-   = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
-   = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
-
-error[E0658]: half-open range patterns are unstable
-  --> $DIR/feature-gate-half-open-range-patterns.rs:16:12
-   |
-LL |     if let 5..= = 0 {}
-   |            ^^^^
-   |
-   = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
-   = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
-
-error[E0658]: half-open range patterns are unstable
-  --> $DIR/feature-gate-half-open-range-patterns.rs:19:12
-   |
-LL |     if let 5... = 0 {}
-   |            ^^^^
-   |
-   = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
-   = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
-
-error: aborting due to 9 previous errors
+error: aborting due to 6 previous errors
 
 Some errors have detailed explanations: E0586, E0658.
 For more information about an error, try `rustc --explain E0586`.
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions0.rs b/src/test/ui/half-open-range-patterns/range_pat_interactions0.rs
new file mode 100644
index 00000000000..4f478a69881
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions0.rs
@@ -0,0 +1,32 @@
+// run-pass
+#![allow(incomplete_features)]
+#![feature(exclusive_range_pattern)]
+#![feature(half_open_range_patterns)]
+#![feature(inline_const)]
+
+fn main() {
+    let mut if_lettable = vec![];
+    let mut first_or = vec![];
+    let mut or_two = vec![];
+    let mut range_from = vec![];
+    let mut bottom = vec![];
+
+    for x in -9 + 1..=(9 - 2) {
+        if let -1..=0 | 2..3 | 4 = x {
+            if_lettable.push(x)
+        }
+        match x {
+            1 | -3..0 => first_or.push(x),
+            y @ (0..5 | 6) => or_two.push(y),
+            y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+            y @ -5.. => range_from.push(y),
+            y @ ..-7 => assert_eq!(y, -8),
+            y => bottom.push(y),
+        }
+    }
+    assert_eq!(if_lettable, [-1, 0, 2, 4]);
+    assert_eq!(first_or, [-3, -2, -1, 1]);
+    assert_eq!(or_two, [0, 2, 3, 4, 6]);
+    assert_eq!(range_from, [-5, -4, 7]);
+    assert_eq!(bottom, [-7, -6]);
+}
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions1.rs b/src/test/ui/half-open-range-patterns/range_pat_interactions1.rs
new file mode 100644
index 00000000000..55353999b67
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions1.rs
@@ -0,0 +1,29 @@
+fn main() {
+    let mut if_lettable = Vec::<i32>::new();
+    let mut first_or = Vec::<i32>::new();
+    let mut or_two = Vec::<i32>::new();
+    let mut range_from = Vec::<i32>::new();
+    let mut bottom = Vec::<i32>::new();
+    let mut errors_only = Vec::<i32>::new();
+
+    for x in -9 + 1..=(9 - 2) {
+        if let n @ 2..3|4 = x {
+            //~^ error: variable `n` is not bound in all patterns
+            //~| exclusive range pattern syntax is experimental
+            errors_only.push(x);
+        } else if let 2..3 | 4 = x {
+            //~^ exclusive range pattern syntax is experimental
+            if_lettable.push(x);
+        }
+        match x as i32 {
+            0..5+1 => errors_only.push(x),
+            //~^ error: expected one of `=>`, `if`, or `|`, found `+`
+            1 | -3..0 => first_or.push(x),
+            y @ (0..5 | 6) => or_two.push(y),
+            y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+            y @ -5.. => range_from.push(y),
+            y @ ..-7 => assert_eq!(y, -8),
+            y => bottom.push(y),
+        }
+    }
+}
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions1.stderr b/src/test/ui/half-open-range-patterns/range_pat_interactions1.stderr
new file mode 100644
index 00000000000..19ebcaf0f36
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions1.stderr
@@ -0,0 +1,36 @@
+error: expected one of `=>`, `if`, or `|`, found `+`
+  --> $DIR/range_pat_interactions1.rs:19:17
+   |
+LL |             0..5+1 => errors_only.push(x),
+   |                 ^ expected one of `=>`, `if`, or `|`
+
+error[E0408]: variable `n` is not bound in all patterns
+  --> $DIR/range_pat_interactions1.rs:10:25
+   |
+LL |         if let n @ 2..3|4 = x {
+   |                -        ^ pattern doesn't bind `n`
+   |                |
+   |                variable not in all patterns
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions1.rs:10:20
+   |
+LL |         if let n @ 2..3|4 = x {
+   |                    ^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions1.rs:14:23
+   |
+LL |         } else if let 2..3 | 4 = x {
+   |                       ^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0408, E0658.
+For more information about an error, try `rustc --explain E0408`.
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions2.rs b/src/test/ui/half-open-range-patterns/range_pat_interactions2.rs
new file mode 100644
index 00000000000..4615ebd688a
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions2.rs
@@ -0,0 +1,21 @@
+fn main() {
+    let mut first_or = Vec::<i32>::new();
+    let mut or_two = Vec::<i32>::new();
+    let mut range_from = Vec::<i32>::new();
+    let mut bottom = Vec::<i32>::new();
+    let mut errors_only = Vec::<i32>::new();
+
+    for x in -9 + 1..=(9 - 2) {
+        match x as i32 {
+            0..=(5+1) => errors_only.push(x),
+            //~^ error: inclusive range with no end
+            //~| error: expected one of `=>`, `if`, or `|`, found `(`
+            1 | -3..0 => first_or.push(x),
+            y @ (0..5 | 6) => or_two.push(y),
+            y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+            y @ -5.. => range_from.push(y),
+            y @ ..-7 => assert_eq!(y, -8),
+            y => bottom.push(y),
+        }
+    }
+}
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions2.stderr b/src/test/ui/half-open-range-patterns/range_pat_interactions2.stderr
new file mode 100644
index 00000000000..13a5542a474
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions2.stderr
@@ -0,0 +1,17 @@
+error[E0586]: inclusive range with no end
+  --> $DIR/range_pat_interactions2.rs:10:14
+   |
+LL |             0..=(5+1) => errors_only.push(x),
+   |              ^^^ help: use `..` instead
+   |
+   = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
+
+error: expected one of `=>`, `if`, or `|`, found `(`
+  --> $DIR/range_pat_interactions2.rs:10:17
+   |
+LL |             0..=(5+1) => errors_only.push(x),
+   |                 ^ expected one of `=>`, `if`, or `|`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0586`.
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions3.rs b/src/test/ui/half-open-range-patterns/range_pat_interactions3.rs
new file mode 100644
index 00000000000..0afb5126059
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions3.rs
@@ -0,0 +1,24 @@
+fn main() {
+    let mut first_or = Vec::<i32>::new();
+    let mut or_two = Vec::<i32>::new();
+    let mut range_from = Vec::<i32>::new();
+    let mut bottom = Vec::<i32>::new();
+
+    for x in -9 + 1..=(9 - 2) {
+        match x as i32 {
+            8.. => bottom.push(x),
+            1 | -3..0 => first_or.push(x),
+            //~^ exclusive range pattern syntax is experimental
+            y @ (0..5 | 6) => or_two.push(y),
+            //~^ exclusive range pattern syntax is experimental
+            y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+            //~^ inline-const is experimental
+            //~| exclusive range pattern syntax is experimental
+            y @ -5.. => range_from.push(y),
+            y @ ..-7 => assert_eq!(y, -8),
+            //~^ half-open range patterns are unstable
+            //~| exclusive range pattern syntax is experimental
+            y => bottom.push(y),
+        }
+    }
+}
diff --git a/src/test/ui/half-open-range-patterns/range_pat_interactions3.stderr b/src/test/ui/half-open-range-patterns/range_pat_interactions3.stderr
new file mode 100644
index 00000000000..8278e7cc6cf
--- /dev/null
+++ b/src/test/ui/half-open-range-patterns/range_pat_interactions3.stderr
@@ -0,0 +1,57 @@
+error[E0658]: half-open range patterns are unstable
+  --> $DIR/range_pat_interactions3.rs:18:17
+   |
+LL |             y @ ..-7 => assert_eq!(y, -8),
+   |                 ^^^^
+   |
+   = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
+   = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
+
+error[E0658]: inline-const is experimental
+  --> $DIR/range_pat_interactions3.rs:14:20
+   |
+LL |             y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+   |                    ^^^^^
+   |
+   = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
+   = help: add `#![feature(inline_const)]` to the crate attributes to enable
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions3.rs:10:17
+   |
+LL |             1 | -3..0 => first_or.push(x),
+   |                 ^^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions3.rs:12:18
+   |
+LL |             y @ (0..5 | 6) => or_two.push(y),
+   |                  ^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions3.rs:14:17
+   |
+LL |             y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
+   |                 ^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error[E0658]: exclusive range pattern syntax is experimental
+  --> $DIR/range_pat_interactions3.rs:18:17
+   |
+LL |             y @ ..-7 => assert_eq!(y, -8),
+   |                 ^^^^
+   |
+   = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
+   = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0658`.