move closure down

This commit is contained in:
Ellen 2022-05-06 11:40:18 +01:00
parent 2819b2d8c9
commit e4b8ed5aff

View File

@ -1001,14 +1001,6 @@ fn compare_generic_param_kinds<'tcx>(
(Const { .. }, Const { .. }) | (Type { .. }, Type { .. }) => false,
(Lifetime { .. }, _) | (_, Lifetime { .. }) => unreachable!(),
} {
let make_param_message = |prefix: &str, param: &ty::GenericParamDef| match param.kind {
Const { .. } => {
format!("{} const parameter of type `{}`", prefix, tcx.type_of(param.def_id))
}
Type { .. } => format!("{} type parameter", prefix),
Lifetime { .. } => unreachable!(),
};
let param_impl_span = tcx.def_span(param_impl.def_id);
let param_trait_span = tcx.def_span(param_trait.def_id);
@ -1022,6 +1014,14 @@ fn compare_generic_param_kinds<'tcx>(
&tcx.def_path_str(tcx.parent(trait_item.def_id))
);
let make_param_message = |prefix: &str, param: &ty::GenericParamDef| match param.kind {
Const { .. } => {
format!("{} const parameter of type `{}`", prefix, tcx.type_of(param.def_id))
}
Type { .. } => format!("{} type parameter", prefix),
Lifetime { .. } => unreachable!(),
};
let trait_header_span = tcx.def_ident_span(tcx.parent(trait_item.def_id)).unwrap();
err.span_label(trait_header_span, "");
err.span_label(param_trait_span, make_param_message("expected", param_trait));