Skip to content

Commit

Permalink
Recover trait import suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 24, 2021
1 parent 8629017 commit 64ee9cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/method/suggest.rs
Expand Up @@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
}
if !alt_rcvr_sugg && self.suggest_valid_traits(err, valid_out_of_scope_traits) {
if self.suggest_valid_traits(err, valid_out_of_scope_traits) {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/suggestions/import-trait-for-method-call.stderr
Expand Up @@ -12,6 +12,7 @@ LL | fn finish(&self) -> u64;
| the method is available for `Box<DefaultHasher>` here
| the method is available for `Box<&mut DefaultHasher>` here
|
= help: items from traits can only be used if the trait is in scope
help: consider wrapping the receiver expression with the appropriate type
|
LL | Box::new(h).finish()
Expand All @@ -20,6 +21,10 @@ help: consider wrapping the receiver expression with the appropriate type
|
LL | Box::new(&mut h).finish()
| ^^^^^^^^^^^^^ ^
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use std::hash::Hasher;
|

error: aborting due to previous error

Expand Down

0 comments on commit 64ee9cc

Please sign in to comment.