Skip to content

Commit

Permalink
Don't panic when accessing enum variant ctor using Self in match
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 30, 2019
1 parent d9a2e3b commit 74675fe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/_match.rs
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions 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() {}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-58006.stderr
@@ -0,0 +1,9 @@
error[E0533]: expected unit struct/variant or constant, found tuple variant `<Self>::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`.

0 comments on commit 74675fe

Please sign in to comment.