diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-13 07:14:54 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-14 20:22:10 +0000 |
| commit | 54edf1863e120f9b2f3bf1a3f2b5040e9c8ca476 (patch) | |
| tree | 4b9f8c87cbca6a53035a9f4297fc07babce36a87 /compiler | |
| parent | 16b33cc1e32d1814d961d97a6e76defc079316d2 (diff) | |
| download | rust-54edf1863e120f9b2f3bf1a3f2b5040e9c8ca476.tar.gz rust-54edf1863e120f9b2f3bf1a3f2b5040e9c8ca476.zip | |
Also do it for generics
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 1f2dfc30ae0..bdb7c90aca3 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -1756,25 +1756,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let hir::ExprKind::Call(path, _) = &call_expr.kind { if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &path.kind { for error in errors { - if let ty::PredicateKind::Trait(predicate) = - error.obligation.predicate.kind().skip_binder() + let self_ty = match error.obligation.predicate.kind().skip_binder() { + ty::PredicateKind::Trait(predicate) => predicate.self_ty(), + ty::PredicateKind::Projection(predicate) => { + predicate.projection_ty.self_ty() + } + _ => continue, + }; + // If any of the type arguments in this path segment caused the + // `FulfillmentError`, point at its span (#61860). + for arg in path + .segments + .iter() + .filter_map(|seg| seg.args.as_ref()) + .flat_map(|a| a.args.iter()) { - // If any of the type arguments in this path segment caused the - // `FulfillmentError`, point at its span (#61860). - for arg in path - .segments - .iter() - .filter_map(|seg| seg.args.as_ref()) - .flat_map(|a| a.args.iter()) + if let hir::GenericArg::Type(hir_ty) = &arg + && let Some(ty) = + self.typeck_results.borrow().node_type_opt(hir_ty.hir_id) + && self.resolve_vars_if_possible(ty) == self_ty { - if let hir::GenericArg::Type(hir_ty) = &arg - && let Some(ty) = - self.typeck_results.borrow().node_type_opt(hir_ty.hir_id) - && self.resolve_vars_if_possible(ty) == predicate.self_ty() - { - error.obligation.cause.span = hir_ty.span; - break; - } + error.obligation.cause.span = hir_ty.span; + break; } } } |
