about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-31 23:39:44 +0200
committerGitHub <noreply@github.com>2022-07-31 23:39:44 +0200
commit20a5e9fd7cdf3f9b3e60f1f4d52148b5ff45819e (patch)
tree7a857226acc4b887c04914a6693071fbcc7aa833 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parente4fcee579ea33fb2b38ddb947850d5ee612e6479 (diff)
parent1c2ea78f29f6c24d210728ccee177d13d235a9df (diff)
downloadrust-20a5e9fd7cdf3f9b3e60f1f4d52148b5ff45819e.tar.gz
rust-20a5e9fd7cdf3f9b3e60f1f4d52148b5ff45819e.zip
Rollup merge of #99986 - WaffleLapkin:record_struct_wrap_suggestion, r=compiler-errors
Add wrap suggestions for record variants

This PR adds a suggestions to wrap an expression in a record struct/variant when encountering mismatched types, similarly to a suggestion to wrap expression in a tuple struct that was added before.

An example:
```rust
struct B {
    f: u8,
}

enum E {
    A(u32),
    B { f: u8 },
}

fn main() {
    let _: B = 1;
    let _: E = 1;
}
```
```text
error[E0308]: mismatched types
  --> ./t.rs:11:16
   |
11 |     let _: B = 1;
   |            -   ^ expected struct `B`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in `B`
   |
11 |     let _: B = B { f: 1 };
   |                ++++++   +

error[E0308]: mismatched types
  --> ./t.rs:12:16
   |
12 |     let _: E = 1;
   |            -   ^ expected enum `E`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in a variant of `E`
   |
12 |     let _: E = E::A(1);
   |                +++++ +
12 |     let _: E = E::B { f: 1 };
   |                +++++++++   +
```

r? `@compiler-errors`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions