Skip to content

Commit 8994315

Browse files
committed
Auto merge of #124459 - RossSmyth:stable_range, r=davidtwco
Stabilize exclusive_range_pattern Stabilization report: #37854 (comment) FCP: #37854 (comment) Stabilization was blocked by a lint that was merged here: #118879 Documentation PR is here: rust-lang/reference#1484 `@rustbot` label +F-exclusive_range_pattern +T-lang
2 parents 6e146c0 + 57f00ce commit 8994315

File tree

84 files changed

+366
-691
lines changed

Some content is hidden

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

84 files changed

+366
-691
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
@@ -844,7 +844,6 @@ declare_lint! {
844844
/// ### Example
845845
///
846846
/// ```rust
847-
/// # #![feature(exclusive_range_pattern)]
848847
/// let x = 123u32;
849848
/// match x {
850849
/// 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
@@ -165,6 +165,7 @@
165165
//
166166
// Language features:
167167
// tidy-alphabetical-start
168+
#![cfg_attr(bootstrap, feature(exclusive_range_pattern))]
168169
#![cfg_attr(not(test), feature(coroutine_trait))]
169170
#![cfg_attr(test, feature(panic_update_hook))]
170171
#![cfg_attr(test, feature(test))]
@@ -179,7 +180,6 @@
179180
#![feature(const_try)]
180181
#![feature(decl_macro)]
181182
#![feature(dropck_eyepatch)]
182-
#![feature(exclusive_range_pattern)]
183183
#![feature(fundamental)]
184184
#![feature(hashmap_internals)]
185185
#![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];

src/tools/clippy/tests/ui/almost_complete_range.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@edition:2018
22
//@aux-build:proc_macros.rs
33

4-
#![feature(exclusive_range_pattern)]
54
#![feature(stmt_expr_attributes)]
65
#![warn(clippy::almost_complete_range)]
76
#![allow(ellipsis_inclusive_range_patterns)]

src/tools/clippy/tests/ui/almost_complete_range.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@edition:2018
22
//@aux-build:proc_macros.rs
33

4-
#![feature(exclusive_range_pattern)]
54
#![feature(stmt_expr_attributes)]
65
#![warn(clippy::almost_complete_range)]
76
#![allow(ellipsis_inclusive_range_patterns)]

src/tools/clippy/tests/ui/almost_complete_range.stderr

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: almost complete ascii range
2-
--> tests/ui/almost_complete_range.rs:18:17
2+
--> tests/ui/almost_complete_range.rs:17:17
33
|
44
LL | let _ = ('a') ..'z';
55
| ^^^^^^--^^^
@@ -10,119 +10,119 @@ LL | let _ = ('a') ..'z';
1010
= help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]`
1111

1212
error: almost complete ascii range
13-
--> tests/ui/almost_complete_range.rs:19:17
13+
--> tests/ui/almost_complete_range.rs:18:17
1414
|
1515
LL | let _ = 'A' .. ('Z');
1616
| ^^^^--^^^^^^
1717
| |
1818
| help: use an inclusive range: `..=`
1919

2020
error: almost complete ascii range
21-
--> tests/ui/almost_complete_range.rs:20:17
21+
--> tests/ui/almost_complete_range.rs:19:17
2222
|
2323
LL | let _ = ((('0'))) .. ('9');
2424
| ^^^^^^^^^^--^^^^^^
2525
| |
2626
| help: use an inclusive range: `..=`
2727

2828
error: almost complete ascii range
29-
--> tests/ui/almost_complete_range.rs:27:13
29+
--> tests/ui/almost_complete_range.rs:26:13
3030
|
3131
LL | let _ = (b'a')..(b'z');
3232
| ^^^^^^--^^^^^^
3333
| |
3434
| help: use an inclusive range: `..=`
3535

3636
error: almost complete ascii range
37-
--> tests/ui/almost_complete_range.rs:28:13
37+
--> tests/ui/almost_complete_range.rs:27:13
3838
|
3939
LL | let _ = b'A'..b'Z';
4040
| ^^^^--^^^^
4141
| |
4242
| help: use an inclusive range: `..=`
4343

4444
error: almost complete ascii range
45-
--> tests/ui/almost_complete_range.rs:29:13
45+
--> tests/ui/almost_complete_range.rs:28:13
4646
|
4747
LL | let _ = b'0'..b'9';
4848
| ^^^^--^^^^
4949
| |
5050
| help: use an inclusive range: `..=`
5151

5252
error: almost complete ascii range
53-
--> tests/ui/almost_complete_range.rs:35:13
53+
--> tests/ui/almost_complete_range.rs:34:13
5454
|
5555
LL | let _ = inline!('a')..'z';
5656
| ^^^^^^^^^^^^--^^^
5757
| |
5858
| help: use an inclusive range: `..=`
5959

6060
error: almost complete ascii range
61-
--> tests/ui/almost_complete_range.rs:36:13
61+
--> tests/ui/almost_complete_range.rs:35:13
6262
|
6363
LL | let _ = inline!('A')..'Z';
6464
| ^^^^^^^^^^^^--^^^
6565
| |
6666
| help: use an inclusive range: `..=`
6767

6868
error: almost complete ascii range
69-
--> tests/ui/almost_complete_range.rs:37:13
69+
--> tests/ui/almost_complete_range.rs:36:13
7070
|
7171
LL | let _ = inline!('0')..'9';
7272
| ^^^^^^^^^^^^--^^^
7373
| |
7474
| help: use an inclusive range: `..=`
7575

7676
error: almost complete ascii range
77-
--> tests/ui/almost_complete_range.rs:40:9
77+
--> tests/ui/almost_complete_range.rs:39:9
7878
|
7979
LL | b'a'..b'z' if true => 1,
8080
| ^^^^--^^^^
8181
| |
8282
| help: use an inclusive range: `..=`
8383

8484
error: almost complete ascii range
85-
--> tests/ui/almost_complete_range.rs:41:9
85+
--> tests/ui/almost_complete_range.rs:40:9
8686
|
8787
LL | b'A'..b'Z' if true => 2,
8888
| ^^^^--^^^^
8989
| |
9090
| help: use an inclusive range: `..=`
9191

9292
error: almost complete ascii range
93-
--> tests/ui/almost_complete_range.rs:42:9
93+
--> tests/ui/almost_complete_range.rs:41:9
9494
|
9595
LL | b'0'..b'9' if true => 3,
9696
| ^^^^--^^^^
9797
| |
9898
| help: use an inclusive range: `..=`
9999

100100
error: almost complete ascii range
101-
--> tests/ui/almost_complete_range.rs:50:9
101+
--> tests/ui/almost_complete_range.rs:49:9
102102
|
103103
LL | 'a'..'z' if true => 1,
104104
| ^^^--^^^
105105
| |
106106
| help: use an inclusive range: `..=`
107107

108108
error: almost complete ascii range
109-
--> tests/ui/almost_complete_range.rs:51:9
109+
--> tests/ui/almost_complete_range.rs:50:9
110110
|
111111
LL | 'A'..'Z' if true => 2,
112112
| ^^^--^^^
113113
| |
114114
| help: use an inclusive range: `..=`
115115

116116
error: almost complete ascii range
117-
--> tests/ui/almost_complete_range.rs:52:9
117+
--> tests/ui/almost_complete_range.rs:51:9
118118
|
119119
LL | '0'..'9' if true => 3,
120120
| ^^^--^^^
121121
| |
122122
| help: use an inclusive range: `..=`
123123

124124
error: almost complete ascii range
125-
--> tests/ui/almost_complete_range.rs:65:17
125+
--> tests/ui/almost_complete_range.rs:64:17
126126
|
127127
LL | let _ = 'a'..'z';
128128
| ^^^--^^^
@@ -132,7 +132,7 @@ LL | let _ = 'a'..'z';
132132
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
133133

134134
error: almost complete ascii range
135-
--> tests/ui/almost_complete_range.rs:66:17
135+
--> tests/ui/almost_complete_range.rs:65:17
136136
|
137137
LL | let _ = 'A'..'Z';
138138
| ^^^--^^^
@@ -142,7 +142,7 @@ LL | let _ = 'A'..'Z';
142142
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
143143

144144
error: almost complete ascii range
145-
--> tests/ui/almost_complete_range.rs:67:17
145+
--> tests/ui/almost_complete_range.rs:66:17
146146
|
147147
LL | let _ = '0'..'9';
148148
| ^^^--^^^
@@ -152,71 +152,71 @@ LL | let _ = '0'..'9';
152152
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
153153

154154
error: almost complete ascii range
155-
--> tests/ui/almost_complete_range.rs:74:9
155+
--> tests/ui/almost_complete_range.rs:73:9
156156
|
157157
LL | 'a'..'z' => 1,
158158
| ^^^--^^^
159159
| |
160160
| help: use an inclusive range: `...`
161161

162162
error: almost complete ascii range
163-
--> tests/ui/almost_complete_range.rs:75:9
163+
--> tests/ui/almost_complete_range.rs:74:9
164164
|
165165
LL | 'A'..'Z' => 2,
166166
| ^^^--^^^
167167
| |
168168
| help: use an inclusive range: `...`
169169

170170
error: almost complete ascii range
171-
--> tests/ui/almost_complete_range.rs:76:9
171+
--> tests/ui/almost_complete_range.rs:75:9
172172
|
173173
LL | '0'..'9' => 3,
174174
| ^^^--^^^
175175
| |
176176
| help: use an inclusive range: `...`
177177

178178
error: almost complete ascii range
179-
--> tests/ui/almost_complete_range.rs:83:13
179+
--> tests/ui/almost_complete_range.rs:82:13
180180
|
181181
LL | let _ = 'a'..'z';
182182
| ^^^--^^^
183183
| |
184184
| help: use an inclusive range: `..=`
185185

186186
error: almost complete ascii range
187-
--> tests/ui/almost_complete_range.rs:84:13
187+
--> tests/ui/almost_complete_range.rs:83:13
188188
|
189189
LL | let _ = 'A'..'Z';
190190
| ^^^--^^^
191191
| |
192192
| help: use an inclusive range: `..=`
193193

194194
error: almost complete ascii range
195-
--> tests/ui/almost_complete_range.rs:85:13
195+
--> tests/ui/almost_complete_range.rs:84:13
196196
|
197197
LL | let _ = '0'..'9';
198198
| ^^^--^^^
199199
| |
200200
| help: use an inclusive range: `..=`
201201

202202
error: almost complete ascii range
203-
--> tests/ui/almost_complete_range.rs:87:9
203+
--> tests/ui/almost_complete_range.rs:86:9
204204
|
205205
LL | 'a'..'z' => 1,
206206
| ^^^--^^^
207207
| |
208208
| help: use an inclusive range: `..=`
209209

210210
error: almost complete ascii range
211-
--> tests/ui/almost_complete_range.rs:88:9
211+
--> tests/ui/almost_complete_range.rs:87:9
212212
|
213213
LL | 'A'..'Z' => 1,
214214
| ^^^--^^^
215215
| |
216216
| help: use an inclusive range: `..=`
217217

218218
error: almost complete ascii range
219-
--> tests/ui/almost_complete_range.rs:89:9
219+
--> tests/ui/almost_complete_range.rs:88:9
220220
|
221221
LL | '0'..'9' => 3,
222222
| ^^^--^^^

0 commit comments

Comments
 (0)