From eb0d5be441239ac5c401b5fe4f9cbb188b35595e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Sat, 2 Jan 2021 10:58:50 +0100 Subject: [PATCH] Add test for #80607 with undesired output --- src/test/ui/issues/issue-80607.rs | 10 ++++++++++ src/test/ui/issues/issue-80607.stderr | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/issues/issue-80607.rs create mode 100644 src/test/ui/issues/issue-80607.stderr diff --git a/src/test/ui/issues/issue-80607.rs b/src/test/ui/issues/issue-80607.rs new file mode 100644 index 0000000000000..8bfda9a5c54b2 --- /dev/null +++ b/src/test/ui/issues/issue-80607.rs @@ -0,0 +1,10 @@ +// 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 field does not exist +} + +fn main() {} diff --git a/src/test/ui/issues/issue-80607.stderr b/src/test/ui/issues/issue-80607.stderr new file mode 100644 index 0000000000000..cd405815c70df --- /dev/null +++ b/src/test/ui/issues/issue-80607.stderr @@ -0,0 +1,14 @@ +error[E0559]: variant `Enum::V1` has no field named `x` + --> $DIR/issue-80607.rs:7:16 + | +LL | V1(i32), + | -- `Enum` defined here +... +LL | Enum::V1 { x } + | -------- ^ field does not exist + | | + | `Enum` is a tuple variant, use the appropriate syntax: `Enum(/* fields */)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0559`.