diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-16 23:37:56 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-21 02:34:52 +0000 |
| commit | 3a1aa3c76eb06bf6eba9c10eaccced92420c2fac (patch) | |
| tree | 6de1acfff58f9fe6967979a9662178585bc5d939 /compiler | |
| parent | c9cb19d26e3e868bc32a95b8cb1a003fa8d365a8 (diff) | |
| download | rust-3a1aa3c76eb06bf6eba9c10eaccced92420c2fac.tar.gz rust-3a1aa3c76eb06bf6eba9c10eaccced92420c2fac.zip | |
Do not favor projection type when pointing out arg causing fulfillment error
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 5a2a68d0604..f2f327e0812 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -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() |
