Auto merge of #9813 - Jarcho:issue_9811, r=xFrednet

Fix `explicit_auto_deref` fp

fixes #9763
fixes #9811

changelog: `explicit_auto_deref`: Don't lint when the target type is a projection with generic arguments
This commit is contained in:
bors 2022-11-09 14:06:42 +00:00
commit 432baf7026
3 changed files with 23 additions and 0 deletions

View File

@ -1385,6 +1385,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 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());
}