Skip to content

Commit 0b3b8bf

Browse files
authored
Rollup merge of rust-lang#120547 - matthewjasper:complete-inline-const-pat, r=compiler-errors
`#![feature(inline_const_pat)]` is no longer incomplete Now that borrow checking and safety checking is implemented for inline constant patterns, the incomplete feature status is not necessary. Stabilizing this feature requires more testing and has some of the same unresolved questions as inline constants. cc rust-lang#76001
2 parents ce6bd84 + 4feec41 commit 0b3b8bf

25 files changed

+28
-53
lines changed

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ declare_features! (
496496
/// Allow anonymous constants from an inline `const` block
497497
(unstable, inline_const, "1.49.0", Some(76001)),
498498
/// Allow anonymous constants from an inline `const` block in pattern position
499-
(incomplete, inline_const_pat, "1.58.0", Some(76001)),
499+
(unstable, inline_const_pat, "1.58.0", Some(76001)),
500500
/// Allows using `pointer` and `reference` in intra-doc links
501501
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
502502
// Allows setting the threshold for the `large_assignments` lint.

tests/ui/consts/invalid-inline-const-in-match-arm.rs

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

43
fn main() {

tests/ui/consts/invalid-inline-const-in-match-arm.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0015]: cannot call non-const closure in constants
2-
--> $DIR/invalid-inline-const-in-match-arm.rs:6:17
2+
--> $DIR/invalid-inline-const-in-match-arm.rs:5:17
33
|
44
LL | const { (|| {})() } => {}
55
| ^^^^^^^^^

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

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

tests/ui/inline-const/const-match-pat-generic.rs

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

43
// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter

tests/ui/inline-const/const-match-pat-generic.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: constant pattern depends on a generic parameter
2-
--> $DIR/const-match-pat-generic.rs:8:9
2+
--> $DIR/const-match-pat-generic.rs:7:9
33
|
44
LL | const { V } => {},
55
| ^^^^^^^^^^^
66

77
error: constant pattern depends on a generic parameter
8-
--> $DIR/const-match-pat-generic.rs:20:9
8+
--> $DIR/const-match-pat-generic.rs:19:9
99
|
1010
LL | const { f(V) } => {},
1111
| ^^^^^^^^^^^^^^

tests/ui/inline-const/const-match-pat-inference.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// check-pass
22

33
#![feature(inline_const_pat)]
4-
#![allow(incomplete_features)]
54

65
fn main() {
76
match 1u64 {

tests/ui/inline-const/const-match-pat-lifetime-err.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(const_mut_refs)]
32
#![feature(inline_const_pat)]
43

tests/ui/inline-const/const-match-pat-lifetime-err.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0597]: `y` does not live long enough
2-
--> $DIR/const-match-pat-lifetime-err.rs:29:29
2+
--> $DIR/const-match-pat-lifetime-err.rs:28:29
33
|
44
LL | fn match_invariant_ref<'a>() {
55
| -- lifetime `'a` defined here
@@ -15,7 +15,7 @@ LL | }
1515
| - `y` dropped here while still borrowed
1616

1717
error: lifetime may not live long enough
18-
--> $DIR/const-match-pat-lifetime-err.rs:39:12
18+
--> $DIR/const-match-pat-lifetime-err.rs:38:12
1919
|
2020
LL | fn match_covariant_ref<'a>() {
2121
| -- lifetime `'a` defined here

tests/ui/inline-const/const-match-pat-lifetime.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22

3-
#![allow(incomplete_features)]
43
#![feature(const_mut_refs)]
54
#![feature(inline_const)]
65
#![feature(inline_const_pat)]

tests/ui/inline-const/const-match-pat-range.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// build-pass
22

3-
#![allow(incomplete_features)]
43
#![feature(inline_const_pat, exclusive_range_pattern)]
54

65
fn main() {

tests/ui/inline-const/const-match-pat.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22

3-
#![allow(incomplete_features)]
43
#![feature(inline_const_pat)]
54
const MMIO_BIT1: u8 = 4;
65
const MMIO_BIT2: u8 = 5;

tests/ui/inline-const/pat-match-fndef.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(inline_const_pat)]
2-
//~^ WARN the feature `inline_const_pat` is incomplete
32

