Rollup merge of #78116 - spastorino:inline-const-in-range-pat, r=petrochenkov
Make inline const work in range patterns Fixes #78108 which is a follow up of https://github.com/rust-lang/rust/pull/77124 r? @petrochenkov
This commit is contained in:
commit
982c4b3081
6 changed files with 61 additions and 14 deletions
38
src/test/ui/inline-const/const-match-pat-range.rs
Normal file
38
src/test/ui/inline-const/const-match-pat-range.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// build-pass
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(inline_const, half_open_range_patterns, exclusive_range_pattern)]
|
||||
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 } => {},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,4 +13,4 @@
|
|||
|
||||
fn f() { |[](* }
|
||||
//~^ ERROR expected one of `,` or `:`, found `(`
|
||||
//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `const`, `mut`, `ref`, `|`, identifier, or path, found `*`
|
||||
//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error: expected one of `,` or `:`, found `(`
|
|||
LL | fn f() { |[](* }
|
||||
| ^ expected one of `,` or `:`
|
||||
|
||||
error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `const`, `mut`, `ref`, `|`, identifier, or path, found `*`
|
||||
error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
|
||||
--> $DIR/issue-66357-unexpected-unreachable.rs:14:14
|
||||
|
|
||||
LL | fn f() { |[](* }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue