forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle context for const patterns correctly
- Loading branch information
1 parent
26f48b4
commit 7832ebb
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}, | ||
) => (), | ||
_ => (), | ||
} | ||
} |