Change:
The following ICE's on stable, beta and nightly: (notice the was NOT closed) <details<summaryBacktrace:</summary</details
Oh, this works with other types as well, except the messages are different ICE's with:
ICE's with:
Its worth nothing explicitly that: these ICE's are happening after we do issue a diagnostic for the parsing error If you address the parsing error (presumably in the same manner that the parser is auto-correcting to make further progress), the ICE goes away
triage: P-medium. Removing nomination.
Triage: The first example still ICEs in MIR building The second and third examples don't ICE anymore and need tests (without closing this issue!).
cc

Discussion:
None } Err(ErrorHandled::TooGeneric) => { <del> span_bug!(tcx.def_span(expr_did), "enum discriminant depends on generic arguments",) </del> <ins> tcx.sess.delay_span_bug( tcx.def_span(expr_did), "enum discriminant depends on generic arguments", ); None </ins> } } }

Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast, }; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; <del> use rustc_middle::ty::{self, AdtKind, Ty}; </del> <ins> use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable}; </ins> use rustc_span::Span; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> {

Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => { let user_provided_types = cx.tables.user_provided_types(); <del> let user_provided_type = user_provided_types.get(expr.hir_id).copied(); debug!("convert_path_expr: user_provided_type={:?}", user_provided_type); </del> <ins> let user_ty = user_provided_types.get(expr.hir_id).copied(); </ins> let ty = cx.tables().node_type(expr.hir_id); match ty.kind { // A unit struct/variant which is used as a value.

adt_def, variant_index: adt_def.variant_index_with_ctor_id(def_id), substs, <del> user_ty: user_provided_type, </del> <ins> user_ty, </ins> fields: vec![], base: None, }, <ins> _ 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, } } </ins> _ => bug!("unexpected ty: {:?}", ty), } }

<ins> mod a { use std::marker::PhantomData; enum Bug { V = [PhantomData; { [ () ].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` } } mod b { enum Bug { V = [Vec::new; { [].len()  ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR type annotations needed } } mod c { enum Bug { V = [Vec::new; { [0].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR type annotations needed } } fn main() {} </ins>

<ins> error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL |         V = [PhantomData; { [ () ].len() ].len() as isize, |             -             -              ^ mismatched closing delimiter |             |             | |             |             unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL |         V = [Vec::new; { [].len()  ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL |         V = [Vec::new; { [0].len() ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL |         V = [PhantomData; { [ () ].len() ].len() as isize, |             -             -              ^ mismatched closing delimiter |             |             | |             |             unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL |         V = [Vec::new; { [].len()  ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL |         V = [Vec::new; { [0].len() ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL |         V = [PhantomData; { [ () ].len() ].len() as isize, |             -             -              ^ mismatched closing delimiter |             |             | |             |             unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL |         V = [Vec::new; { [].len()  ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL |         V = [Vec::new; { [0].len() ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL |         V = [PhantomData; { [ () ].len() ].len() as isize, |             -             -              ^ mismatched closing delimiter |             |             | |             |             unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL |         V = [Vec::new; { [].len()  ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL |         V = [Vec::new; { [0].len() ].len() as isize, |             -          -           ^ mismatched closing delimiter |             |          | |             |          unclosed delimiter |             closing delimiter possibly meant for this error[E0282]: type annotations needed --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:29 | LL |         V = [Vec::new; { [].len()  ].len() as isize, |                             ^^^ cannot infer type for type parameter `T` error[E0282]: type annotations needed --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14 | LL |         V = [Vec::new; { [0].len() ].len() as isize, |              ^^^^^^^^ cannot infer type for type parameter `T` error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0282`. </ins>