Rollup merge of #134010 - RalfJung:promoted-type-error-ice, r=oli-obk

fix ICE on type error in promoted

Fixes https://github.com/rust-lang/rust/issues/133968

Ensure that when we turn a type error into a "this promoted failed to evaluate" error, we do record this as something that may happen even in "infallible" promoteds.
This commit is contained in:
León Orell Valerian Liehr 2024-12-10 08:55:59 +01:00 committed by GitHub
commit 4d544d9443
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 78 additions and 213 deletions

View file

@ -11,7 +11,7 @@ use rustc_hir::{
BodyId, Expr, ExprKind, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind, UnOp,
};
use rustc_lint::{LateContext, LateLintPass, Lint};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId, ReportedErrorInfo};
use rustc_middle::ty::adjustment::Adjust;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::impl_lint_pass;
@ -302,7 +302,10 @@ impl<'tcx> NonCopyConst<'tcx> {
tcx.const_eval_global_id_for_typeck(typing_env, cid, span)
},
Ok(None) => Err(ErrorHandled::TooGeneric(span)),
Err(err) => Err(ErrorHandled::Reported(err.into(), span)),
Err(err) => Err(ErrorHandled::Reported(
ReportedErrorInfo::non_const_eval_error(err),
span,
)),
}
}
}