diff options
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 9 | ||||
| -rw-r--r-- | src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs | 16 | ||||
| -rw-r--r-- | src/test/run-pass/inc-range-pat.rs | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2fc451d5d00..aa5a4143027 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -26,7 +26,7 @@ use self::AttributeType::*; use self::AttributeGate::*; use abi::Abi; -use ast::{self, NodeId, PatKind, RangeEnd}; +use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax}; use attr; use codemap::Spanned; use syntax_pos::Span; @@ -392,6 +392,9 @@ declare_features! ( // allow `'_` placeholder lifetimes (active, underscore_lifetimes, "1.22.0", Some(44524)), + + // allow `..=` in patterns (RFC 1192) + (active, dotdoteq_in_patterns, "1.22.0", Some(28237)), ); declare_features! ( @@ -1491,6 +1494,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, exclusive_range_pattern, pattern.span, "exclusive range pattern syntax is experimental"); } + PatKind::Range(_, _, RangeEnd::Included(RangeSyntax::DotDotEq)) => { + gate_feature_post!(&self, dotdoteq_in_patterns, pattern.span, + "`..=` syntax in patterns is experimental"); + } _ => {} } visit::walk_pat(self, pattern) diff --git a/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs b/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs new file mode 100644 index 00000000000..1fb139bf07f --- /dev/null +++ b/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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. + +pub fn main() { + match 22 { + 0 ..= 3 => {} //~ ERROR `..=` syntax in patterns is experimental + _ => {} + } +} diff --git a/src/test/run-pass/inc-range-pat.rs b/src/test/run-pass/inc-range-pat.rs index 237b41b6128..5faf36eddaf 100644 --- a/src/test/run-pass/inc-range-pat.rs +++ b/src/test/run-pass/inc-range-pat.rs @@ -9,6 +9,8 @@ // except according to those terms. // Test old and new syntax for inclusive range patterns. +#![feature(dotdoteq_in_patterns)] + fn main() { assert!(match 42 { 0 ... 100 => true, _ => false }); |
