diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2023-12-22 16:38:20 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2024-01-05 10:00:59 +0000 |
| commit | 7832ebbd4ff090aced6e338ff92e1353bbe88f76 (patch) | |
| tree | 54413fdab6e25c05d2d46fd4a14c15014801e890 /tests/ui/unsafe | |
| parent | 26f48b4cba17a6f7d321bccaa86b345596923763 (diff) | |
| download | rust-7832ebbd4ff090aced6e338ff92e1353bbe88f76.tar.gz rust-7832ebbd4ff090aced6e338ff92e1353bbe88f76.zip | |
Handle context for const patterns correctly
Diffstat (limited to 'tests/ui/unsafe')
| -rw-r--r-- | tests/ui/unsafe/const_pat_in_layout_restricted.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/unsafe/const_pat_in_layout_restricted.rs b/tests/ui/unsafe/const_pat_in_layout_restricted.rs new file mode 100644 index 00000000000..5bc7a7113e4 --- /dev/null +++ b/tests/ui/unsafe/const_pat_in_layout_restricted.rs @@ -0,0 +1,24 @@ +// 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 + +#![allow(incomplete_features)] +#![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 + }, + ) => (), + _ => (), + } +} |