43
fn uwu() {}
54

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `inline_const_pat` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/pat-match-fndef.rs:1:12
3-
|
4-
LL | #![feature(inline_const_pat)]
5-
| ^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `fn() {uwu}` cannot be used in patterns
11-
--> $DIR/pat-match-fndef.rs:9:9
2+
--> $DIR/pat-match-fndef.rs:8:9
123
|
134
LL | const { uwu } => {}
145
| ^^^^^^^^^^^^^
156

16-
error: aborting due to 1 previous error; 1 warning emitted
7+
error: aborting due to 1 previous error
178

tests/ui/inline-const/pat-unsafe-err.rs

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

43
const unsafe fn require_unsafe() -> usize {

tests/ui/inline-const/pat-unsafe-err.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
2-
--> $DIR/pat-unsafe-err.rs:11:13
2+
--> $DIR/pat-unsafe-err.rs:10:13
33
|
44
LL | require_unsafe();
55
| ^^^^^^^^^^^^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
10-
--> $DIR/pat-unsafe-err.rs:18:13
10+
--> $DIR/pat-unsafe-err.rs:17:13
1111
|
1212
LL | require_unsafe()
1313
| ^^^^^^^^^^^^^^^^ call to unsafe function

tests/ui/inline-const/pat-unsafe.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22

3-
#![allow(incomplete_features)]
43
#![warn(unused_unsafe)]
54
#![feature(inline_const_pat)]
65

tests/ui/inline-const/pat-unsafe.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
warning: unnecessary `unsafe` block
2-
--> $DIR/pat-unsafe.rs:16:17
2+
--> $DIR/pat-unsafe.rs:15:17
33
|
44
LL | unsafe {}
55
| ^^^^^^ unnecessary `unsafe` block
66
|
77
note: the lint level is defined here
8-
--> $DIR/pat-unsafe.rs:4:9
8+
--> $DIR/pat-unsafe.rs:3:9
99
|
1010
LL | #![warn(unused_unsafe)]
1111
| ^^^^^^^^^^^^^
1212

1313
warning: unnecessary `unsafe` block
14-
--> $DIR/pat-unsafe.rs:23:17
14+
--> $DIR/pat-unsafe.rs:22:17
1515
|
1616
LL | unsafe {}
1717
| ^^^^^^ unnecessary `unsafe` block

tests/ui/lint/dead-code/anon-const-in-pat.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22
#![feature(inline_const_pat)]
3-
#![allow(incomplete_features)]
43
#![deny(dead_code)]
54

65
const fn one() -> i32 {

tests/ui/match/issue-112438.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
#![feature(inline_const_pat)]
33
#![allow(dead_code)]
4-
#![allow(incomplete_features)]
54
fn foo<const V: usize>() {
65
match 0 {
76
const { 1 << 5 } | _ => {}

tests/ui/match/validate-range-endpoints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(exclusive_range_pattern)]
22
#![feature(inline_const_pat)]
3-
#![allow(incomplete_features)]
43
#![allow(overlapping_range_endpoints)]
54

65
fn main() {

tests/ui/match/validate-range-endpoints.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
error: literal out of range for `u8`
2-
--> $DIR/validate-range-endpoints.rs:9:12
2+
--> $DIR/validate-range-endpoints.rs:8:12
33
|
44
LL | 1..257 => {}
55
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`
66

77
error: literal out of range for `u8`
8-
--> $DIR/validate-range-endpoints.rs:11:13
8+
--> $DIR/validate-range-endpoints.rs:10:13
99
|
1010
LL | 1..=256 => {}
1111
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`
1212

1313
error[E0030]: lower range bound must be less than or equal to upper
14-
--> $DIR/validate-range-endpoints.rs:20:9
14+
--> $DIR/validate-range-endpoints.rs:19:9
1515
|
1616
LL | 1..=TOO_BIG => {}
1717
| ^^^^^^^^^^^ lower bound larger than upper bound
1818

1919
error[E0030]: lower range bound must be less than or equal to upper
20-
--> $DIR/validate-range-endpoints.rs:22:9
20+
--> $DIR/validate-range-endpoints.rs:21:9
2121
|
2222
LL | 1..=const { 256 } => {}
2323
| ^^^^^^^^^^^^^^^^^ lower bound larger than upper bound
2424

2525
error: literal out of range for `u64`
26-
--> $DIR/validate-range-endpoints.rs:28:32
26+
--> $DIR/validate-range-endpoints.rs:27:32
2727
|
2828
LL | 10000000000000000000..=99999999999999999999 => {}
2929
| ^^^^^^^^^^^^^^^^^^^^ this value does not fit into the type `u64` whose range is `0..=18446744073709551615`
3030

3131
error: literal out of range for `i8`
32-
--> $DIR/validate-range-endpoints.rs:34:12
32+
--> $DIR/validate-range-endpoints.rs:33:12
3333
|
3434
LL | 0..129 => {}
3535
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`
3636

3737
error: literal out of range for `i8`
38-
--> $DIR/validate-range-endpoints.rs:36:13
38+
--> $DIR/validate-range-endpoints.rs:35:13
3939
|
4040
LL | 0..=128 => {}
4141
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`
4242

4343
error: literal out of range for `i8`
44-
--> $DIR/validate-range-endpoints.rs:38:9
44+
--> $DIR/validate-range-endpoints.rs:37:9
4545
|
4646
LL | -129..0 => {}
4747
| ^^^^ this value does not fit into the type `i8` whose range is `-128..=127`
4848

4949
error: literal out of range for `i8`
50-
--> $DIR/validate-range-endpoints.rs:40:9
50+
--> $DIR/validate-range-endpoints.rs:39:9
5151
|
5252
LL | -10000..=-20 => {}
5353
| ^^^^^^ this value does not fit into the type `i8` whose range is `-128..=127`
5454

5555
error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
56-
--> $DIR/validate-range-endpoints.rs:51:11
56+
--> $DIR/validate-range-endpoints.rs:50:11
5757
|
5858
LL | match 0i8 {
5959
| ^^^ patterns `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
@@ -66,7 +66,7 @@ LL + i8::MIN..=-17_i8 | 1_i8..=i8::MAX => todo!()
6666
|
6767

6868
error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` not covered
69-
--> $DIR/validate-range-endpoints.rs:55:11
69+
--> $DIR/validate-range-endpoints.rs:54:11
7070
|
7171
LL | match 0i8 {
7272
| ^^^ pattern `i8::MIN..=-17_i8` not covered

tests/ui/pattern/non-structural-match-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// edition:2021
22

3-
#![allow(incomplete_features)]
43
#![allow(unreachable_code)]
54
#![feature(const_async_blocks)]
65
#![feature(inline_const_pat)]

tests/ui/pattern/non-structural-match-types.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error: `{closure@$DIR/non-structural-match-types.rs:10:17: 10:19}` cannot be used in patterns
2-
--> $DIR/non-structural-match-types.rs:10:9
1+
error: `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns
2+
--> $DIR/non-structural-match-types.rs:9:9
33
|
44
LL | const { || {} } => {}
55
| ^^^^^^^^^^^^^^^
66

7-
error: `{async block@$DIR/non-structural-match-types.rs:13:17: 13:25}` cannot be used in patterns
8-
--> $DIR/non-structural-match-types.rs:13:9
7+
error: `{async block@$DIR/non-structural-match-types.rs:12:17: 12:25}` cannot be used in patterns
8+
--> $DIR/non-structural-match-types.rs:12:9
99
|
1010
LL | const { async {} } => {}
1111
| ^^^^^^^^^^^^^^^^^^

tests/ui/unsafe/const_pat_in_layout_restricted.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// unsafe because they're within a pattern for a layout constrained stuct.
33
// check-pass
44

5-
#![allow(incomplete_features)]
65
#![feature(rustc_attrs)]
76
#![feature(inline_const_pat)]
87

0 commit comments

Comments
 (0)