Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. -- <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
Seems to be the indicated function:
.
Assigning as discussed as part of the and removing . label -I-prioritize +P-medium
Oh this is ugly x) Reading the PR, the problem is that there are two ways to match a Box: via a box-pattern or via . But we can't know which will be used based on the type only. Current code assumes box-patterns, hence the error. The PR works because luckily all the fields of are private. If you tried pattern-matching within the module that defines , you'd get crazy results like (actually wouldn't even typecheck): We'll need to figure out a real solution when we implement generalized Deref patterns...
in that case we should open a new ticket for that work, tagged something like or something.

Discussion:
match &mut fields { Fields::Vec(pats) => { for (i, pat) in new_pats { <del> pats[i] = pat </del> <ins> if let Some(p) = pats.get_mut(i) { *p = pat; } </ins> } } Fields::Filtered { fields, .. } => {

// aux-build:struct_variant_privacy.rs extern crate struct_variant_privacy; <del> fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private </del> <ins> fn f(b: struct_variant_privacy::Bar) { //~^ ERROR enum `Bar` is private </ins> match b { struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private }

| ^^^^^^^^ error[E0603]: enum `Bar` is private <del> --> $DIR/struct-variant-privacy-xc.rs:6:33 </del> <ins> --> $DIR/struct-variant-privacy-xc.rs:7:33 </ins> | LL |         struct_variant_privacy::Bar::Baz { a: _a } => {} |                                 ^^^ private enum

mod foo { enum Bar { <del> Baz { a: isize } </del> <ins> Baz { a: isize }, </ins> } } <del> fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private </del> <ins> fn f(b: foo::Bar) { //~^ ERROR enum `Bar` is private </ins> match b { foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private }

|     ^^^^^^^^ error[E0603]: enum `Bar` is private <del> --> $DIR/struct-variant-privacy.rs:9:14 </del> <ins> --> $DIR/struct-variant-privacy.rs:10:14 </ins> | LL |         foo::Bar::Baz { a: _a } => {} |              ^^^ private enum

<ins> // edition:2018 fn main() { use a::ModPrivateStruct; let Box { 0: _, .. }: Box<()>; //~ ERROR field `0` of let Box { 1: _, .. }: Box<()>; //~ ERROR field `1` of let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); //~ ERROR field `1` of } mod a { #[derive(Default)] pub struct ModPrivateStruct(u8, u8); } </ins>

<ins> error[E0451]: field `0` of struct `Box` is private --> $DIR/issue-82772.rs:5:15 | LL |     let Box { 0: _, .. }: Box<()>; |               ^^^^ private field error[E0451]: field `1` of struct `Box` is private --> $DIR/issue-82772.rs:6:15 | LL |     let Box { 1: _, .. }: Box<()>; |               ^^^^ private field error[E0451]: field `1` of struct `ModPrivateStruct` is private --> $DIR/issue-82772.rs:7:28 | LL |     let ModPrivateStruct { 1: _, .. } = ModPrivateStruct::default(); |                            ^^^^ private field error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0451`. </ins>