Skip to content

Commit 8cc5c84

Browse files
authored
Merge pull request #37078 from petrochenkov/beta
[beta] Temporary fix for metadata decoding for struct constructors
2 parents 94158fe + bfe0844 commit 8cc5c84

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/librustc_typeck/check/_match.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
534534
report_unexpected_def();
535535
return tcx.types.err;
536536
}
537-
Def::Variant(..) | Def::Struct(..) => {
537+
Def::Variant(..) => {
538538
let variant = tcx.expect_variant_def(def);
539539
if variant.kind != VariantKind::Unit {
540540
report_unexpected_def();
541541
return tcx.types.err;
542542
}
543543
}
544+
Def::Struct(ctor_did) => {
545+
let did = tcx.parent_def_id(ctor_did).expect("struct ctor has no parent");
546+
let variant = tcx.lookup_adt_def(did).struct_variant();
547+
if variant.kind != VariantKind::Unit {
548+
report_unexpected_def();
549+
return tcx.types.err;
550+
}
551+
}
544552
Def::Const(..) | Def::AssociatedConst(..) => {} // OK
545553
_ => bug!("unexpected pattern definition {:?}", def)
546554
}
@@ -589,9 +597,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
589597
report_unexpected_def(false);
590598
return tcx.types.err;
591599
}
592-
Def::Variant(..) | Def::Struct(..) => {
600+
Def::Variant(..) => {
593601
tcx.expect_variant_def(def)
594602
}
603+
Def::Struct(ctor_did) => {
604+
let did = tcx.parent_def_id(ctor_did).expect("struct ctor has no parent");
605+
tcx.lookup_adt_def(did).struct_variant()
606+
}
595607
_ => bug!("unexpected pattern definition {:?}", def)
596608
};
597609
if variant.kind == VariantKind::Unit && subpats.is_empty() && ddpos.is_some() {

0 commit comments

Comments
 (0)