remove feature(inline_const_pat)

This commit is contained in:
lcnr 2025-03-14 12:47:08 +01:00
parent 5d85a714b1
commit d4b8fa9e4c
53 changed files with 110 additions and 887 deletions

View File

@ -483,7 +483,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
half_open_range_patterns_in_slices,
"half-open range patterns in slices are unstable"
);
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
gate_all!(associated_const_equality, "associated const equality is incomplete");
gate_all!(yeet_expr, "`do yeet` expression is experimental");
gate_all!(dyn_star, "`dyn*` trait objects are experimental");

View File

@ -142,6 +142,9 @@ declare_features! (
/// Allows inferring `'static` outlives requirements (RFC 2093).
(removed, infer_static_outlives_requirements, "1.63.0", Some(54185),
Some("removed as it caused some confusion and discussion was inactive for years")),
/// Allow anonymous constants from an inline `const` block in pattern position
(removed, inline_const_pat, "CURRENT_RUSTC_VERSION", Some(76001),
Some("removed due to implementation concerns as it requires significant refactorings")),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")),
/// Changes `impl Trait` to capture all lifetimes in scope.

View File

@ -531,8 +531,6 @@ declare_features! (
(unstable, import_trait_associated_functions, "1.86.0", Some(134691)),
/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allow anonymous constants from an inline `const` block in pattern position
(unstable, inline_const_pat, "1.58.0", Some(76001)),
/// Allows using `pointer` and `reference` in intra-doc links
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
// Allows using the `kl` and `widekl` target features and the associated intrinsics

View File

@ -842,8 +842,6 @@ parse_unexpected_expr_in_pat_const_sugg = consider extracting the expression int
parse_unexpected_expr_in_pat_create_guard_sugg = consider moving the expression to a match arm guard
parse_unexpected_expr_in_pat_inline_const_sugg = consider wrapping the expression in an inline `const` (requires `{"#"}![feature(inline_const_pat)]`)
parse_unexpected_expr_in_pat_update_guard_sugg = consider moving the expression to the match arm guard
parse_unexpected_if_with_if = unexpected `if` in the condition expression

View File

@ -2787,17 +2787,6 @@ pub(crate) enum UnexpectedExpressionInPatternSugg {
/// The statement's block's indentation.
indentation: String,
},
#[multipart_suggestion(
parse_unexpected_expr_in_pat_inline_const_sugg,
applicability = "maybe-incorrect"
)]
InlineConst {
#[suggestion_part(code = "const {{ ")]
start_span: Span,
#[suggestion_part(code = " }}")]
end_span: Span,
},
}
#[derive(Diagnostic)]

View File

@ -1370,9 +1370,6 @@ impl<'a> Parser<'a> {
/// Parses inline const expressions.
fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
if pat {
self.psess.gated_spans.gate(sym::inline_const_pat, span);
}
self.expect_keyword(exp!(Const))?;
let (attrs, blk) = self.parse_inner_attrs_and_block(None)?;
let anon_const = AnonConst {
@ -1380,7 +1377,17 @@ impl<'a> Parser<'a> {
value: self.mk_expr(blk.span, ExprKind::Block(blk, None)),
};
let blk_span = anon_const.value.span;
Ok(self.mk_expr_with_attrs(span.to(blk_span), ExprKind::ConstBlock(anon_const), attrs))
let kind = if pat {
let guar = self
.dcx()
.struct_span_err(blk_span, "`inline_const_pat` has been removed")
.with_help("use a named `const`-item or an `if`-guard instead")
.emit();
ExprKind::Err(guar)
} else {
ExprKind::ConstBlock(anon_const)
};
Ok(self.mk_expr_with_attrs(span.to(blk_span), kind, attrs))
}
/// Parses mutability (`mut` or nothing).

View File

@ -631,15 +631,6 @@ impl<'a> Parser<'a> {
ident,
indentation,
});
// help: wrap the expr in a `const { expr }`
// FIXME(inline_const_pat): once stabilized, remove this check and remove the `(requires #[feature(inline_const_pat)])` note from the message
if self.parser.psess.unstable_features.is_nightly_build() {
err.subdiagnostic(UnexpectedExpressionInPatternSugg::InlineConst {
start_span: expr_span.shrink_to_lo(),
end_span: expr_span.shrink_to_hi(),
});
}
},
);
}

View File

