diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-14 23:56:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-14 23:56:28 +0100 |
| commit | db77788dc5d72da6dc2077e59d9ff321cbda1cec (patch) | |
| tree | c66a72aeeff0f31ff9a70e4a3b0b9c49fb0c9569 /compiler/rustc_codegen_llvm/src | |
| parent | 0aeaa5eb22180fdf12a8489e63c4daa18da6f236 (diff) | |
| parent | 831f4549cd1b23915729cbd2f1dd841621c4e8b8 (diff) | |
| download | rust-db77788dc5d72da6dc2077e59d9ff321cbda1cec.tar.gz rust-db77788dc5d72da6dc2077e59d9ff321cbda1cec.zip | |
Rollup merge of #132939 - uellenberg:suggest-deref, r=oli-obk
Suggest using deref in patterns
Fixes #132784
This changes the following code:
```rs
use std::sync::Arc;
fn main() {
let mut x = Arc::new(Some(1));
match x {
Some(_) => {}
None => {}
}
}
```
to output
```rs
error[E0308]: mismatched types
--> src/main.rs:5:9
|
LL | match x {
| - this expression has type `Arc<Option<{integer}>>`
...
LL | Some(_) => {}
| ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>`
|
= note: expected struct `Arc<Option<{integer}>>`
found enum `Option<_>`
help: consider dereferencing to access the inner value using the Deref trait
|
LL | match *x {
| ~~
```
instead of
```rs
error[E0308]: mismatched types
--> src/main.rs:5:9
|
4 | match x {
| - this expression has type `Arc<Option<{integer}>>`
5 | Some(_) => {}
| ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>`
|
= note: expected struct `Arc<Option<{integer}>>`
found enum `Option<_>`
```
This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
