Skip to content

Commit 169e2ab

Browse files
Correctly handle type relative in trait_duplication_in_bounds lint
1 parent 37947ff commit 169e2ab

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ fn get_trait_info_from_bound<'a>(bound: &'a GenericBound<'_>) -> Option<(Res, &'
390390
}
391391
}
392392

393+
fn get_ty_res(ty: Ty<'_>) -> Option<Res> {
394+
match ty.kind {
395+
TyKind::Path(QPath::Resolved(_, path)) => Some(path.res),
396+
TyKind::Path(QPath::TypeRelative(ty, _)) => get_ty_res(*ty),
397+
_ => None,
398+
}
399+
}
400+
393401
// FIXME: ComparableTraitRef does not support nested bounds needed for associated_type_bounds
394402
fn into_comparable_trait_ref(trait_ref: &TraitRef<'_>) -> ComparableTraitRef {
395403
ComparableTraitRef(
@@ -401,10 +409,8 @@ fn into_comparable_trait_ref(trait_ref: &TraitRef<'_>) -> ComparableTraitRef {
401409
.filter_map(|segment| {
402410
// get trait bound type arguments
403411
Some(segment.args?.args.iter().filter_map(|arg| {
404-
if let GenericArg::Type(ty) = arg
405-
&& let TyKind::Path(QPath::Resolved(_, path)) = ty.kind
406-
{
407-
return Some(path.res);
412+
if let GenericArg::Type(ty) = arg {
413+
return get_ty_res(**ty);
408414
}
409415
None
410416
}))

0 commit comments

Comments
 (0)