Skip to content

Commit 828dd00

Browse files
committed
Stabilize exclusive_range
1 parent aed2187 commit 828dd00

File tree

74 files changed

+300
-619
lines changed

Some content is hidden

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

74 files changed

+300
-619
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast as ast;
22
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
33
use rustc_ast::{attr, AssocConstraint, AssocConstraintKind, NodeId};
4-
use rustc_ast::{token, PatKind, RangeEnd};
4+
use rustc_ast::{token, PatKind};
55
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
77
use rustc_session::Session;
@@ -418,15 +418,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
418418
PatKind::Box(..) => {
419419
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
420420
}
421-
PatKind::Range(_, Some(_), Spanned { node: RangeEnd::Excluded, .. }) => {
422-
gate!(
423-
&self,
424-
exclusive_range_pattern,
425-
pattern.span,
426-
"exclusive range pattern syntax is experimental",
427-
"use an inclusive range pattern, like N..=M"
428-
);
429-
}
430421
_ => {}
431422
}
432423
visit::walk_pat(self, pattern)
@@ -619,10 +610,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
619610
// be too.
620611
gate_all_legacy_dont_use!(return_type_notation, "return type notation is experimental");
621612
gate_all_legacy_dont_use!(decl_macro, "`macro` is experimental");
622-
gate_all_legacy_dont_use!(
623-
exclusive_range_pattern,
624-
"exclusive range pattern syntax is experimental"
625-
);
626613
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
627614
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");
628615

compiler/rustc_error_codes/src/error_codes/E0579.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ A lower range wasn't less than the upper range.
33
Erroneous code example:
44

55
```compile_fail,E0579
6-
#![feature(exclusive_range_pattern)]
76
87
fn main() {
98
match 5u32 {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ declare_features! (
162162
(accepted, drop_types_in_const, "1.22.0", Some(33156)),
163163
/// Allows using `dyn Trait` as a syntax for trait objects.
164164
(accepted, dyn_trait, "1.27.0", Some(44662)),
165+
/// Allows `X..Y` patterns.
166+
(accepted, exclusive_range_pattern, "CURRENT_RUSTC_VERSION", Some(37854)),
165167
/// Allows integer match exhaustiveness checking (RFC 2591).
166168
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907)),
167169
/// Allows explicit generic arguments specification with `impl Trait` present.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,6 @@ declare_features! (
454454
(incomplete, dyn_star, "1.65.0", Some(102425)),
455455
/// Uses generic effect parameters for ~const bounds
456456
(unstable, effects, "1.72.0", Some(102090)),
457-
/// Allows `X..Y` patterns.
458-
(unstable, exclusive_range_pattern, "1.11.0", Some(37854)),
459457
/// Allows exhaustive pattern matching on types that contain uninhabited types.
460458
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
461459
/// Allows explicit tail calls via `become` expression.

compiler/rustc_lint_defs/src/builtin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,6 @@ declare_lint! {
842842
/// ### Example
843843
///
844844
/// ```rust
845-
/// # #![feature(exclusive_range_pattern)]
846845
/// let x = 123u32;
847846
/// match x {
848847
/// 0..100 => { println!("small"); }

compiler/rustc_pattern_analysis/src/usefulness.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
//! This is enough to compute usefulness: a pattern in a `match` expression is redundant iff it is
4343
//! not useful w.r.t. the patterns above it:
4444
//! ```compile_fail,E0004
45-
//! # #![feature(exclusive_range_pattern)]
4645
//! # fn foo() {
4746
//! match Some(0u32) {
4847
//! Some(0..100) => {},

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
// Language features:
168168
// tidy-alphabetical-start
169169
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
170+
#![cfg_attr(bootstrap, feature(exclusive_range_pattern))]
170171
#![cfg_attr(bootstrap, feature(inline_const))]
171172
#![cfg_attr(not(bootstrap), rustc_preserve_ub_checks)]
172173
#![cfg_attr(not(test), feature(coroutine_trait))]
@@ -183,7 +184,6 @@
183184
#![feature(const_try)]
184185
#![feature(decl_macro)]
185186
#![feature(dropck_eyepatch)]
186-
#![feature(exclusive_range_pattern)]
187187
#![feature(fundamental)]
188188
#![feature(hashmap_internals)]
189189
#![feature(lang_items)]

src/doc/unstable-book/src/language-features/exclusive-range-pattern.md

-26
This file was deleted.

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# `half_open_range_patterns_in_slices`
22

