Skip to content

Commit 5a36f9e

Browse files
author
Alexander Regueiro
committed
Fixed several ICEs.
1 parent 65f5058 commit 5a36f9e

File tree

4 files changed

+116
-72
lines changed

4 files changed

+116
-72
lines changed

src/librustc_typeck/check/_match.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use util::nodemap::FxHashMap;
1717
use std::collections::hash_map::Entry::{Occupied, Vacant};
1818
use std::cmp;
1919

20+
use super::report_unexpected_variant_def;
21+
2022
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2123
/// The `is_arg` argument indicates whether this pattern is the
2224
/// *outermost* pattern in an argument (e.g., in `fn foo(&x:
@@ -736,12 +738,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
736738
expected: Ty<'tcx>) -> Ty<'tcx>
737739
{
738740
let tcx = self.tcx;
739-
let report_unexpected_def = |def: Def| {
740-
span_err!(tcx.sess, pat.span, E0533,
741-
"expected unit struct/variant or constant, found {} `{}`",
742-
def.kind_name(),
743-
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
744-
};
745741

746742
// Resolve the path and check the definition for errors.
747743
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
@@ -751,7 +747,11 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
751747
return tcx.types.err;
752748
}
753749
Def::Method(..) => {
754-
report_unexpected_def(def);
750+
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
751+
return tcx.types.err;
752+
}
753+
Def::VariantCtor(_, CtorKind::Fictive) => {
754+
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
755755
return tcx.types.err;
756756
}
757757
Def::VariantCtor(_, CtorKind::Const) |

0 commit comments

Comments
 (0)