1
Fork 0

Rollup merge of #135380 - compiler-errors:mismatch-valtree, r=lcnr

Make sure we can produce `ConstArgHasWrongType` errors for valtree consts

I forgot about `ty::ConstKind::Value` in #134771.

The error message here could use some work -- both in the new trait solver and the old trait solver. But unrelated to the issue here.

Fixes https://github.com/rust-lang/rust/issues/135361 -- this was only ICEing in coherence because coherence uses the new trait solver, but I don't think the minimization is worth committing compared to the test I added.

r? ```@lcnr``` or ```@BoxyUwU```
This commit is contained in:
Jubilee 2025-01-14 19:56:33 -08:00 committed by GitHub
commit 7c85da9003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 110 additions and 2 deletions

View file

@ -264,9 +264,10 @@ fn fulfillment_error_for_no_solution<'tcx>(
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!(
ty::ConstKind::Value(ty, _) => ty,
kind => span_bug!(
obligation.cause.span,
"ConstArgHasWrongType failed but we don't know how to compute type"
"ConstArgHasWrongType failed but we don't know how to compute type for {kind:?}"
),
};
FulfillmentErrorCode::Select(SelectionError::ConstArgHasWrongType {