diff options
| author | Michael Goulet <michael@errs.io> | 2022-07-11 05:21:41 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-07-11 05:23:08 +0000 |
| commit | 88f2140d8736329610a4c0bd8000e164c9170537 (patch) | |
| tree | 4a342b7f10edc09e7e2c7d0912fe8613a77c250e | |
| parent | 0c39762dd620c278f1defa42394f09293e1a98b9 (diff) | |
| download | rust-88f2140d8736329610a4c0bd8000e164c9170537.tar.gz rust-88f2140d8736329610a4c0bd8000e164c9170537.zip | |
Do not suggest same trait over again
| -rw-r--r-- | compiler/rustc_typeck/src/check/method/mod.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-35976.stderr | 5 |
2 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_typeck/src/check/method/mod.rs b/compiler/rustc_typeck/src/check/method/mod.rs index e29f0275bf4..c0b3a23fde4 100644 --- a/compiler/rustc_typeck/src/check/method/mod.rs +++ b/compiler/rustc_typeck/src/check/method/mod.rs @@ -20,8 +20,8 @@ use rustc_hir::def_id::DefId; use rustc_infer::infer::{self, InferOk}; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; -use rustc_middle::ty::GenericParamDefKind; use rustc_middle::ty::{self, ToPredicate, Ty, TypeVisitable}; +use rustc_middle::ty::{DefIdTree, GenericParamDefKind}; use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::traits; @@ -221,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // We probe again, taking all traits into account (not only those in scope). - let candidates = match self.lookup_probe( + let mut candidates = match self.lookup_probe( span, segment.ident, self_ty, @@ -243,6 +243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .collect(), _ => Vec::new(), }; + candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id)); return Err(IllegalSizedBound(candidates, needs_mut, span)); } diff --git a/src/test/ui/issues/issue-35976.stderr b/src/test/ui/issues/issue-35976.stderr index f9b9b7dbd34..fe16f97b9d0 100644 --- a/src/test/ui/issues/issue-35976.stderr +++ b/src/test/ui/issues/issue-35976.stderr @@ -6,11 +6,6 @@ LL | fn wait(&self) where Self: Sized; ... LL | arg.wait(); | ^^^^ - | -help: another candidate was found in the following trait, perhaps add a `use` for it: - | -LL | use private::Future; - | error: aborting due to previous error |
