9df7f26b1b
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` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
messages.ftl |