Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] Temporary fix for metadata decoding for struct constructors #37078

Merged
merged 1 commit into from
Oct 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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