Rollup merge of #58007 - estebank:issue-58006, r=petrochenkov

Don't panic when accessing enum variant ctor using `Self` in match

Fix #58006.

r? @petrochenkov
This commit is contained in:
Mazdak Farrokhzad 2019-01-31 02:10:52 +01:00 committed by GitHub
commit bc7be96cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -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;
}

View File

@ -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() {}

View File

@ -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`.