Add tests
This commit is contained in:
parent
e0c38af27c
commit
bf1848d8a5
30
src/test/ui/pattern/usefulness/const-private-fields.rs
Normal file
30
src/test/ui/pattern/usefulness/const-private-fields.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// check-pass
|
||||
//
|
||||
// Check that we don't ignore private fields in usefulness checking
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
mod inner {
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct PrivateField {
|
||||
pub x: bool,
|
||||
y: bool,
|
||||
}
|
||||
|
||||
pub const FOO: PrivateField = PrivateField { x: true, y: true };
|
||||
pub const BAR: PrivateField = PrivateField { x: true, y: false };
|
||||
}
|
||||
use inner::*;
|
||||
|
||||
fn main() {
|
||||
match FOO {
|
||||
FOO => {}
|
||||
BAR => {}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match FOO {
|
||||
FOO => {}
|
||||
PrivateField { x: true, .. } => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
// This used to ICE in exhaustiveness checking. Explanation here:
|
||||
// https://github.com/rust-lang/rust/issues/82772#issuecomment-905946768
|
||||
fn main() {
|
||||
let Box { 1: _, .. }: Box<()>; //~ ERROR field `1` of
|
||||
let Box { .. }: Box<()>;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
error[E0451]: field `1` of struct `Box` is private
|
||||
--> $DIR/issue-82772-match-box-as-struct.rs:4:15
|
||||
|
|
||||
LL | let Box { 1: _, .. }: Box<()>;
|
||||
| ^^^^ private field
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0451`.
|
Loading…
Reference in New Issue
Block a user