1
Fork 0

Do not ICE on AnonConsts in diagnostic_hir_wf_check

This commit is contained in:
Gurinder Singh 2024-04-22 10:31:32 +05:30
parent 426a698606
commit 446f78d051
4 changed files with 208 additions and 14 deletions

View file

@ -163,15 +163,17 @@ 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)
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]
}) = tcx.hir_node_by_def_id(const_param_id)
{
vec![*ty]
} else {
vec![]
}
}
ref node => bug!("Unexpected node {:?}", node),
},