Change:
Ok(ConstValue::Scalar(Scalar::from_uint(result, width))) }; <del> let lit = match *lit { ast::LitKind::Str(ref s, _) => { </del> <ins> let lit = match (lit, &ty.kind) { (ast::LitKind::Str(s, _), ty::Ref(_, TyS { kind: ty::Str, .. }, _)) => { </ins> let s = s.as_str(); let allocation = Allocation::from_byte_aligned_bytes(s.as_bytes()); let allocation = tcx.intern_const_alloc(allocation); ConstValue::Slice { data: allocation, start: 0, end: s.len() } } <del> ast::LitKind::ByteStr(ref data) => { if let ty::Ref(_, ref_ty, _) = ty.kind { match ref_ty.kind { ty::Slice(_) => { let allocation = Allocation::from_byte_aligned_bytes(data as &Vec<u8>); let allocation = tcx.intern_const_alloc(allocation); ConstValue::Slice { data: allocation, start: 0, end: data.len() } } ty::Array(_, _) => { let id = tcx.allocate_bytes(data); ConstValue::Scalar(Scalar::Ptr(id.into())) } _ => { bug!("bytestring should have type of either &[u8] or &[u8; _], not {}", ty) } } } else { bug!("bytestring should have type of either &[u8] or &[u8; _], not {}", ty) } </del> <ins> (ast::LitKind::ByteStr(data), ty::Ref(_, TyS { kind: ty::Slice(_), .. }, _)) => { let allocation = Allocation::from_byte_aligned_bytes(data as &Vec<u8>); let allocation = tcx.intern_const_alloc(allocation); ConstValue::Slice { data: allocation, start: 0, end: data.len() } } (ast::LitKind::ByteStr(data), ty::Ref(_, TyS { kind: ty::Array(_, _), .. }, _)) => { let id = tcx.allocate_bytes(data); ConstValue::Scalar(Scalar::Ptr(id.into())) } (ast::LitKind::Byte(n), ty::Uint(ast::UintTy::U8)) => { ConstValue::Scalar(Scalar::from_uint(*n, Size::from_bytes(1))) </ins> } <del> ast::LitKind::Byte(n) => ConstValue::Scalar(Scalar::from_uint(n, Size::from_bytes(1))), ast::LitKind::Int(n, _) if neg => { let n = n as i128; let n = n.overflowing_neg().0; trunc(n as u128)? </del> <ins> (ast::LitKind::Int(n, _), ty::Uint(_)) | (ast::LitKind::Int(n, _), ty::Int(_)) => { trunc(if neg { (*n as i128).overflowing_neg().0 as u128 } else { *n })? </ins> } <del> ast::LitKind::Int(n, _) => trunc(n)?, ast::LitKind::Float(n, _) => { let fty = match ty.kind { ty::Float(fty) => fty, _ => bug!(), }; parse_float(n, fty, neg).map_err(|_| LitToConstError::UnparseableFloat)? </del> <ins> (ast::LitKind::Float(n, _), ty::Float(fty)) => { parse_float(*n, *fty, neg).map_err(|_| LitToConstError::UnparseableFloat)? </ins> } <del> ast::LitKind::Bool(b) => ConstValue::Scalar(Scalar::from_bool(b)), ast::LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)), ast::LitKind::Err(_) => return Err(LitToConstError::Reported), </del> <ins> (ast::LitKind::Bool(b), ty::Bool) => ConstValue::Scalar(Scalar::from_bool(*b)), (ast::LitKind::Char(c), ty::Char) => ConstValue::Scalar(Scalar::from_char(*c)), (ast::LitKind::Err(_), _) => return Err(LitToConstError::Reported), _ => return Err(LitToConstError::TypeError), </ins> }; Ok(ty::Const::from_value(tcx, lit, ty)) }

Discussion:
I'm seeing an internal compiler error on the following input (found by ): The error happens on and , but not on . <details<summaryNightly backtrace</summary</details
triage: P-high, assigning to self.
(This ended up being a great motivation for me to tie off some work I've been doing...)
ICE was introduced between nightly 2020-01-15 and 2010-01-16. Here are the merges from that time period: ( is independently working to identify which one is the culprit.)
Okay finished: searched nightlies: from nightly-2020-01-15 to nightly-2020-01-22 regressed nightly: nightly-2020-01-16 searched commits: from to regressed commit:
Looks like the problem was injected by PR
reassigning to
The following also causes an ICE: (Same reason, but different message.)
Fixed by