Skip to content

Commit 5b802ed

Browse files
Apply suggestions from code review
Co-authored-by: Esteban Kuber <[email protected]>
1 parent 6efa14b commit 5b802ed

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

compiler/rustc_typeck/src/check/method/suggest.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
384384
} else {
385385
span = item_name.span;
386386

387-
// issue #81576, elision of generic argument when no methode can be found in any implementation
387+
// Don't show generic arguments when the method can't be found in any implementation (#81576).
388388
let mut ty_str_reported = ty_str.clone();
389389
if let ty::Adt(_, ref generics) = actual.kind() {
390390
if generics.len() > 0 {
@@ -493,22 +493,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
493493
self.associated_item(*def_id, item_name, Namespace::ValueNS)
494494
{
495495
// Check for both mode is the same so we avoid suggesting
496-
// incorect associated item.
497-
match (mode, assoc.fn_has_self_parameter) {
498-
(Mode::MethodCall, true) => {
499-
if let SelfSource::MethodCall(_) = source {
500-
// We check that the suggest type is actually
501-
// different from the received one
502-
// So we avoid suggestion method with Box<Self>
503-
// for instance
504-
self.tcx.at(span).type_of(*def_id) != actual
505-
&& self.tcx.at(span).type_of(*def_id)
506-
!= rcvr_ty
507-
} else {
508-
false
509-
}
496+
// incorrect associated item.
497+
match (mode, assoc.fn_has_self_parameter, source) {
498+
(Mode::MethodCall, true, SelfSource::MethodCall(_)) => {
499+
// We check that the suggest type is actually
500+
// different from the received one
501+
// So we avoid suggestion method with Box<Self>
502+
// for instance
503+
self.tcx.at(span).type_of(*def_id) != actual
504+
&& self.tcx.at(span).type_of(*def_id)
505+
!= rcvr_ty
510506
}
511-
(Mode::Path, false) => true,
507+
(Mode::Path, false, _) => true,
512508
_ => false,
513509
}
514510
} else {
@@ -521,7 +517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
521517
inherent_impls_candidate.dedup();
522518
// number of type to shows at most.
523519
const LIMIT: usize = 3;
524-
let mut note = format!("The {item_kind} was found for");
520+
let mut note = format!("the {item_kind} was found for");
525521
if inherent_impls_candidate.len() > 1 {
526522
for impl_item in inherent_impls_candidate.iter().take(LIMIT - 2)
527523
{

0 commit comments

Comments
 (0)