about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/mod.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-11-21 09:55:16 +0100
committerGitHub <noreply@github.com>2021-11-21 09:55:16 +0100
commita54eae94a019a4128265413f3799b8d93a81c2e3 (patch)
tree36dcdf00f3b274fcaa32a36afeb30af58af07cc6 /compiler/rustc_mir_transform/src/coverage/mod.rs
parent3eb30b8e7faa436e0dfc673f2642b8ebad45a519 (diff)
parent01b24045faebc1d0d9f42f355e536df6fc693e49 (diff)
downloadrust-a54eae94a019a4128265413f3799b8d93a81c2e3.tar.gz
rust-a54eae94a019a4128265413f3799b8d93a81c2e3.zip
Rollup merge of #91098 - compiler-errors:issue-91058, r=estebank
Don't suggest certain fixups (`.field`, `.await`, etc) when reporting errors while matching on arrays

When we have a type mismatch with a `cause.code` that is an `ObligationCauseCode::Pattern`, skip suggesting fixes like adding `.await` or accessing a struct's `.field` if the pattern's `root_ty` differs from the `expected` ty. This occurs in situations like this:

```rust
struct S(());

fn main() {
    let array = [S(())];

    match array {
        [()] => {}
        _ => {}
    }
}
```

I think what's happening here is a layer of `[_; N]` is peeled off of both types and we end up seeing the mismatch between just `S` and `()`, but when we suggest a fixup, that applies to the expression with type `root_ty`.

---

Questions:
1. Should this check live here, above all of the suggestions, or should I push this down into every suggestion when we match `ObligationCauseCode`?
2. Any other `ObligationCauseCode`s to check here?
3. Am I overlooking an easier way to get to this same conclusion without pattern matching on `ObligationCauseCode` and comparing `root_ty`?

Fixes #91058
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/mod.rs')
0 files changed, 0 insertions, 0 deletions