Skip to content

Commit 1347b48

Browse files
Remove additional call to lookup_op_method
1 parent ed16ae8 commit 1347b48

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30553055
pub(crate) fn note_unmet_impls_on_type(
30563056
&self,
30573057
err: &mut Diag<'_>,
3058-
errors: Vec<FulfillmentError<'tcx>>,
3058+
errors: &[FulfillmentError<'tcx>],
30593059
suggest_derive: bool,
30603060
) {
30613061
let preds: Vec<_> = errors

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
322322
lhs_expr.span,
323323
format!("cannot use `{}` on type `{}`", s, lhs_ty_str),
324324
);
325-
self.note_unmet_impls_on_type(&mut err, errors, false);
325+
self.note_unmet_impls_on_type(&mut err, &errors, false);
326326
(err, None)
327327
}
328328
Op::BinOp(bin_op) => {
@@ -382,7 +382,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
382382
err.span_label(rhs_expr.span, rhs_ty_str);
383383
}
384384
let suggest_derive = self.can_eq(self.param_env, lhs_ty, rhs_ty);
385-
self.note_unmet_impls_on_type(&mut err, errors, suggest_derive);
385+
self.note_unmet_impls_on_type(&mut err, &errors, suggest_derive);
386386
(err, output_def_id)
387387
}
388388
};
@@ -582,22 +582,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
582582
// concatenation (e.g., "Hello " + "World!"). This means
583583
// we don't want the note in the else clause to be emitted
584584
} else if lhs_ty.has_non_region_param() {
585-
// Look for a TraitPredicate in the Fulfillment errors,
586-
// and use it to generate a suggestion.
587-
//
588-
// Note that lookup_op_method must be called again but
589-
// with a specific rhs_ty instead of a placeholder so
590-
// the resulting predicate generates a more specific
591-
// suggestion for the user.
592-
let errors = self
593-
.lookup_op_method(
594-
(lhs_expr, lhs_ty),
595-
Some((rhs_expr, rhs_ty)),
596-
lang_item_for_binop(self.tcx, op),
597-
op.span(),
598-
expected,
599-
)
600-
.unwrap_err();
601585
if !errors.is_empty() {
602586
for error in errors {
603587
if let Some(trait_pred) =
@@ -946,7 +930,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
946930
ty::Str | ty::Never | ty::Char | ty::Tuple(_) | ty::Array(_, _) => {}
947931
ty::Ref(_, lty, _) if *lty.kind() == ty::Str => {}
948932
_ => {
949-
self.note_unmet_impls_on_type(&mut err, errors, true);
933+
self.note_unmet_impls_on_type(&mut err, &errors, true);
950934
}
951935
}
952936
}

0 commit comments

Comments
 (0)