Skip to content

Commit e22d479

Browse files
committed
Partially revert "Do not ICE in the face of invalid enum discriminant"
This (partially) reverts commit f47c4ff.
1 parent 2deb39d commit e22d479

File tree

1 file changed

+4
-10
lines changed
  • src/librustc_mir_build/hair/cx

1 file changed

+4
-10
lines changed

src/librustc_mir_build/hair/cx/expr.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::ty::adjustment::{
1212
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
1313
};
1414
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
15-
use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable};
15+
use rustc_middle::ty::{self, AdtKind, Ty};
1616
use rustc_span::Span;
1717

1818
impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> {
@@ -718,7 +718,8 @@ fn convert_path_expr<'a, 'tcx>(
718718

719719
Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => {
720720
let user_provided_types = cx.tables.user_provided_types();
721-
let user_ty = user_provided_types.get(expr.hir_id).copied();
721+
let user_provided_type = user_provided_types.get(expr.hir_id).copied();
722+
debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
722723
let ty = cx.tables().node_type(expr.hir_id);
723724
match ty.kind {
724725
// A unit struct/variant which is used as a value.
@@ -727,17 +728,10 @@ fn convert_path_expr<'a, 'tcx>(
727728
adt_def,
728729
variant_index: adt_def.variant_index_with_ctor_id(def_id),
729730
substs,
730-
user_ty,
731+
user_ty: user_provided_type,
731732
fields: vec![],
732733
base: None,
733734
},
734-
_ if ty.references_error() => {
735-
// Handle degenerate input without ICE (#67377).
736-
ExprKind::Literal {
737-
literal: ty::Const::zero_sized(cx.tcx, cx.tcx.types.err),
738-
user_ty: None,
739-
}
740-
}
741735
_ => bug!("unexpected ty: {:?}", ty),
742736
}
743737
}

0 commit comments

Comments
 (0)