From e22d4795d849d2c6a229ccb666db922ae5b76410 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 16 Apr 2020 13:48:17 +0300 Subject: [PATCH] Partially revert "Do not ICE in the face of invalid enum discriminant" This (partially) reverts commit f47c4ffdfacc783b3fe4bad395a6e16ae296b3d1. --- src/librustc_mir_build/hair/cx/expr.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/hair/cx/expr.rs index d2d99cf030d9..21d632b9f6b8 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/hair/cx/expr.rs @@ -12,7 +12,7 @@ use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast, }; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; -use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable}; +use rustc_middle::ty::{self, AdtKind, Ty}; use rustc_span::Span; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> { @@ -718,7 +718,8 @@ fn convert_path_expr<'a, 'tcx>( Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => { let user_provided_types = cx.tables.user_provided_types(); - let user_ty = user_provided_types.get(expr.hir_id).copied(); + let user_provided_type = user_provided_types.get(expr.hir_id).copied(); + debug!("convert_path_expr: user_provided_type={:?}", user_provided_type); let ty = cx.tables().node_type(expr.hir_id); match ty.kind { // A unit struct/variant which is used as a value. @@ -727,17 +728,10 @@ fn convert_path_expr<'a, 'tcx>( adt_def, variant_index: adt_def.variant_index_with_ctor_id(def_id), substs, - user_ty, + user_ty: user_provided_type, fields: vec![], base: None, }, - _ if ty.references_error() => { - // Handle degenerate input without ICE (#67377). - ExprKind::Literal { - literal: ty::Const::zero_sized(cx.tcx, cx.tcx.types.err), - user_ty: None, - } - } _ => bug!("unexpected ty: {:?}", ty), } }