Make check_param_wf only go through the HIR in the error path

This commit is contained in:
Oli Scherer
2025-06-03 15:27:34 +00:00
parent 215009bd0c
commit cca072ca15
2 changed files with 31 additions and 26 deletions

View File

@@ -1186,7 +1186,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
ty: Ty<'tcx>,
obligation: &PredicateObligation<'tcx>,
) -> Diag<'a> {
let span = obligation.cause.span;
let param = obligation.cause.body_id;
let hir::GenericParamKind::Const { ty: &hir::Ty { span, .. }, .. } =
self.tcx.hir_node_by_def_id(param).expect_generic_param().kind
else {
bug!()
};
let mut diag = match ty.kind() {
ty::Float(_) => {