@ -1,22 +0,0 @@
# `inline_const_pat`
The tracking issue for this feature is: [#76001]
------
This feature allows you to use inline constant expressions in pattern position:
```rust
#![feature(inline_const_pat)]
const fn one() -> i32 { 1 }
let some_int = 3;
match some_int {
const { 1 + 2 } => println!("Matched 1 + 2"),
const { one() } => println!("Matched const fn returning 1"),
_ => println!("Didn't match anything :("),
}
```
[#76001]: https://github.com/rust-lang/rust/issues/76001

View File

@ -246,7 +246,6 @@ fn emit_redundant_guards<'tcx>(
fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
for_each_expr_without_closures(expr, |expr| {
if match expr.kind {
ExprKind::ConstBlock(..) => cx.tcx.features().inline_const_pat(),
ExprKind::Call(c, ..) if let ExprKind::Path(qpath) = c.kind => {
// Allow ctors
matches!(cx.qpath_res(&qpath, c.hir_id), Res::Def(DefKind::Ctor(..), ..))

View File

@ -2876,7 +2876,6 @@ ui/macros/rfc-3086-metavar-expr/issue-111904.rs
ui/malformed/issue-107423-unused-delim-only-one-no-pair.rs
ui/malformed/issue-69341-malformed-derive-inert.rs
ui/marker_trait_attr/issue-61651-type-mismatch.rs
ui/match/issue-112438.rs
ui/match/issue-113012.rs
ui/match/issue-11319.rs
ui/match/issue-114691.rs

View File

@ -1,9 +0,0 @@
#![feature(inline_const_pat)]
fn main() {
match () {
const { (|| {})() } => {}
//~^ ERROR cannot call non-const closure in constants
//~| ERROR could not evaluate constant pattern
}
}

View File

@ -1,18 +0,0 @@
error[E0015]: cannot call non-const closure in constants
--> $DIR/invalid-inline-const-in-match-arm.rs:5:17
|
LL | const { (|| {})() } => {}
| ^^^^^^^^^
|
= note: closures need an RFC before allowed to be called in constants
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: could not evaluate constant pattern
--> $DIR/invalid-inline-const-in-match-arm.rs:5:9
|
LL | const { (|| {})() } => {}
| ^^^^^^^^^^^^^^^^^^^ could not evaluate constant
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0015`.

View File

@ -1,4 +0,0 @@
fn main() {
let const { () } = ();
//~^ ERROR inline-const in pattern position is experimental [E0658]
}

View File

@ -1,13 +0,0 @@
error[E0658]: inline-const in pattern position is experimental
--> $DIR/feature-gate-inline_const_pat.rs:2:9
|
LL | let const { () } = ();
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,7 +1,5 @@
//@ run-pass
#![allow(non_contiguous_range_endpoints)]
#![feature(inline_const_pat)]
fn main() {
let mut if_lettable = vec![];
let mut first_or = vec![];
@ -16,7 +14,6 @@ fn main() {
match x {
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),
@ -25,6 +22,6 @@ fn main() {
assert_eq!(if_lettable, [-1, 0, 2, 4]);
assert_eq!(first_or, [-3, -2, -1, 1]);
assert_eq!(or_two, [0, 2, 3, 4, 6]);
assert_eq!(range_from, [-5, -4, 7]);
assert_eq!(range_from, [-5, -4, 5, 7]);
assert_eq!(bottom, [-7, -6]);
}

View File

@ -18,8 +18,6 @@ fn main() {
//~^ error: expected a pattern range bound, found an expression
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
//~^ error: inline-const in pattern position is experimental [E0658]
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),

View File

@ -11,10 +11,6 @@ LL + const VAL: /* Type */ = 5+1;
LL ~ match x as i32 {
LL ~ 0..VAL => errors_only.push(x),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 0..const { 5+1 } => errors_only.push(x),
| +++++++ +
error[E0408]: variable `n` is not bound in all patterns
--> $DIR/range_pat_interactions1.rs:10:25
@ -24,17 +20,6 @@ LL | if let n @ 2..3|4 = x {
| |
| variable not in all patterns
error[E0658]: inline-const in pattern position is experimental
--> $DIR/range_pat_interactions1.rs:21:20
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0408, E0658.
For more information about an error, try `rustc --explain E0408`.
For more information about this error, try `rustc --explain E0408`.

View File

@ -1,22 +0,0 @@
fn main() {
let mut first_or = Vec::<i32>::new();
let mut or_two = Vec::<i32>::new();
let mut range_from = Vec::<i32>::new();
let mut bottom = Vec::<i32>::new();
let mut errors_only = Vec::<i32>::new();
for x in -9 + 1..=(9 - 2) {
match x as i32 {
0..=(5+1) => errors_only.push(x),
//~^ error: expected a pattern range bound, found an expression
//~| error: range pattern bounds cannot have parentheses
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
//~^ error: inline-const in pattern position is experimental
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),
}
}
}

View File

@ -1,43 +0,0 @@
error: range pattern bounds cannot have parentheses
--> $DIR/range_pat_interactions2.rs:10:17
|
LL | 0..=(5+1) => errors_only.push(x),
| ^ ^
|
help: remove these parentheses
|
LL - 0..=(5+1) => errors_only.push(x),
LL + 0..=5+1 => errors_only.push(x),
|
error: expected a pattern range bound, found an expression
--> $DIR/range_pat_interactions2.rs:10:18
|
LL | 0..=(5+1) => errors_only.push(x),
| ^^^ not a pattern
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
help: consider extracting the expression into a `const`
|
LL + const VAL: /* Type */ = 5+1;
LL ~ match x as i32 {
LL ~ 0..=(VAL) => errors_only.push(x),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 0..=(const { 5+1 }) => errors_only.push(x),
| +++++++ +
error[E0658]: inline-const in pattern position is experimental
--> $DIR/range_pat_interactions2.rs:15:20
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,19 +0,0 @@
fn main() {
let mut first_or = Vec::<i32>::new();
let mut or_two = Vec::<i32>::new();
let mut range_from = Vec::<i32>::new();
let mut bottom = Vec::<i32>::new();
for x in -9 + 1..=(9 - 2) {
match x as i32 {
8.. => bottom.push(x),
1 | -3..0 => first_or.push(x),
y @ (0..5 | 6) => or_two.push(y),
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
//~^ inline-const in pattern position is experimental
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
y => bottom.push(y),
}
}
}

View File

@ -1,13 +0,0 @@
error[E0658]: inline-const in pattern position is experimental
--> $DIR/range_pat_interactions3.rs:12:20
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,16 +0,0 @@
//@ compile-flags: -Zlint-mir
//@ check-pass
#![feature(inline_const_pat)]
fn main() {
match 1 {
const {
|| match 0 {
x => 0,
};
0
} => (),
_ => (),
}
}

View File

@ -1,18 +0,0 @@
//! This test used to ICE because const blocks didn't have a body
//! anymore, making a lot of logic very fragile around handling the
//! HIR of a const block.
//! https://github.com/rust-lang/rust/issues/125846
//@ check-pass
#![feature(inline_const_pat)]
fn main() {
match 0 {
const {
let a = 10_usize;
*&a
}
| _ => {}
}
}

View File

@ -1,28 +0,0 @@
#![feature(inline_const_pat)]
// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter
fn foo<const V: usize>() {
match 0 {
const { V } => {},
//~^ ERROR constant pattern cannot depend on generic parameters
_ => {},
}
}
const fn f(x: usize) -> usize {
x + 1
}
fn bar<const V: usize>() {
match 0 {
const { f(V) } => {},
//~^ ERROR constant pattern cannot depend on generic parameters
_ => {},
}
}
fn main() {
foo::<1>();
bar::<1>();
}

View File

@ -1,15 +0,0 @@
error[E0158]: constant pattern cannot depend on generic parameters
--> $DIR/const-match-pat-generic.rs:7:9
|
LL | const { V } => {},
| ^^^^^^^^^^^ `const` depends on a generic parameter
error[E0158]: constant pattern cannot depend on generic parameters
--> $DIR/const-match-pat-generic.rs:19:9
|
LL | const { f(V) } => {},
| ^^^^^^^^^^^^^^ `const` depends on a generic parameter
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0158`.

View File

@ -1,11 +0,0 @@
//@ check-pass
#![feature(inline_const_pat)]
fn main() {
match 1u64 {
0 => (),
const { 0 + 1 } => (),
const { 2 - 1 } ..= const { u64::MAX } => (),
}
}

View File

@ -1,47 +0,0 @@
#![feature(inline_const_pat)]
use std::marker::PhantomData;
#[derive(PartialEq, Eq)]
pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
#[derive(PartialEq, Eq)]
pub struct CovariantRef<'a, T: ?Sized>(&'a T);
impl<'a, T: ?Sized> InvariantRef<'a, T> {
pub const fn new(r: &'a T) -> Self {
InvariantRef(r, PhantomData)
}
}
impl<'a> InvariantRef<'a, ()> {
pub const NEW: Self = InvariantRef::new(&());
}
impl<'a> CovariantRef<'a, ()> {
pub const NEW: Self = CovariantRef(&());
}
fn match_invariant_ref<'a>() {
let y = ();
match InvariantRef::new(&y) {
//~^ ERROR `y` does not live long enough [E0597]
const { InvariantRef::<'a>::NEW } => (),
}
}
fn match_covariant_ref<'a>() {
// Unclear if we should error here (should we be able to subtype the type of
// `y.0`), but using the associated const directly in the pattern also
// errors.
let y: (CovariantRef<'static, _>,) = (CovariantRef(&()),);
//~^ ERROR lifetime may not live long enough
match y.0 {
const { CovariantRef::<'a>::NEW } => (),
}
}
fn main() {
match_invariant_ref();
match_covariant_ref();
}

View File

@ -1,28 +0,0 @@
error[E0597]: `y` does not live long enough
--> $DIR/const-match-pat-lifetime-err.rs:27:29
|
LL | fn match_invariant_ref<'a>() {
| -- lifetime `'a` defined here
LL | let y = ();
| - binding `y` declared here
LL | match InvariantRef::new(&y) {
| ^^ borrowed value does not live long enough
LL |
LL | const { InvariantRef::<'a>::NEW } => (),
| ----------------------- using this value as a constant requires that `y` is borrowed for `'a`
LL | }
LL | }
| - `y` dropped here while still borrowed
error: lifetime may not live long enough
--> $DIR/const-match-pat-lifetime-err.rs:37:12
|
LL | fn match_covariant_ref<'a>() {
| -- lifetime `'a` defined here
...
LL | let y: (CovariantRef<'static, _>,) = (CovariantRef(&()),);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0597`.

View File

@ -1,34 +0,0 @@
//@ run-pass
#![feature(inline_const_pat)]
use std::marker::PhantomData;
// rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid"
fn issue_78174() {
match "foo" {
const { concat!("fo", "o") } => (),
_ => unreachable!(),
}
}
#[derive(PartialEq, Eq)]
pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
impl<'a, T: ?Sized> InvariantRef<'a, T> {
pub const fn new(r: &'a T) -> Self {
InvariantRef(r, PhantomData)
}
}
fn match_invariant_ref<'a>() {
match const { InvariantRef::<'a, _>::new(&()) } {
const { InvariantRef::<'a, ()>::new(&()) } => {
}
}
}
fn main() {
issue_78174();
match_invariant_ref();
}

View File

@ -1,38 +0,0 @@
//@ build-pass
#![feature(inline_const_pat)]
fn main() {
const N: u32 = 10;
let x: u32 = 3;
match x {
1 ..= const { N + 1 } => {},
_ => {},
}
match x {
const { N - 1 } ..= 10 => {},
_ => {},
}
match x {
const { N - 1 } ..= const { N + 1 } => {},
_ => {},
}
match x {
.. const { N + 1 } => {},
_ => {},
}
match x {
const { N - 1 } .. => {},
_ => {},
}
match x {
..= const { N + 1 } => {},
_ => {}
}
}

View File

@ -1,20 +0,0 @@
//@ run-pass
#![feature(inline_const_pat)]
const MMIO_BIT1: u8 = 4;
const MMIO_BIT2: u8 = 5;
fn main() {
let s = match read_mmio() {
0 => "FOO",
const { 1 << MMIO_BIT1 } => "BAR",
const { 1 << MMIO_BIT2 } => "BAZ",
_ => unreachable!(),
};
assert_eq!("BAZ", s);
}
fn read_mmio() -> i32 {
1 << 5
}

View File

@ -0,0 +1,11 @@
// While `feature(inline_const_pat)` has been removed from the
// compiler, we should still make sure that the resulting error
// message is acceptable.
fn main() {
match 1 {
const { 1 + 7 } => {}
//~^ `inline_const_pat` has been removed
2 => {}
_ => {}
}
}

View File

@ -0,0 +1,10 @@
error: `inline_const_pat` has been removed
--> $DIR/in-pat-recovery.rs:6:15
|
LL | const { 1 + 7 } => {}
| ^^^^^^^^^
|
= help: use a named `const`-item or an `if`-guard instead
error: aborting due to 1 previous error

View File

@ -1,12 +0,0 @@
#![feature(inline_const_pat)]
fn uwu() {}
fn main() {
let x = [];
match x[123] {
const { uwu } => {}
//~^ ERROR `fn() {uwu}` cannot be used in patterns
_ => {}
}
}

View File

@ -1,8 +0,0 @@
error: fn item `fn() {uwu}` cannot be used in patterns
--> $DIR/pat-match-fndef.rs:8:9
|
LL | const { uwu } => {}
| ^^^^^^^^^^^^^ fn item can't be used in patterns
error: aborting due to 1 previous error

View File

@ -1,22 +0,0 @@
#![feature(inline_const_pat)]
const unsafe fn require_unsafe() -> usize {
1
}
fn main() {
match () {
const {
require_unsafe();
//~^ ERROR [E0133]
} => (),
}
match 1 {
const {
require_unsafe()
//~^ ERROR [E0133]
}..=4 => (),
_ => (),
}
}

View File

@ -1,19 +0,0 @@
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
--> $DIR/pat-unsafe-err.rs:10:13
|
LL | require_unsafe();
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
--> $DIR/pat-unsafe-err.rs:17:13
|
LL | require_unsafe()
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,29 +0,0 @@
//@ check-pass
#![warn(unused_unsafe)]
#![feature(inline_const_pat)]
const unsafe fn require_unsafe() -> usize {
1
}
fn main() {
unsafe {
match () {
const {
require_unsafe();
unsafe {}
//~^ WARNING unnecessary `unsafe` block
} => (),
}
match 1 {
const {
unsafe {}
//~^ WARNING unnecessary `unsafe` block
require_unsafe()
}..=4 => (),
_ => (),
}
}
}

View File

@ -1,20 +0,0 @@
warning: unnecessary `unsafe` block
--> $DIR/pat-unsafe.rs:15:17
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/pat-unsafe.rs:3:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^
warning: unnecessary `unsafe` block
--> $DIR/pat-unsafe.rs:22:17
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
warning: 2 warnings emitted

View File

@ -1,44 +0,0 @@
//@ check-pass
#![feature(inline_const_pat)]
#![deny(dead_code)]
const fn one() -> i32 {
1
}
const fn two() -> i32 {
2
}
const fn three() -> i32 {
3
}
fn inline_const() {
// rust-lang/rust#78171: dead_code lint triggers even though function is used in const pattern
match 1 {
const { one() } => {}
_ => {}
}
}
fn inline_const_range() {
match 1 {
1 ..= const { two() } => {}
_ => {}
}
}
struct S<const C: i32>;
fn const_generic_arg() {
match S::<3> {
S::<{three()}> => {}
}
}
fn main() {
inline_const();
inline_const_range();
const_generic_arg();
}

View File

@ -1,10 +0,0 @@
//@ run-pass
#![feature(inline_const_pat)]
#![allow(dead_code)]
fn foo<const V: usize>() {
match 0 {
const { 1 << 5 } | _ => {}
}
}
fn main() {}

View File

@ -1,4 +1,3 @@
#![feature(inline_const_pat)]
#![allow(overlapping_range_endpoints)]
fn main() {
@ -17,8 +16,6 @@ fn main() {
// There isn't really a way to detect these
1..=TOO_BIG => {}
//~^ ERROR lower range bound must be less than or equal to upper
1..=const { 256 } => {}
//~^ ERROR lower range bound must be less than or equal to upper
_ => {}
}

View File

@ -1,59 +1,53 @@
error: literal out of range for `u8`
--> $DIR/validate-range-endpoints.rs:7:12
--> $DIR/validate-range-endpoints.rs:6:12
|
LL | 1..257 => {}
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`
error: literal out of range for `u8`
--> $DIR/validate-range-endpoints.rs:9:13
--> $DIR/validate-range-endpoints.rs:8:13
|
LL | 1..=256 => {}
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`
error[E0030]: lower range bound must be less than or equal to upper
--> $DIR/validate-range-endpoints.rs:18:9
--> $DIR/validate-range-endpoints.rs:17:9
|
LL | 1..=TOO_BIG => {}
| ^^^^^^^^^^^ lower bound larger than upper bound
error[E0030]: lower range bound must be less than or equal to upper
--> $DIR/validate-range-endpoints.rs:20:9
|
LL | 1..=const { 256 } => {}
| ^^^^^^^^^^^^^^^^^ lower bound larger than upper bound
error: literal out of range for `u64`
--> $DIR/validate-range-endpoints.rs:26:32
--> $DIR/validate-range-endpoints.rs:23:32
|
LL | 10000000000000000000..=99999999999999999999 => {}
| ^^^^^^^^^^^^^^^^^^^^ this value does not fit into the type `u64` whose range is `0..=18446744073709551615`
error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:32:12
--> $DIR/validate-range-endpoints.rs:29:12
|
LL | 0..129 => {}
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`
error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:34:13
--> $DIR/validate-range-endpoints.rs:31:13
|
LL | 0..=128 => {}
| ^^^ this value does not fit into the type `i8` whose range is `-128..=127`
error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:36:9
--> $DIR/validate-range-endpoints.rs:33:9
|
LL | -129..0 => {}
| ^^^^ this value does not fit into the type `i8` whose range is `-128..=127`
error: literal out of range for `i8`
--> $DIR/validate-range-endpoints.rs:38:9
--> $DIR/validate-range-endpoints.rs:35:9
|
LL | -10000..=-20 => {}
| ^^^^^^ this value does not fit into the type `i8` whose range is `-128..=127`
error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
--> $DIR/validate-range-endpoints.rs:49:11
--> $DIR/validate-range-endpoints.rs:46:11
|
LL | match 0i8 {
| ^^^ patterns `i8::MIN..=-17_i8` and `1_i8..=i8::MAX` not covered
@ -66,7 +60,7 @@ LL + i8::MIN..=-17_i8 | 1_i8..=i8::MAX => todo!()
|
error[E0004]: non-exhaustive patterns: `i8::MIN..=-17_i8` not covered
--> $DIR/validate-range-endpoints.rs:53:11
--> $DIR/validate-range-endpoints.rs:50:11
|
LL | match 0i8 {
| ^^^ pattern `i8::MIN..=-17_i8` not covered
@ -78,7 +72,7 @@ LL ~ -10000.. => {},
LL + i8::MIN..=-17_i8 => todo!()
|
error: aborting due to 11 previous errors
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0004, E0030.
For more information about an error, try `rustc --explain E0004`.

View File

@ -16,10 +16,6 @@ LL + const VAL: /* Type */ = tmp[0];
LL ~ match z {
LL ~ VAL => {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { tmp[0] } => {}
| +++++++ +
error: aborting due to 1 previous error

View File

@ -17,10 +17,6 @@ LL ~ match 0 {
LL | x => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.y } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:6:9
@ -42,10 +38,6 @@ LL | x => (),
LL | x.y => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:7:9
@ -68,10 +60,6 @@ LL | x.y => (),
LL | x.0 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x._0 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:8:9
@ -94,10 +82,6 @@ LL | x => (),
LL | x._0 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0.1 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:9:9
@ -120,10 +104,6 @@ LL | x => (),
LL | x.0.1 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.4.y.17.__z } => (),
| +++++++ +
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.`
--> $DIR/recover-pat-exprs.rs:12:12
@ -173,10 +153,6 @@ LL + const VAL: /* Type */ = x[0];
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x[0] } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:24:9
@ -197,10 +173,6 @@ LL ~ match 0 {
LL | x[0] => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x[..] } => (),
| +++++++ +
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
--> $DIR/recover-pat-exprs.rs:27:12
@ -247,10 +219,6 @@ LL + const VAL: /* Type */ = x.f();
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:38:9
@ -271,10 +239,6 @@ LL ~ match 0 {
LL | x.f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x._f() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:39:9
@ -296,10 +260,6 @@ LL | x.f() => (),
LL | x._f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x? } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:40:9
@ -322,10 +282,6 @@ LL | x._f() => (),
LL | x? => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { ().f() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:41:9
@ -348,10 +304,6 @@ LL | x.f() => (),
LL | ().f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { (0, x)?.f() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:42:9
@ -374,10 +326,6 @@ LL | x.f() => (),
LL | (0, x)?.f() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f().g() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:43:9
@ -400,10 +348,6 @@ LL | x.f() => (),
LL | x.f().g() => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0.f()?.g()?? } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:50:9
@ -423,10 +367,6 @@ LL + const VAL: /* Type */ = x as usize;
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x as usize } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:51:9
@ -447,10 +387,6 @@ LL ~ match 0 {
LL | x as usize => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0 as usize } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:52:9
@ -472,10 +408,6 @@ LL | x as usize => (),
LL | 0 as usize => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.f().0.4 as f32 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:59:9
@ -495,10 +427,6 @@ LL + const VAL: /* Type */ = 1 + 1;
LL ~ match 0 {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 1 + 1 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:60:9
@ -519,10 +447,6 @@ LL ~ match 0 {
LL | 1 + 1 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { (1 + 2) * 3 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:63:9
@ -545,10 +469,6 @@ LL | 1 + 1 => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 > 2 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:64:9
@ -571,10 +491,6 @@ LL | 1 + 1 => (),
LL | x.0 > 2 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { x.0 == 2 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:69:13
@ -594,10 +510,6 @@ LL + const VAL: /* Type */ = y.0 > 2;
LL ~ match (0, 0) {
LL ~ (x, VAL) if x != 0 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (x, const { y.0 > 2 }) if x != 0 => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:70:13
@ -618,10 +530,6 @@ LL ~ match (0, 0) {
LL | (x, y.0 > 2) if x != 0 => (),
LL ~ (x, VAL) if x != 0 || x != 1 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (x, const { y.0 > 2 }) if x != 0 || x != 1 => (),
| +++++++ +
error: left-hand side of `@` must be a binding
--> $DIR/recover-pat-exprs.rs:83:9
@ -658,10 +566,6 @@ LL + const VAL: /* Type */ = u8::MAX.abs();
LL ~ match u8::MAX {
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { u8::MAX.abs() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:86:17
@ -684,10 +588,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ z @ w @ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | z @ w @ const { v.u() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:88:9
@ -710,10 +610,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { y.ilog(3) } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:90:9
@ -736,10 +632,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { n + 1 } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:92:10
@ -762,10 +654,6 @@ LL | u8::MAX.abs() => (),
LL |
LL ~ (VAL) => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { "".f() + 14 * 8 }) => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:95:9
@ -788,10 +676,6 @@ LL | u8::MAX.abs() => (),
LL | 0 | ((1) | 2) | 3 => (),
LL ~ VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { f?() } => (),
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-exprs.rs:101:9

View File

@ -16,10 +16,6 @@ LL + const VAL: /* Type */ = "hi".to_owned();
LL ~ match foo {
LL ~ Foo(VAL) => true,
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | Foo(const { "hi".to_owned() }) => true,
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:14:20
@ -39,10 +35,6 @@ LL + const BAZ: /* Type */ = "hi".to_owned();
LL ~ match bar {
LL ~ Bar { baz: BAZ } => true,
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | Bar { baz: const { "hi".to_owned() } } => true,
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:25:11
@ -62,10 +54,6 @@ LL + const VAL: /* Type */ = "foo".to_string();
LL ~ match foo.as_slice() {
LL ~ &[VAL] => {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | &[const { "foo".to_string() }] => {}
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:36:17
@ -79,10 +67,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = MAGIC.0 as usize;
LL ~ if let Some(VAL) = None::<usize> {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let Some(const { MAGIC.0 as usize }) = None::<usize> {}
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:41:13
@ -96,10 +80,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = -1.some(4);
LL ~ if let (VAL) = (0, Some(4)) {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let (const { -1.some(4) }) = (0, Some(4)) {}
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-issues.rs:44:13
@ -113,10 +93,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = -1.Some(4);
LL ~ if let (VAL) = (0, Some(4)) {}
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let (const { -1.Some(4) }) = (0, Some(4)) {}
| +++++++ +
error: aborting due to 6 previous errors

View File

@ -34,10 +34,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = 1 + 1;
LL ~ let Some(VAL) = x else {
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | let Some(const { 1 + 1 }) = x else {
| +++++++ +
error: expected a pattern, found an expression
--> $DIR/recover-pat-lets.rs:17:17
@ -51,10 +47,6 @@ help: consider extracting the expression into a `const`
LL + const VAL: /* Type */ = 1 + 1;
LL ~ if let Some(VAL) = x {
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | if let Some(const { 1 + 1 }) = x {
| +++++++ +
error: aborting due to 5 previous errors

View File

@ -98,10 +98,6 @@ LL | 0..=1 => (),
LL |
LL ~ ..=VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | ..=const { 1 + 2 } => (),
| +++++++ +
error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:15:10
@ -119,10 +115,6 @@ LL | 0..=1 => (),
LL |
LL ~ (VAL).. => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { -4 + 0 }).. => (),
| +++++++ +
error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:18:10
@ -140,10 +132,6 @@ LL | 0..=1 => (),
LL |
LL ~ (VAL)...1 * 2 => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (const { 1 + 4 })...1 * 2 => (),
| +++++++ +
error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:18:19
@ -161,10 +149,6 @@ LL | 0..=1 => (),
LL |
LL ~ (1 + 4)...VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | (1 + 4)...const { 1 * 2 } => (),
| +++++++ +
error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:24:9
@ -182,10 +166,6 @@ LL | 0..=1 => (),
LL |
LL ~ VAL..="y".z() => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | const { 0.x() }..="y".z() => (),
| +++++++ +
error: expected a pattern range bound, found an expression
--> $DIR/recover-pat-ranges.rs:24:17
@ -203,10 +183,6 @@ LL | 0..=1 => (),
LL |
LL ~ 0.x()..=VAL => (),
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 0.x()..=const { "y".z() } => (),
| +++++++ +
warning: `...` range patterns are deprecated
--> $DIR/recover-pat-ranges.rs:18:16

View File

@ -84,10 +84,6 @@ LL + const VAL: /* Type */ = 2 + _;
LL ~ match 9 {
LL ~ 4..=(VAL) => ()
|
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
|
LL | 4..=(const { 2 + _ }) => ()
| +++++++ +
error: aborting due to 11 previous errors

View File

@ -1,14 +1,29 @@
//@ edition:2021
#![allow(unreachable_code)]
#![feature(const_async_blocks)]
#![feature(inline_const_pat)]
fn main() {
match loop {} {
const { || {} } => {} //~ ERROR cannot be used in patterns
struct AnyOption<T>(T);
impl<T> AnyOption<T> {
const NONE: Option<T> = None;
}
fn uwu() {}
fn defines() {
match Some(uwu) {
AnyOption::<_>::NONE => {}
//~^ ERROR constant of non-structural type
_ => {}
}
match loop {} {
const { async {} } => {} //~ ERROR cannot be used in patterns
match Some(|| {}) {
AnyOption::<_>::NONE => {}
//~^ ERROR constant of non-structural type
_ => {}
}
match Some(async {}) {
AnyOption::<_>::NONE => {}
//~^ ERROR constant of non-structural type
_ => {}
}
}
fn main() {}

View File

@ -1,14 +1,42 @@
error: closure `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:9:9
|
LL | const { || {} } => {}
| ^^^^^^^^^^^^^^^ closure can't be used in patterns
error: `async` block `{async block@$DIR/non-structural-match-types.rs:12:17: 12:22}` cannot be used in patterns
error: constant of non-structural type `Option<fn() {uwu}>` in a pattern
--> $DIR/non-structural-match-types.rs:12:9
|
LL | const { async {} } => {}
| ^^^^^^^^^^^^^^^^^^ `async` block can't be used in patterns
LL | impl<T> AnyOption<T> {
| --------------------
LL | const NONE: Option<T> = None;
| --------------------- constant defined here
...
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
error: aborting due to 2 previous errors
error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:17:16: 17:18}>` in a pattern
--> $DIR/non-structural-match-types.rs:18:9
|
LL | impl<T> AnyOption<T> {
| --------------------
LL | const NONE: Option<T> = None;
| --------------------- constant defined here
...
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
error: constant of non-structural type `Option<{async block@$DIR/non-structural-match-types.rs:23:16: 23:21}>` in a pattern
--> $DIR/non-structural-match-types.rs:24:9
|
LL | impl<T> AnyOption<T> {
| --------------------
LL | const NONE: Option<T> = None;
| --------------------- constant defined here
...
LL | AnyOption::<_>::NONE => {}
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
= note: `ResumeTy` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
error: aborting due to 3 previous errors

View File

@ -1,10 +0,0 @@
#![feature(pattern_types)]
#![feature(pattern_type_macro)]
#![feature(inline_const_pat)]
//@ check-pass
use std::pat::pattern_type;
fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {}
fn main() {}

View File

@ -1,23 +0,0 @@
// Check that ref mut patterns within a const pattern don't get considered
// unsafe because they're within a pattern for a layout constrained stuct.
//@ check-pass
#![feature(rustc_attrs)]
#![feature(inline_const_pat)]
#[rustc_layout_scalar_valid_range_start(3)]
struct Gt2(i32);
fn main() {
match unsafe { Gt2(5) } {
Gt2(
const {
|| match () {
ref mut y => (),
};
4
},
) => (),
_ => (),
}
}