Skip to content

Commit 4426dff

Browse files
Rollup merge of #121000 - Nadrieril:keep_all_fields, r=compiler-errors
pattern_analysis: rework how we hide empty private fields Consider this: ```rust mod foo { pub struct Bar { pub a: bool, b: !, } } fn match_a_bar(bar: foo::Bar) -> bool { match bar { Bar { a, .. } => a, } } ``` Because the field `b` is private, matches outside the module are not allowed to observe the fact that `Bar` is empty. In particular `match bar {}` is valid within the module `foo` but an error outside (assuming `exhaustive_patterns`). We currently handle this by hiding the field `b` when it's both private and empty. This means that the pattern `Bar { a, .. }` is lowered to `Bar(a, _)` if we're inside of `foo` and to `Bar(a)` outside. This involves a bit of a dance to keep field indices straight. But most importantly this makes pattern lowering depend on the module. In this PR, I instead do nothing special when lowering. Only during analysis do we track whether a place must be skipped. r? `@compiler-errors`
2 parents 4778310 + 51bf6b8 commit 4426dff

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)