Skip to content

Commit

Permalink
Stabilize half_open_range_patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 8, 2022
1 parent c084c26 commit 5ae7363
Show file tree
Hide file tree
Showing 43 changed files with 258 additions and 398 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ declare_features! (
(accepted, global_allocator, "1.28.0", Some(27389), None),
// FIXME: explain `globs`.
(accepted, globs, "1.0.0", None, None),
/// Allows using `..=X` as a pattern.
(accepted, half_open_range_patterns, "CURRENT_RUSTC_VERSION", Some(67264), None),
/// Allows using the `u128` and `i128` types.
(accepted, i128_type, "1.26.0", Some(35118), None),
/// Allows the use of `if let` expressions.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#![feature(type_alias_impl_trait)]
#![feature(associated_type_bounds)]
#![feature(rustc_attrs)]
#![feature(half_open_range_patterns)]
#![cfg_attr(bootstrap, feature(half_open_range_patterns))]
#![feature(control_flow_enum)]
#![feature(associated_type_defaults)]
#![feature(trusted_step)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ impl<'a> Parser<'a> {
/// expression syntax `...expr` for splatting in expressions.
fn parse_pat_range_to(&mut self, mut re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
let end = self.parse_pat_range_end()?;
self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_token.span));
if let RangeEnd::Included(ref mut syn @ RangeSyntax::DotDotDot) = &mut re.node {
*syn = RangeSyntax::DotDotEq;
self.struct_span_err(re.span, "range-to patterns with `...` are not allowed")
Expand Down

This file was deleted.

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

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:6:12
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:12
|
LL | match [5..4, 99..105, 43..44] {
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`
Expand All @@ -10,7 +10,7 @@ LL | [..9, 99..100, _] => {},
found type `{integer}`

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

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

This file was deleted.

This file was deleted.

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

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0029]: only `char` and numeric types are allowed in range patterns
--> $DIR/half-open-range-pats-bad-types.rs:5:9
--> $DIR/half-open-range-pats-bad-types.rs:4:9
|
LL | let "a".. = "a";
| ^^^ this is of type `&'static str` but it should be `char` or numeric

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

error[E0029]: only `char` and numeric types are allowed in range patterns
--> $DIR/half-open-range-pats-bad-types.rs:7:12
--> $DIR/half-open-range-pats-bad-types.rs:6:12
|
LL | let ..="a" = "a";
| ^^^ this is of type `&'static str` but it should be `char` or numeric
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Test various non-exhaustive matches for `X..`, `..=X` and `..X` ranges.

#![feature(half_open_range_patterns)]
#![feature(exclusive_range_pattern)]
#![allow(illegal_floating_point_literal_pattern)]

Expand Down
Loading

0 comments on commit 5ae7363

Please sign in to comment.