Skip to content

Commit 88f2140

Browse files
Do not suggest same trait over again
1 parent 0c39762 commit 88f2140

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Diff for: compiler/rustc_typeck/src/check/method/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use rustc_hir::def_id::DefId;
2020
use rustc_infer::infer::{self, InferOk};
2121
use rustc_middle::ty::subst::Subst;
2222
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
23-
use rustc_middle::ty::GenericParamDefKind;
2423
use rustc_middle::ty::{self, ToPredicate, Ty, TypeVisitable};
24+
use rustc_middle::ty::{DefIdTree, GenericParamDefKind};
2525
use rustc_span::symbol::Ident;
2626
use rustc_span::Span;
2727
use rustc_trait_selection::traits;
@@ -221,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
221221
}
222222

223223
// We probe again, taking all traits into account (not only those in scope).
224-
let candidates = match self.lookup_probe(
224+
let mut candidates = match self.lookup_probe(
225225
span,
226226
segment.ident,
227227
self_ty,
@@ -243,6 +243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
243243
.collect(),
244244
_ => Vec::new(),
245245
};
246+
candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id));
246247

247248
return Err(IllegalSizedBound(candidates, needs_mut, span));
248249
}

Diff for: src/test/ui/issues/issue-35976.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ LL | fn wait(&self) where Self: Sized;
66
...
77
LL | arg.wait();
88
| ^^^^
9-
|
10-
help: another candidate was found in the following trait, perhaps add a `use` for it:
11-
|
12-
LL | use private::Future;
13-
|
149

1510
error: aborting due to previous error
1611

0 commit comments

Comments
 (0)