diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-02-29 17:08:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 17:08:37 +0100 |
| commit | 9df7f26b1b0b3cfe7dc8224514d1685d11b1e495 (patch) | |
| tree | 0a9bed0e22c89fb8ca780d823177872a7f9bcc6f /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | 36bd9ef5a841a41a1889ce0c74e1bacc6874dafc (diff) | |
| parent | c918893b63022c1d810a71e8b7fa211b6aecd782 (diff) | |
| download | rust-9df7f26b1b0b3cfe7dc8224514d1685d11b1e495.tar.gz rust-9df7f26b1b0b3cfe7dc8224514d1685d11b1e495.zip | |
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`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
0 files changed, 0 insertions, 0 deletions
