Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bf1848d

Browse files
committed
Add tests
1 parent e0c38af commit bf1848d

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// check-pass
2+
//
3+
// Check that we don't ignore private fields in usefulness checking
4+
#![deny(unreachable_patterns)]
5+
6+
mod inner {
7+
#[derive(PartialEq, Eq)]
8+
pub struct PrivateField {
9+
pub x: bool,
10+
y: bool,
11+
}
12+
13+
pub const FOO: PrivateField = PrivateField { x: true, y: true };
14+
pub const BAR: PrivateField = PrivateField { x: true, y: false };
15+
}
16+
use inner::*;
17+
18+
fn main() {
19+
match FOO {
20+
FOO => {}
21+
BAR => {}
22+
_ => {}
23+
}
24+
25+
match FOO {
26+
FOO => {}
27+
PrivateField { x: true, .. } => {}
28+
_ => {}
29+
}
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This used to ICE in exhaustiveness checking. Explanation here:
2+
// https://github.com/rust-lang/rust/issues/82772#issuecomment-905946768
3+
fn main() {
4+
let Box { 1: _, .. }: Box<()>; //~ ERROR field `1` of
5+
let Box { .. }: Box<()>;
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0451]: field `1` of struct `Box` is private
2+
--> $DIR/issue-82772-match-box-as-struct.rs:4:15
3+
|
4+
LL | let Box { 1: _, .. }: Box<()>;
5+
| ^^^^ private field
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0451`.

0 commit comments

Comments
 (0)