about summary refs log tree commit diff
path: root/tests/debuginfo/enum-thinlto.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-16 20:30:42 +0000
committerbors <bors@rust-lang.org>2023-02-16 20:30:42 +0000
commit6444621c101151b49a5e7c9854d602483000e337 (patch)
treea8916b1c79f2a138e80af52bbea206ba5f25a9f1 /tests/debuginfo/enum-thinlto.rs
parenteac0bd9da39154f53d3251b19e6d5690332a5529 (diff)
parent09d3097734883a78b69f111a9ecf2154c7da9ce7 (diff)
downloadrust-6444621c101151b49a5e7c9854d602483000e337.tar.gz
rust-6444621c101151b49a5e7c9854d602483000e337.zip
Auto merge of #10336 - samueltardieu:issue-10241, r=llogiq
manual_let_else: do not suggest semantically different replacements

The problem is that this lint does not consider the possibility that the divergent branch can come first and that the patterns may overlap. This led to incorrect suggestions, previously registered as correct in the tests themselves:

```rust
let v = match build_enum() {
    _ => continue,
    Variant::Bar(v) | Variant::Baz(v) => v,
};
```

had a `let Variant::Bar(v) | Variant::Baz(v) = v else { continue; }` suggestion, which is obviously wrong as the original code `continue`s in any case. Issue #10241 gives another example.

The code now checks that the divergent branch comes second. It could be extended later (I've added a TODO) to check for non-overlapping patterns.

Fixes #10241.

changelog: [`manual_let_else`] do not suggest non equivalent replacements in `match`
Diffstat (limited to 'tests/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions