diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-06 20:59:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-06 20:59:32 +0100 |
| commit | 44c6e83b492dcfa0d8cd763b2b18fcd1be9f6fb4 (patch) | |
| tree | 3f4b9080538e4db458e862f62de387efb7d64f02 /compiler | |
| parent | 49b05ed7c11c811dda75cf9f64c8bf0f2aa5cf77 (diff) | |
| parent | 592259930b27525789f14f07396f02b254d4dfc9 (diff) | |
| download | rust-44c6e83b492dcfa0d8cd763b2b18fcd1be9f6fb4.tar.gz rust-44c6e83b492dcfa0d8cd763b2b18fcd1be9f6fb4.zip | |
Rollup merge of #134771 - compiler-errors:const-arg-has-type-err, r=lcnr
Report correct `SelectionError` for `ConstArgHasType` in new solver fulfill r? ``@BoxyUwU``
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/fulfill.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 2b2623a050e..c79a8abca20 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -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 }) } |
