diff options
| author | Ezra Shaw <ezrasure@outlook.com> | 2023-01-18 13:14:56 +1300 |
|---|---|---|
| committer | Ezra Shaw <ezrasure@outlook.com> | 2023-01-18 13:14:56 +1300 |
| commit | b73cdf1b29d25d3c6d0cc4f8a7744b08930e86ee (patch) | |
| tree | a3bdc4dc6325dff8a8b5b26cb2a70fca101ac6ed /tests/ui/error-codes | |
| parent | ca1178f02237fd84649a30b74052da4ef265371f (diff) | |
| download | rust-b73cdf1b29d25d3c6d0cc4f8a7744b08930e86ee.tar.gz rust-b73cdf1b29d25d3c6d0cc4f8a7744b08930e86ee.zip | |
special case removing `&` suggestion
Diffstat (limited to 'tests/ui/error-codes')
| -rw-r--r-- | tests/ui/error-codes/E0606.rs | 3 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0606.stderr | 22 |
2 files changed, 19 insertions, 6 deletions
diff --git a/tests/ui/error-codes/E0606.rs b/tests/ui/error-codes/E0606.rs index cb0d8cfc31e..6f6c6513846 100644 --- a/tests/ui/error-codes/E0606.rs +++ b/tests/ui/error-codes/E0606.rs @@ -1,3 +1,4 @@ fn main() { - &0u8 as u8; //~ ERROR E0606 + let x = &(&0u8 as u8); //~ ERROR E0606 + x as u8; //~ casting `&u8` as `u8` is invalid [E0606] } diff --git a/tests/ui/error-codes/E0606.stderr b/tests/ui/error-codes/E0606.stderr index 586b1f2fd54..2492eb299cc 100644 --- a/tests/ui/error-codes/E0606.stderr +++ b/tests/ui/error-codes/E0606.stderr @@ -1,14 +1,26 @@ error[E0606]: casting `&u8` as `u8` is invalid - --> $DIR/E0606.rs:2:5 + --> $DIR/E0606.rs:2:14 | -LL | &0u8 as u8; - | ^^^^^^^^^^ +LL | let x = &(&0u8 as u8); + | ^^^^^^^^^^^^ + | +help: remove the unneeded borrow + | +LL - let x = &(&0u8 as u8); +LL + let x = &(0u8 as u8); + | + +error[E0606]: casting `&u8` as `u8` is invalid + --> $DIR/E0606.rs:3:5 + | +LL | x as u8; + | ^^^^^^^ | help: dereference the expression | -LL | *&0u8 as u8; +LL | *x as u8; | + -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0606`. |
