dotdoteq_in_patterns feature gate
This commit is contained in:
parent
7aabf57278
commit
54c4a83084
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
_ => {}
|
||||
}
|
||||
}
|
|
@ -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 });
|
||||
|
|
Loading…
Reference in New Issue