- let const_params_impl = const_params_of(impl_m.def_id);
- let const_params_trait = const_params_of(trait_m.def_id);
-
- for (const_param_impl, const_param_trait) in iter::zip(const_params_impl, const_params_trait) {
- let impl_ty = tcx.type_of(const_param_impl);
- let trait_ty = tcx.type_of(const_param_trait);
- if impl_ty != trait_ty {
- let (impl_span, impl_ident) = match tcx.hir().get_if_local(const_param_impl) {
- Some(hir::Node::GenericParam(hir::GenericParam { span, name, .. })) => (
- span,
- match name {
- hir::ParamName::Plain(ident) => Some(ident),
- _ => None,
- },
- ),
- other => bug!(
- "expected GenericParam, found {:?}",
- other.map_or_else(|| "nothing".to_string(), |n| format!("{:?}", n))
- ),
- };
- let trait_span = match tcx.hir().get_if_local(const_param_trait) {
- Some(hir::Node::GenericParam(hir::GenericParam { span, .. })) => Some(span),
- _ => None,
- };
+
+ for (param_impl, param_trait) in
+ iter::zip(ty_const_params_of(impl_item.def_id), ty_const_params_of(trait_item.def_id))
+ {
+ use GenericParamDefKind::*;
+ if match (¶m_impl.kind, ¶m_trait.kind) {
+ (Const { .. }, Const { .. })
+ if tcx.type_of(param_impl.def_id) != tcx.type_of(param_trait.def_id) =>
+ {
+ true
+ }
+ (Const { .. }, Type { .. }) | (Type { .. }, Const { .. }) => true,
+ // this is exhaustive so that anyone adding new generic param kinds knows
+ // to make sure this error is reported for them.
+ (Const { .. }, Const { .. }) | (Type { .. }, Type { .. }) => false,
+ (Lifetime { .. }, _) | (_, Lifetime { .. }) => unreachable!(),
+ } {
+ let param_impl_span = tcx.def_span(param_impl.def_id);
+ let param_trait_span = tcx.def_span(param_trait.def_id);
+