Skip to content

Commit 5ae7363

Browse files
committed
Stabilize half_open_range_patterns
1 parent c084c26 commit 5ae7363

File tree

43 files changed

+258
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+258
-398
lines changed

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ declare_features! (
169169
(accepted, global_allocator, "1.28.0", Some(27389), None),
170170
// FIXME: explain `globs`.
171171
(accepted, globs, "1.0.0", None, None),
172+
/// Allows using `..=X` as a pattern.
173+
(accepted, half_open_range_patterns, "CURRENT_RUSTC_VERSION", Some(67264), None),
172174
/// Allows using the `u128` and `i128` types.
173175
(accepted, i128_type, "1.26.0", Some(35118), None),
174176
/// Allows the use of `if let` expressions.

compiler/rustc_middle/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#![feature(type_alias_impl_trait)]
4545
#![feature(associated_type_bounds)]
4646
#![feature(rustc_attrs)]
47-
#![feature(half_open_range_patterns)]
47+
#![cfg_attr(bootstrap, feature(half_open_range_patterns))]
4848
#![feature(control_flow_enum)]
4949
#![feature(associated_type_defaults)]
5050
#![feature(trusted_step)]

compiler/rustc_parse/src/parser/pat.rs

-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ impl<'a> Parser<'a> {
777777
/// expression syntax `...expr` for splatting in expressions.
778778
fn parse_pat_range_to(&mut self, mut re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
779779
let end = self.parse_pat_range_end()?;
780-
self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_token.span));
781780
if let RangeEnd::Included(ref mut syn @ RangeSyntax::DotDotDot) = &mut re.node {
782781
*syn = RangeSyntax::DotDotEq;
783782
self.struct_span_err(re.span, "range-to patterns with `...` are not allowed")

src/doc/unstable-book/src/language-features/half-open-range-patterns.md

-27
This file was deleted.

src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(half_open_range_patterns)]
21
#![feature(exclusive_range_pattern)]
32

43
fn main() {

src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:12
2+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:12
33
|
44
LL | match [5..4, 99..105, 43..44] {
55
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
@@ -10,7 +10,7 @@ LL | [..9, 99..100, _] => {},
1010
found type `{integer}`
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:15
13+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:15
1414
|
1515
LL | match [5..4, 99..105, 43..44] {
1616
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
@@ -23,7 +23,7 @@ LL | [..9, 99..100, _] => {},
2323
found type `{integer}`
2424

2525
error[E0308]: mismatched types
26-
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:19
26+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:19
2727
|
2828
LL | match [5..4, 99..105, 43..44] {
2929
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`

src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs

-18
This file was deleted.

src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr

-53
This file was deleted.

src/test/ui/half-open-range-patterns/half-open-range-pats-bad-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(half_open_range_patterns)]
21
#![feature(exclusive_range_pattern)]
32

43
fn main() {

src/test/ui/half-open-range-patterns/half-open-range-pats-bad-types.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0029]: only `char` and numeric types are allowed in range patterns
2-
--> $DIR/half-open-range-pats-bad-types.rs:5:9
2+
--> $DIR/half-open-range-pats-bad-types.rs:4:9
33
|
44
LL | let "a".. = "a";
55
| ^^^ this is of type `&'static str` but it should be `char` or numeric
66

77
error[E0029]: only `char` and numeric types are allowed in range patterns
8-
--> $DIR/half-open-range-pats-bad-types.rs:6:11
8+
--> $DIR/half-open-range-pats-bad-types.rs:5:11
99
|
1010
LL | let .."a" = "a";
1111
| ^^^ this is of type `&'static str` but it should be `char` or numeric
1212

1313
error[E0029]: only `char` and numeric types are allowed in range patterns
14-
--> $DIR/half-open-range-pats-bad-types.rs:7:12
14+
--> $DIR/half-open-range-pats-bad-types.rs:6:12
1515
|
1616
LL | let ..="a" = "a";
1717
| ^^^ this is of type `&'static str` but it should be `char` or numeric

src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Test various non-exhaustive matches for `X..`, `..=X` and `..X` ranges.
22

3-
#![feature(half_open_range_patterns)]
43
#![feature(exclusive_range_pattern)]
54
#![allow(illegal_floating_point_literal_pattern)]
65

0 commit comments

Comments
 (0)