rust/tests/ui/pattern/usefulness/const-private-fields.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
577 B
Rust
Raw Normal View History

2021-08-25 15:58:49 -05:00
// 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, .. } => {}
_ => {}
}
}