Skip to content

Commit 4942e38

Browse files
committed
remove unnecessary code
1 parent 2de4cd8 commit 4942e38

File tree

2 files changed

+4
-40
lines changed

2 files changed

+4
-40
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
407407
&self,
408408
self_source: SelfSource<'tcx>,
409409
method_name: Ident,
410-
unsatisfied_predicates: &[(
411-
ty::Predicate<'tcx>,
412-
Option<ty::Predicate<'tcx>>,
413-
Option<ObligationCause<'tcx>>,
414-
)],
415410
ty: Ty<'tcx>,
416411
err: &mut Diag<'_>,
417412
) {
@@ -487,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
487482
}
488483

489484
// If the shadowed binding has an itializer expression,
490-
// use the initializer expression'ty to try to find the method again.
485+
// use the initializer expression's ty to try to find the method again.
491486
// For example like: `let mut x = Vec::new();`,
492487
// `Vec::new()` is the itializer expression.
493488
if let Some(self_ty) = self.fcx.node_ty_opt(binding.init_hir_id)
@@ -576,34 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
576571
span.push_span_label(sugg_let.span,
577572
format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here"));
578573

579-
// Don't show generic arguments when the method can't be found in any implementation (#81576).
580-
let mut ty_str = None;
581-
if let ty::Adt(_, generics) = ty.kind() {
582-
if generics.len() > 0 {
583-
let mut autoderef = self.autoderef(DUMMY_SP, ty).silence_errors();
584-
let candidate_found = autoderef.any(|(ty, _)| {
585-
if let ty::Adt(adt_def, _) = ty.kind() {
586-
self.tcx.inherent_impls(adt_def.did()).into_iter().any(
587-
|def_id| {
588-
self.associated_value(*def_id, method_name).is_some()
589-
},
590-
)
591-
} else {
592-
false
593-
}
594-
});
595-
let has_deref = autoderef.step_count() > 0;
596-
if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() {
597-
let t = with_forced_trimmed_paths!(ty.to_string());
598-
if let Some((path_string, _)) = t.split_once('<') {
599-
ty_str = Some(path_string.to_string());
600-
}
601-
}
602-
}
603-
}
604-
605-
let ty =
606-
ty_str.unwrap_or_else(|| self.tcx.short_string(ty, err.long_ty_path()));
574+
let ty = self.tcx.short_string(ty, err.long_ty_path());
607575
span.push_span_label(
608576
self.tcx.hir_span(recv_id),
609577
format!("earlier `{rcvr_name}` shadowed here with type `{ty}`"),
@@ -720,11 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
720688

721689
if is_method {
722690
self.suggest_use_shadowed_binding_with_method(
723-
source,
724-
item_ident,
725-
&unsatisfied_predicates,
726-
rcvr_ty,
727-
&mut err,
691+
source, item_ident, rcvr_ty, &mut err,
728692
);
729693
}
730694

tests/ui/attributes/rustc_confusables_std_cases.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LL | let mut x = Vec::new();
3535
| ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here
3636
...
3737
LL | let mut x = VecDeque::new();
38-
| ----- earlier `x` shadowed here with type `VecDeque`
38+
| ----- earlier `x` shadowed here with type `VecDeque<_>`
3939
help: you might have meant to use `push_back`
4040
|
4141
LL | x.push_back(1);

0 commit comments

Comments
 (0)