rust/compiler/rustc_pattern_analysis/src
Guillaume Gomez 9df7f26b1b
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`
2024-02-29 17:08:37 +01:00
..
constructor.rs Rollup merge of #121000 - Nadrieril:keep_all_fields, r=compiler-errors 2024-02-29 17:08:37 +01:00
errors.rs Rename DiagnosticBuilder as Diag. 2024-02-28 08:55:35 +11:00
lib.rs Rename Skip to PrivateUninhabited 2024-02-28 17:56:01 +01:00
lints.rs Remove dead args from functions 2024-02-02 22:47:26 +00:00
pat.rs Rename Skip to PrivateUninhabited 2024-02-28 17:56:01 +01:00
pat_column.rs Rollup merge of #120331 - Nadrieril:no-arena, r=compiler-errors 2024-02-06 22:45:40 +01:00
rustc.rs Rename Skip to PrivateUninhabited 2024-02-28 17:56:01 +01:00
usefulness.rs Rename Skip to PrivateUninhabited 2024-02-28 17:56:01 +01:00