summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-08-01 16:00:26 +0200
committerGitHub <noreply@github.com>2019-08-01 16:00:26 +0200
commit810ffe2ba07320cac7b89af0c2a68048bfb779c9 (patch)
tree41f7ef742d5d0a7cb4bbed18d3b566c7ee497981 /src/test/ui/parser
parente2934bab3ea0e1cdcd15e215629ba0ea17507449 (diff)
parent6551285ccaf1562eb73ca1013730165b4d415d8e (diff)
downloadrust-810ffe2ba07320cac7b89af0c2a68048bfb779c9.tar.gz
rust-810ffe2ba07320cac7b89af0c2a68048bfb779c9.zip
Rollup merge of #63122 - Centril:fix-63115, r=petrochenkov
Account for `maybe_whole_expr` in range patterns

Fixes https://github.com/rust-lang/rust/issues/63115 (fallout from https://github.com/rust-lang/rust/pull/62550).

r? @petrochenkov
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-63115-range-pat-interpolated.rs16
-rw-r--r--src/test/ui/parser/recover-range-pats.rs28
-rw-r--r--src/test/ui/parser/recover-range-pats.stderr83
3 files changed, 126 insertions, 1 deletions
diff --git a/src/test/ui/parser/issue-63115-range-pat-interpolated.rs b/src/test/ui/parser/issue-63115-range-pat-interpolated.rs
new file mode 100644
index 00000000000..a7d10ca9320
--- /dev/null
+++ b/src/test/ui/parser/issue-63115-range-pat-interpolated.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(exclusive_range_pattern)]
+
+#![allow(ellipsis_inclusive_range_patterns)]
+
+fn main() {
+    macro_rules! mac_expr {
+        ($e:expr) => {
+            if let 2...$e = 3 {}
+            if let 2..=$e = 3 {}
+            if let 2..$e = 3 {}
+        }
+    }
+    mac_expr!(4);
+}
diff --git a/src/test/ui/parser/recover-range-pats.rs b/src/test/ui/parser/recover-range-pats.rs
index c66652ff4fa..260e1083159 100644
--- a/src/test/ui/parser/recover-range-pats.rs
+++ b/src/test/ui/parser/recover-range-pats.rs
@@ -121,3 +121,31 @@ fn inclusive2_to() {
     //~| ERROR `...` range patterns are deprecated
     //~| ERROR mismatched types
 }
+
+fn with_macro_expr_var() {
+    macro_rules! mac2 {
+        ($e1:expr, $e2:expr) => {
+            let $e1..$e2;
+            let $e1...$e2;
+            //~^ ERROR `...` range patterns are deprecated
+            let $e1..=$e2;
+        }
+    }
+
+    mac2!(0, 1);
+
+    macro_rules! mac {
+        ($e:expr) => {
+            let ..$e; //~ ERROR `..X` range patterns are not supported
+            let ...$e; //~ ERROR `...X` range patterns are not supported
+            //~^ ERROR `...` range patterns are deprecated
+            let ..=$e; //~ ERROR `..=X` range patterns are not supported
+            let $e..; //~ ERROR `X..` range patterns are not supported
+            let $e...; //~ ERROR `X...` range patterns are not supported
+            //~^ ERROR `...` range patterns are deprecated
+            let $e..=; //~ ERROR `X..=` range patterns are not supported
+        }
+    }
+
+    mac!(0);
+}
diff --git a/src/test/ui/parser/recover-range-pats.stderr b/src/test/ui/parser/recover-range-pats.stderr
index c50d5e6eb61..89ec059cb82 100644
--- a/src/test/ui/parser/recover-range-pats.stderr
+++ b/src/test/ui/parser/recover-range-pats.stderr
@@ -214,6 +214,60 @@ error: `...X` range patterns are not supported
 LL |     if let ....3 = 0 {}
    |            ^^^^^ help: try using the minimum value for the type: `MIN...0.3`
 
+error: `..X` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:139:17
+   |
+LL |             let ..$e;
+   |                 ^^ help: try using the minimum value for the type: `MIN..0`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `...X` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:140:17
+   |
+LL |             let ...$e;
+   |                 ^^^ help: try using the minimum value for the type: `MIN...0`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `..=X` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:142:17
+   |
+LL |             let ..=$e;
+   |                 ^^^ help: try using the minimum value for the type: `MIN..=0`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `X..` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:143:19
+   |
+LL |             let $e..;
+   |                   ^^ help: try using the maximum value for the type: `0..MAX`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `X...` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:144:19
+   |
+LL |             let $e...;
+   |                   ^^^ help: try using the maximum value for the type: `0...MAX`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `X..=` range patterns are not supported
+  --> $DIR/recover-range-pats.rs:146:19
+   |
+LL |             let $e..=;
+   |                   ^^^ help: try using the maximum value for the type: `0..=MAX`
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
 error: `...` range patterns are deprecated
   --> $DIR/recover-range-pats.rs:41:13
    |
@@ -316,6 +370,33 @@ error: `...` range patterns are deprecated
 LL |     if let ....3 = 0 {}
    |            ^^^ help: use `..=` for an inclusive range
 
+error: `...` range patterns are deprecated
+  --> $DIR/recover-range-pats.rs:129:20
+   |
+LL |             let $e1...$e2;
+   |                    ^^^ help: use `..=` for an inclusive range
+...
+LL |     mac2!(0, 1);
+   |     ------------ in this macro invocation
+
+error: `...` range patterns are deprecated
+  --> $DIR/recover-range-pats.rs:140:17
+   |
+LL |             let ...$e;
+   |                 ^^^ help: use `..=` for an inclusive range
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
+error: `...` range patterns are deprecated
+  --> $DIR/recover-range-pats.rs:144:19
+   |
+LL |             let $e...;
+   |                   ^^^ help: use `..=` for an inclusive range
+...
+LL |     mac!(0);
+   |     -------- in this macro invocation
+
 error[E0029]: only char and numeric types are allowed in range patterns
   --> $DIR/recover-range-pats.rs:19:12
    |
@@ -532,7 +613,7 @@ LL |     if let ....3 = 0 {}
    = note: expected type `{integer}`
               found type `{float}`
 
-error: aborting due to 76 previous errors
+error: aborting due to 85 previous errors
 
 Some errors have detailed explanations: E0029, E0308.
 For more information about an error, try `rustc --explain E0029`.