Rollup merge of #134771 - compiler-errors:const-arg-has-type-err, r=lcnr
Report correct `SelectionError` for `ConstArgHasType` in new solver fulfill r? ``@BoxyUwU``
This commit is contained in:
commit
44c6e83b49
4 changed files with 40 additions and 3 deletions
|
@ -10,9 +10,9 @@ use rustc_infer::traits::{
|
|||
self, FromSolverError, MismatchedProjectionTypes, Obligation, ObligationCause,
|
||||
ObligationCauseCode, PredicateObligation, PredicateObligations, SelectionError, TraitEngine,
|
||||
};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_next_trait_solver::solve::{GenerateProofTree, HasChanged, SolverDelegateEvalExt as _};
|
||||
use tracing::{instrument, trace};
|
||||
|
||||
|
@ -258,6 +258,23 @@ fn fulfillment_error_for_no_solution<'tcx>(
|
|||
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
||||
)
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, expected_ty)) => {
|
||||
let ct_ty = match ct.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
infcx.tcx.type_of(uv.def).instantiate(infcx.tcx, uv.args)
|
||||
}
|
||||
ty::ConstKind::Param(param_ct) => param_ct.find_ty_from_env(obligation.param_env),
|
||||
_ => span_bug!(
|
||||
obligation.cause.span,
|
||||
"ConstArgHasWrongType failed but we don't know how to compute type"
|
||||
),
|
||||
};
|
||||
FulfillmentErrorCode::Select(SelectionError::ConstArgHasWrongType {
|
||||
ct,
|
||||
ct_ty,
|
||||
expected_ty,
|
||||
})
|
||||
}
|
||||
ty::PredicateKind::NormalizesTo(..) => {
|
||||
FulfillmentErrorCode::Project(MismatchedProjectionTypes { err: TypeError::Mismatch })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue