Skip to content

Commit dc45eb9

Browse files
Revert 88f2140
1 parent 5ac7e08 commit dc45eb9

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Diff for: compiler/rustc_hir_typeck/src/method/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_hir::def_id::DefId;
2020
use rustc_infer::infer::{self, InferOk};
2121
use rustc_middle::traits::ObligationCause;
2222
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
23-
use rustc_middle::ty::{self, DefIdTree, GenericParamDefKind, Ty, TypeVisitable};
23+
use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitable};
2424
use rustc_span::symbol::Ident;
2525
use rustc_span::Span;
2626
use rustc_trait_selection::traits;
@@ -217,7 +217,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
217217
}
218218

219219
// We probe again, taking all traits into account (not only those in scope).
220-
let mut candidates =
220+
let candidates =
221221
match self.lookup_probe(segment.ident, self_ty, call_expr, ProbeScope::AllTraits) {
222222
// If we find a different result the caller probably forgot to import a trait.
223223
Ok(ref new_pick) if pick.differs_from(new_pick) => {
@@ -236,7 +236,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
236236
.collect(),
237237
_ => Vec::new(),
238238
};
239-
candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id));
240239

241240
return Err(IllegalSizedBound(candidates, needs_mut, span));
242241
}

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
// revisions: imported unimported
2+
//[imported] check-pass
3+
14
mod private {
25
pub trait Future {
6+
//[unimported]~^^ HELP perhaps add a `use` for it
37
fn wait(&self) where Self: Sized;
48
}
59

@@ -8,13 +12,13 @@ mod private {
812
}
913
}
1014

11-
//use private::Future;
15+
#[cfg(imported)]
16+
use private::Future;
1217

1318
fn bar(arg: Box<dyn private::Future>) {
19+
// Importing the trait means that we don't autoderef `Box<dyn Future>`
1420
arg.wait();
15-
//~^ ERROR the `wait` method cannot be invoked on a trait object
21+
//[unimported]~^ ERROR the `wait` method cannot be invoked on a trait object
1622
}
1723

18-
fn main() {
19-
20-
}
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
error: the `wait` method cannot be invoked on a trait object
2-
--> $DIR/issue-35976.rs:14:9
2+
--> $DIR/issue-35976.rs:20:9
33
|
44
LL | fn wait(&self) where Self: Sized;
55
| ----- this has a `Sized` requirement
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+
|
914

1015
error: aborting due to previous error
1116

0 commit comments

Comments
 (0)