Don't lint explicit_auto_deref when the target type is a projection containing a generic argument

This commit is contained in:
Jason Newcomb 2022-11-07 14:08:40 -05:00
parent 213003b887
commit 5b1e445b9a
3 changed files with 23 additions and 0 deletions

View File

@ -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()
},

View File

@ -266,4 +266,15 @@ fn main() {
}
x
};
trait WithAssoc {
type Assoc: ?Sized;
}
impl WithAssoc for String {
type Assoc = str;
}
fn takes_assoc<T: WithAssoc>(_: &T::Assoc) -> T {
unimplemented!()
}
let _: String = takes_assoc(&*String::new());
}

View File

@ -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: WithAssoc>(_: &T::Assoc) -> T {
unimplemented!()
}
let _: String = takes_assoc(&*String::new());
}