33
The tracking issue for this feature is: [#67264]
4-
It is part of the `exclusive_range_pattern` feature,
4+
It is a future part of the `exclusive_range_pattern` feature,
55
tracked at [#37854].
66

77
[#67264]: https://github.com/rust-lang/rust/issues/67264
@@ -12,7 +12,6 @@ This feature allow using top-level half-open range patterns in slices.
1212

1313
```rust
1414
#![feature(half_open_range_patterns_in_slices)]
15-
#![feature(exclusive_range_pattern)]
1615

1716
fn main() {
1817
let xs = [13, 1, 5, 2, 3, 1, 21, 8];

tests/mir-opt/building/match/sort_candidates.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Check specific cases of sorting candidates in match lowering.
2-
#![feature(exclusive_range_pattern)]
32

43
// EMIT_MIR sort_candidates.constant_eq.SimplifyCfg-initial.after.mir
54
fn constant_eq(s: &str, b: bool) -> u32 {

tests/ui/binding/match-range.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
#![feature(exclusive_range_pattern)]
32

43
pub fn main() {
54
match 5_usize {

tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ aux-build:static_cross_crate.rs
33
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
44
//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
5-
#![feature(exclusive_range_pattern, half_open_range_patterns_in_slices)]
5+
#![feature(half_open_range_patterns_in_slices)]
66
#![allow(static_mut_refs)]
77

88
extern crate static_cross_crate;

tests/ui/feature-gates/feature-gate-exclusive-range-pattern.rs

-6
This file was deleted.

tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr

-14
This file was deleted.

tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(half_open_range_patterns_in_slices)]
2-
#![feature(exclusive_range_pattern)]
32

43
fn main() {
54
match [5..4, 99..105, 43..44] {

tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/exclusive_range_pattern_syntax_collision.rs:6:13
2+
--> $DIR/exclusive_range_pattern_syntax_collision.rs:5:13
33
|
44
LL | match [5..4, 99..105, 43..44] {
55
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`

tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(half_open_range_patterns_in_slices)]
2-
#![feature(exclusive_range_pattern)]
32

43
fn main() {
54
match [5..4, 99..105, 43..44] {

tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0527]: pattern requires 2 elements but array has 3
2-
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:6:9
2+
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:5:9
33
|
44
LL | [_, 99..] => {},
55
| ^^^^^^^^^ expected 3 elements
66

77
error[E0308]: mismatched types
8-
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:6:13
8+
--> $DIR/exclusive_range_pattern_syntax_collision2.rs:5:13
99
|
1010
LL | match [5..4, 99..105, 43..44] {
1111
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`

tests/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(exclusive_range_pattern)]
2-
31
fn main() {
42
match [5..4, 99..105, 43..44] {
53
[..9, 99..100, _] => {},

tests/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:5:12
2+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:3: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:5:15
13+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:3: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:5:19
26+
--> $DIR/exclusive_range_pattern_syntax_collision3.rs:3:19
2727
|
2828
LL | match [5..4, 99..105, 43..44] {
2929
| ----------------------- this expression has type `[std::ops::Range<{integer}>; 3]`

tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(exclusive_range_pattern)]
2-
31
fn main() {
42
let xs = [13, 1, 5, 2, 3, 1, 21, 8];
53
let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;

tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: `X..` patterns in slices are experimental
2-
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:5:10
2+
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:3:10
33
|
44
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
55
| ^^^^^^^
@@ -9,7 +9,7 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0005]: refutable pattern in local binding
12-
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:5:9
12+
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:3:9
1313
|
1414
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `[i32::MIN..=2_i32, ..]` not covered

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(exclusive_range_pattern)]
2-
31
fn main() {
42
let "a".. = "a"; //~ ERROR only `char` and numeric types are allowed in range patterns
53
let .."a" = "a"; //~ ERROR only `char` and numeric types are allowed in range patterns

tests/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:4:9
2+
--> $DIR/half-open-range-pats-bad-types.rs:2: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:5:11
8+
--> $DIR/half-open-range-pats-bad-types.rs:3: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:6:12
14+
--> $DIR/half-open-range-pats-bad-types.rs:4:12
1515
|
1616
LL | let ..="a" = "a";
1717
| ^^^ this is of type `&'static str` but it should be `char` or numeric

tests/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(exclusive_range_pattern)]
43
#![allow(non_contiguous_range_endpoints)]
54

65
fn main() {}

0 commit comments

Comments
 (0)