diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-02-24 15:27:06 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-03-01 01:47:56 +0300 |
| commit | c9aff92e6dc3ea43228d3d4e24ee7f5485943569 (patch) | |
| tree | 84fe8eb3d8ea997a2fecd31c818ce040a3f741af /src/test | |
| parent | 0ff9872b2280009f094af0df3dcdc542cc46a5fd (diff) | |
Support parentheses in patterns under feature gate
Improve recovery for trailing comma after `..`
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/parse-fail/pat-tuple-2.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/pat-tuple-7.rs (renamed from src/test/parse-fail/pat-tuple-6.rs) | 4 | ||||
| -rw-r--r-- | src/test/ui/feature-gate-pattern_parentheses.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/feature-gate-pattern_parentheses.stderr | 11 |
4 files changed, 29 insertions, 3 deletions
diff --git a/src/test/parse-fail/pat-tuple-2.rs b/src/test/parse-fail/pat-tuple-2.rs index ad52fa57870..07b391d3279 100644 --- a/src/test/parse-fail/pat-tuple-2.rs +++ b/src/test/parse-fail/pat-tuple-2.rs @@ -12,6 +12,6 @@ fn main() { match 0 { - (pat, ..,) => {} //~ ERROR expected pattern, found `)` + (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` } } diff --git a/src/test/parse-fail/pat-tuple-6.rs b/src/test/run-pass/pat-tuple-7.rs index 3252d92fe1b..6d51df63e15 100644 --- a/src/test/parse-fail/pat-tuple-6.rs +++ b/src/test/run-pass/pat-tuple-7.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Z parse-only +#![feature(pattern_parentheses)] fn main() { match 0 { - (pat) => {} //~ ERROR expected one of `,` or `@`, found `)` + (pat) => assert_eq!(pat, 0) } } diff --git a/src/test/ui/feature-gate-pattern_parentheses.rs b/src/test/ui/feature-gate-pattern_parentheses.rs new file mode 100644 index 00000000000..29768018f0e --- /dev/null +++ b/src/test/ui/feature-gate-pattern_parentheses.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 0 { + (pat) => {} //~ ERROR parentheses in patterns are unstable + } +} diff --git a/src/test/ui/feature-gate-pattern_parentheses.stderr b/src/test/ui/feature-gate-pattern_parentheses.stderr new file mode 100644 index 00000000000..4fc1441a0fa --- /dev/null +++ b/src/test/ui/feature-gate-pattern_parentheses.stderr @@ -0,0 +1,11 @@ +error[E0658]: parentheses in patterns are unstable + --> $DIR/feature-gate-pattern_parentheses.rs:13:9 + | +LL | (pat) => {} //~ ERROR parentheses in patterns are unstable + | ^^^^^ + | + = help: add #![feature(pattern_parentheses)] to the crate attributes to enable + +error: aborting due to previous error + +If you want more information on this error, try using "rustc --explain E0658" |
