1
Fork 0

Gracefully handle AnonConst in diagnostic_hir_wf_check()

when it is the default value of a generic param
This commit is contained in:
Gurinder Singh 2024-03-19 09:20:23 +05:30
parent 21d94a3d2c
commit 3c70d60c4f
3 changed files with 82 additions and 0 deletions

View file

@ -163,6 +163,16 @@ fn diagnostic_hir_wf_check<'tcx>(
kind: hir::GenericParamKind::Type { default: Some(ty), .. },
..
}) => vec![*ty],
hir::Node::AnonConst(_)
if let Some(const_param_id) =
tcx.hir().opt_const_param_default_param_def_id(hir_id)
&& let hir::Node::GenericParam(hir::GenericParam {
kind: hir::GenericParamKind::Const { ty, .. },
..
}) = tcx.hir_node_by_def_id(const_param_id) =>
{
vec![*ty]
}
ref node => bug!("Unexpected node {:?}", node),
},
WellFormedLoc::Param { function: _, param_idx } => {