Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add semicolon to "perhaps add a use for one of them" help #37759

Merged
merged 1 commit into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let limit = if candidates.len() == 5 { 5 } else { 4 };
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
err.help(&format!("candidate #{}: `use {}`",
err.help(&format!("candidate #{}: `use {};`",
i + 1,
self.tcx.item_path_str(*trait_did)));
}
Expand Down
16 changes: 8 additions & 8 deletions src/test/compile-fail/no-method-suggested-traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ fn main() {
1u32.method();
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
//~^^ ERROR no method named
//~^^^ HELP `use foo::Bar`
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
//~^^^ HELP `use foo::Bar;`
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
std::rc::Rc::new(&mut Box::new(&1u32)).method();
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
//~^^ ERROR no method named
//~^^^ HELP `use foo::Bar`
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
//~^^^ HELP `use foo::Bar;`
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`

'a'.method();
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `use foo::Bar`
//~^^^ HELP `use foo::Bar;`
std::rc::Rc::new(&mut Box::new(&'a')).method();
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `use foo::Bar`
//~^^^ HELP `use foo::Bar;`

1i32.method();
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
std::rc::Rc::new(&mut Box::new(&1i32)).method();
//~^ ERROR no method named
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`

Foo.method();
//~^ ERROR no method named
Expand Down