Rollup merge of #123491 - gurry:123154-ice-unsized-struct-eval, r=oli-obk
Fix ICE in `eval_body_using_ecx` Ensures `TypeckResults` is tainted by failing candidate assembly for types with error Fixes #123154
This commit is contained in:
commit
ea7eb713d9
12 changed files with 72 additions and 37 deletions
|
@ -984,7 +984,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
// Already reported in the query.
|
||||
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(guar)) |
|
||||
// Already reported.
|
||||
Overflow(OverflowError::Error(guar)) => return guar,
|
||||
Overflow(OverflowError::Error(guar)) => {
|
||||
self.set_tainted_by_errors(guar);
|
||||
return guar
|
||||
},
|
||||
|
||||
Overflow(_) => {
|
||||
bug!("overflow should be handled before the `report_selection_error` path");
|
||||
|
|
|
@ -87,6 +87,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
} else if lang_items.sized_trait() == Some(def_id) {
|
||||
// Sized is never implementable by end-users, it is
|
||||
// always automatically computed.
|
||||
|
||||
// FIXME: Consider moving this check to the top level as it
|
||||
// may also be useful for predicates other than `Sized`
|
||||
// Error type cannot possibly implement `Sized` (fixes #123154)
|
||||
if let Err(e) = obligation.predicate.skip_binder().self_ty().error_reported() {
|
||||
return Err(SelectionError::Overflow(e.into()));
|
||||
}
|
||||
|
||||
let sized_conditions = self.sized_conditions(obligation);
|
||||
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
|
||||
} else if lang_items.unsize_trait() == Some(def_id) {
|
||||
|
|
|
@ -91,8 +91,8 @@ fn adt_sized_constraint<'tcx>(
|
|||
let tail_ty = tcx.type_of(tail_def.did).instantiate_identity();
|
||||
|
||||
let constraint_ty = sized_constraint_for_ty(tcx, tail_ty)?;
|
||||
if constraint_ty.references_error() {
|
||||
return None;
|
||||
if let Err(guar) = constraint_ty.error_reported() {
|
||||
return Some(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
|
||||
}
|
||||
|
||||
// perf hack: if there is a `constraint_ty: Sized` bound, then we know
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue