diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-02-25 14:34:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-25 14:34:04 +0100 |
| commit | 12ea0f6112d99310ba992f5656c29929da0bc6eb (patch) | |
| tree | 144b02741c4b15840124a8085325e1cf4a023851 /compiler/rustc_llvm/llvm-wrapper/Linker.cpp | |
| parent | 20928e0cbf65a65a5e96d56d2f665e62f593fdf8 (diff) | |
| parent | fa74d489a227054f20b0ffdda85e864e53cc7617 (diff) | |
| download | rust-12ea0f6112d99310ba992f5656c29929da0bc6eb.tar.gz rust-12ea0f6112d99310ba992f5656c29929da0bc6eb.zip | |
Rollup merge of #82364 - osa1:issue82361, r=estebank
Improve error msgs when found type is deref of expected
This improves help messages in two cases:
- When expected type is `T` and found type is `&T`, we now look through blocks
and suggest dereferencing the expression of the block, rather than the whole
block.
- In the above case, if the expression is an `&`, we not suggest removing the
`&` instead of adding `*`.
Both of these are demonstrated in the regression test. Before this patch the
first error in the test would be:
error[E0308]: `if` and `else` have incompatible types
--> test.rs:8:9
|
5 | / if true {
6 | | a
| | - expected because of this
7 | | } else {
8 | | b
| | ^ expected `usize`, found `&usize`
9 | | };
| |_____- `if` and `else` have incompatible types
|
help: consider dereferencing the borrow
|
7 | } else *{
8 | b
9 | };
|
Now:
error[E0308]: `if` and `else` have incompatible types
--> test.rs:8:9
|
5 | / if true {
6 | | a
| | - expected because of this
7 | | } else {
8 | | b
| | ^
| | |
| | expected `usize`, found `&usize`
| | help: consider dereferencing the borrow: `*b`
9 | | };
| |_____- `if` and `else` have incompatible types
The second error:
error[E0308]: `if` and `else` have incompatible types
--> test.rs:14:9
|
11 | / if true {
12 | | 1
| | - expected because of this
13 | | } else {
14 | | &1
| | ^^ expected integer, found `&{integer}`
15 | | };
| |_____- `if` and `else` have incompatible types
|
help: consider dereferencing the borrow
|
13 | } else *{
14 | &1
15 | };
|
now:
error[E0308]: `if` and `else` have incompatible types
--> test.rs:14:9
|
11 | / if true {
12 | | 1
| | - expected because of this
13 | | } else {
14 | | &1
| | ^-
| | ||
| | |help: consider removing the `&`: `1`
| | expected integer, found `&{integer}`
15 | | };
| |_____- `if` and `else` have incompatible types
Fixes #82361
---
r? ````@estebank````
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/Linker.cpp')
0 files changed, 0 insertions, 0 deletions
