add ui test for new typeof error messages
This commit is contained in:
parent
81e4d5f96c
commit
ed903f9b91
2 changed files with 32 additions and 0 deletions
9
src/test/ui/typeof/type_mismatch.rs
Normal file
9
src/test/ui/typeof/type_mismatch.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Test that using typeof results in the correct type mismatch errors instead of always assuming
|
||||
// `usize`, in addition to the pre-existing "typeof is reserved and unimplemented" error
|
||||
fn main() {
|
||||
const a: u8 = 1;
|
||||
let b: typeof(a) = 1i8;
|
||||
//~^ ERROR `typeof` is a reserved keyword but unimplemented
|
||||
//~| ERROR mismatched types
|
||||
//~| expected `u8`, found `i8`
|
||||
}
|
23
src/test/ui/typeof/type_mismatch.stderr
Normal file
23
src/test/ui/typeof/type_mismatch.stderr
Normal file
|
@ -0,0 +1,23 @@
|
|||
error[E0516]: `typeof` is a reserved keyword but unimplemented
|
||||
--> $DIR/type_mismatch.rs:5:12
|
||||
|
|
||||
LL | let b: typeof(a) = 1i8;
|
||||
| ^^^^^^^^^ reserved keyword
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/type_mismatch.rs:5:24
|
||||
|
|
||||
LL | let b: typeof(a) = 1i8;
|
||||
| --------- ^^^ expected `u8`, found `i8`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
help: change the type of the numeric literal from `i8` to `u8`
|
||||
|
|
||||
LL | let b: typeof(a) = 1u8;
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0516.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
Loading…
Add table
Reference in a new issue