Skip to content

Commit 64ee9cc

Browse files
committed
Recover trait import suggestion
1 parent 8629017 commit 64ee9cc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10471047
}
10481048
}
10491049
}
1050-
if !alt_rcvr_sugg && self.suggest_valid_traits(err, valid_out_of_scope_traits) {
1050+
if self.suggest_valid_traits(err, valid_out_of_scope_traits) {
10511051
return;
10521052
}
10531053

src/test/ui/suggestions/import-trait-for-method-call.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LL | fn finish(&self) -> u64;
1212
| the method is available for `Box<DefaultHasher>` here
1313
| the method is available for `Box<&mut DefaultHasher>` here
1414
|
15+
= help: items from traits can only be used if the trait is in scope
1516
help: consider wrapping the receiver expression with the appropriate type
1617
|
1718
LL | Box::new(h).finish()
@@ -20,6 +21,10 @@ help: consider wrapping the receiver expression with the appropriate type
2021
|
2122
LL | Box::new(&mut h).finish()
2223
| ^^^^^^^^^^^^^ ^
24+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
25+
|
26+
LL | use std::hash::Hasher;
27+
|
2328

2429
error: aborting due to previous error
2530

0 commit comments

Comments
 (0)