Skip to content

Commit 54c4a83

Browse files
committed
dotdoteq_in_patterns feature gate
1 parent 7aabf57 commit 54c4a83

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/libsyntax/feature_gate.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use self::AttributeType::*;
2626
use self::AttributeGate::*;
2727

2828
use abi::Abi;
29-
use ast::{self, NodeId, PatKind, RangeEnd};
29+
use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax};
3030
use attr;
3131
use codemap::Spanned;
3232
use syntax_pos::Span;
@@ -392,6 +392,9 @@ declare_features! (
392392

393393
// allow `'_` placeholder lifetimes
394394
(active, underscore_lifetimes, "1.22.0", Some(44524)),
395+
396+
// allow `..=` in patterns (RFC 1192)
397+
(active, dotdoteq_in_patterns, "1.22.0", Some(28237)),
395398
);
396399

397400
declare_features! (
@@ -1491,6 +1494,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
14911494
gate_feature_post!(&self, exclusive_range_pattern, pattern.span,
14921495
"exclusive range pattern syntax is experimental");
14931496
}
1497+
PatKind::Range(_, _, RangeEnd::Included(RangeSyntax::DotDotEq)) => {
1498+
gate_feature_post!(&self, dotdoteq_in_patterns, pattern.span,
1499+
"`..=` syntax in patterns is experimental");
1500+
}
14941501
_ => {}
14951502
}
14961503
visit::walk_pat(self, pattern)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
match 22 {
13+
0 ..= 3 => {} //~ ERROR `..=` syntax in patterns is experimental
14+
_ => {}
15+
}
16+
}

src/test/run-pass/inc-range-pat.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// except according to those terms.
1010

1111
// Test old and new syntax for inclusive range patterns.
12+
#![feature(dotdoteq_in_patterns)]
13+
1214

1315
fn main() {
1416
assert!(match 42 { 0 ... 100 => true, _ => false });

0 commit comments

Comments
 (0)