1
Fork 0

Do not favor projection type when pointing out arg causing fulfillment error

This commit is contained in:
Michael Goulet 2022-08-16 23:37:56 +00:00
parent c9cb19d26e
commit 3a1aa3c76e
5 changed files with 32 additions and 14 deletions

View file

@ -1742,7 +1742,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.inputs()
.iter()
.enumerate()
.filter(|(_, ty)| ty.walk().any(|arg| arg == param_to_point_at))
.filter(|(_, ty)| {
let mut walk = ty.walk();
while let Some(arg) = walk.next() {
if arg == param_to_point_at {
return true;
} else if let ty::GenericArgKind::Type(ty) = arg.unpack()
&& let ty::Projection(..) = ty.kind()
{
// This logic may seem a bit strange, but typically when
// we have a projection type in a function signature, the
// argument that's being passed into that signature is
// not actually constraining that projection in a meaningful
// way. So we skip it, and see improvements in some UI tests
// due to it.
walk.skip_current_subtree();
}
}
false
})
.collect();
if let [(idx, _)] = args_referencing_param.as_slice()