diff options
Diffstat (limited to 'tests/ui/enum')
| -rw-r--r-- | tests/ui/enum/enum-discriminant-type-mismatch-8761.rs | 11 | ||||
| -rw-r--r-- | tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr | 27 | ||||
| -rw-r--r-- | tests/ui/enum/enum-variant-field-error-80607.rs | 11 | ||||
| -rw-r--r-- | tests/ui/enum/enum-variant-field-error-80607.stderr | 18 | ||||
| -rw-r--r-- | tests/ui/enum/simple-enum-usage-8506.rs | 14 |
5 files changed, 81 insertions, 0 deletions
diff --git a/tests/ui/enum/enum-discriminant-type-mismatch-8761.rs b/tests/ui/enum/enum-discriminant-type-mismatch-8761.rs new file mode 100644 index 00000000000..ae09b919dc1 --- /dev/null +++ b/tests/ui/enum/enum-discriminant-type-mismatch-8761.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/8761 +enum Foo { + A = 1i64, + //~^ ERROR mismatched types + //~| NOTE expected `isize`, found `i64` + B = 2u8 + //~^ ERROR mismatched types + //~| NOTE expected `isize`, found `u8` +} + +fn main() {} diff --git a/tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr b/tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr new file mode 100644 index 00000000000..f1645183e17 --- /dev/null +++ b/tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/enum-discriminant-type-mismatch-8761.rs:3:9 + | +LL | A = 1i64, + | ^^^^ expected `isize`, found `i64` + | +help: change the type of the numeric literal from `i64` to `isize` + | +LL - A = 1i64, +LL + A = 1isize, + | + +error[E0308]: mismatched types + --> $DIR/enum-discriminant-type-mismatch-8761.rs:6:9 + | +LL | B = 2u8 + | ^^^ expected `isize`, found `u8` + | +help: change the type of the numeric literal from `u8` to `isize` + | +LL - B = 2u8 +LL + B = 2isize + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/enum/enum-variant-field-error-80607.rs b/tests/ui/enum/enum-variant-field-error-80607.rs new file mode 100644 index 00000000000..aa3f2f7c526 --- /dev/null +++ b/tests/ui/enum/enum-variant-field-error-80607.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/80607 +// This tests makes sure the diagnostics print the offending enum variant, not just the type. +pub enum Enum { + V1(i32), +} + +pub fn foo(x: i32) -> Enum { + Enum::V1 { x } //~ ERROR `Enum::V1` has no field named `x` +} + +fn main() {} diff --git a/tests/ui/enum/enum-variant-field-error-80607.stderr b/tests/ui/enum/enum-variant-field-error-80607.stderr new file mode 100644 index 00000000000..8d088ef04bb --- /dev/null +++ b/tests/ui/enum/enum-variant-field-error-80607.stderr @@ -0,0 +1,18 @@ +error[E0559]: variant `Enum::V1` has no field named `x` + --> $DIR/enum-variant-field-error-80607.rs:8:16 + | +LL | V1(i32), + | -- `Enum::V1` defined here +... +LL | Enum::V1 { x } + | ^ field does not exist + | +help: `Enum::V1` is a tuple variant, use the appropriate syntax + | +LL - Enum::V1 { x } +LL + Enum::V1(/* i32 */) + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0559`. diff --git a/tests/ui/enum/simple-enum-usage-8506.rs b/tests/ui/enum/simple-enum-usage-8506.rs new file mode 100644 index 00000000000..ebe095d84e4 --- /dev/null +++ b/tests/ui/enum/simple-enum-usage-8506.rs @@ -0,0 +1,14 @@ +// https://github.com/rust-lang/rust/issues/8506 +//@ run-pass +#![allow(non_upper_case_globals)] + +#![allow(dead_code)] + +enum Either { + One, + Other(String,String) +} + +static one : Either = Either::One; + +pub fn main () { } |
