Skip to content

Commit

Permalink
Merge pull request #37078 from petrochenkov/beta
Browse files Browse the repository at this point in the history
[beta] Temporary fix for metadata decoding for struct constructors
  • Loading branch information
brson committed Oct 14, 2016
2 parents 94158fe + bfe0844 commit 8cc5c84
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
report_unexpected_def();
return tcx.types.err;
}
Def::Variant(..) | Def::Struct(..) => {
Def::Variant(..) => {
let variant = tcx.expect_variant_def(def);
if variant.kind != VariantKind::Unit {
report_unexpected_def();
return tcx.types.err;
}
}
Def::Struct(ctor_did) => {
let did = tcx.parent_def_id(ctor_did).expect("struct ctor has no parent");
let variant = tcx.lookup_adt_def(did).struct_variant();
if variant.kind != VariantKind::Unit {
report_unexpected_def();
return tcx.types.err;
}
}
Def::Const(..) | Def::AssociatedConst(..) => {} // OK
_ => bug!("unexpected pattern definition {:?}", def)
}
Expand Down Expand Up @@ -589,9 +597,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
report_unexpected_def(false);
return tcx.types.err;
}
Def::Variant(..) | Def::Struct(..) => {
Def::Variant(..) => {
tcx.expect_variant_def(def)
}
Def::Struct(ctor_did) => {
let did = tcx.parent_def_id(ctor_did).expect("struct ctor has no parent");
tcx.lookup_adt_def(did).struct_variant()
}
_ => bug!("unexpected pattern definition {:?}", def)
};
if variant.kind == VariantKind::Unit && subpats.is_empty() && ddpos.is_some() {
Expand Down

0 comments on commit 8cc5c84

Please sign in to comment.