diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 86e7bc2e6d1..e2624ee80c0 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1362,6 +1362,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc continue; }, ty::Param(_) => TyPosition::new_deref_stable_for_result(precedence, ty), + ty::Projection(_) if ty.has_non_region_param() => TyPosition::new_deref_stable_for_result(precedence, ty), ty::Infer(_) | ty::Error(_) | ty::Bound(..) | ty::Opaque(..) | ty::Placeholder(_) | ty::Dynamic(..) => { Position::ReborrowStable(precedence).into() }, diff --git a/tests/ui/explicit_auto_deref.fixed b/tests/ui/explicit_auto_deref.fixed index d1d35e5c0eb..59ff5e4040a 100644 --- a/tests/ui/explicit_auto_deref.fixed +++ b/tests/ui/explicit_auto_deref.fixed @@ -266,4 +266,15 @@ fn main() { } x }; + + trait WithAssoc { + type Assoc: ?Sized; + } + impl WithAssoc for String { + type Assoc = str; + } + fn takes_assoc(_: &T::Assoc) -> T { + unimplemented!() + } + let _: String = takes_assoc(&*String::new()); } diff --git a/tests/ui/explicit_auto_deref.rs b/tests/ui/explicit_auto_deref.rs index deedafad153..bcfb60c3278 100644 --- a/tests/ui/explicit_auto_deref.rs +++ b/tests/ui/explicit_auto_deref.rs @@ -266,4 +266,15 @@ fn deref(&self) -> &Self::Target { } *x }; + + trait WithAssoc { + type Assoc: ?Sized; + } + impl WithAssoc for String { + type Assoc = str; + } + fn takes_assoc(_: &T::Assoc) -> T { + unimplemented!() + } + let _: String = takes_assoc(&*String::new()); }