diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 141b8222b1f33..4203c71a00a41 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -784,7 +784,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); report_unexpected_variant_def(tcx, &def, pat.span, qpath); return tcx.types.err; } - Def::VariantCtor(_, CtorKind::Fictive) => { + Def::VariantCtor(_, CtorKind::Fictive) | + Def::VariantCtor(_, CtorKind::Fn) => { report_unexpected_variant_def(tcx, &def, pat.span, qpath); return tcx.types.err; } diff --git a/src/test/ui/issues/issue-58006.rs b/src/test/ui/issues/issue-58006.rs new file mode 100644 index 0000000000000..1fb5fefa7596d --- /dev/null +++ b/src/test/ui/issues/issue-58006.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_enum_variants)] +pub enum Enum { + A(usize), +} + +impl Enum { + fn foo(&self) -> () { + match self { + Self::A => (), + //~^ ERROR expected unit struct/variant or constant, found tuple variant + } + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-58006.stderr b/src/test/ui/issues/issue-58006.stderr new file mode 100644 index 0000000000000..c65e3e2777fae --- /dev/null +++ b/src/test/ui/issues/issue-58006.stderr @@ -0,0 +1,9 @@ +error[E0533]: expected unit struct/variant or constant, found tuple variant `::A` + --> $DIR/issue-58006.rs:9:13 + | +LL | Self::A => (), + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0533`.