Skip to content

Commit f3a71d3

Browse files
committed
Add semicolon to "perhaps add a use for one of them" help
Similar to pull request #37430, this makes the message more copy-paste friendly and aligns it with other messages like: help: you can import it into scope: use foo::Bar;
1 parent 3316ef7 commit f3a71d3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
308308

309309
let limit = if candidates.len() == 5 { 5 } else { 4 };
310310
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
311-
err.help(&format!("candidate #{}: `use {}`",
311+
err.help(&format!("candidate #{}: `use {};`",
312312
i + 1,
313313
self.tcx.item_path_str(*trait_did)));
314314
}

src/test/compile-fail/no-method-suggested-traits.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,31 @@ fn main() {
3434
1u32.method();
3535
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
3636
//~^^ ERROR no method named
37-
//~^^^ HELP `use foo::Bar`
38-
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
37+
//~^^^ HELP `use foo::Bar;`
38+
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
3939
std::rc::Rc::new(&mut Box::new(&1u32)).method();
4040
//~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them
4141
//~^^ ERROR no method named
42-
//~^^^ HELP `use foo::Bar`
43-
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub`
42+
//~^^^ HELP `use foo::Bar;`
43+
//~^^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
4444

4545
'a'.method();
4646
//~^ ERROR no method named
4747
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
48-
//~^^^ HELP `use foo::Bar`
48+
//~^^^ HELP `use foo::Bar;`
4949
std::rc::Rc::new(&mut Box::new(&'a')).method();
5050
//~^ ERROR no method named
5151
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
52-
//~^^^ HELP `use foo::Bar`
52+
//~^^^ HELP `use foo::Bar;`
5353

5454
1i32.method();
5555
//~^ ERROR no method named
5656
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
57-
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
57+
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
5858
std::rc::Rc::new(&mut Box::new(&1i32)).method();
5959
//~^ ERROR no method named
6060
//~^^ HELP the following trait is implemented but not in scope, perhaps add a `use` for it:
61-
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
61+
//~^^^ HELP `use no_method_suggested_traits::foo::PubPub;`
6262

6363
Foo.method();
6464
//~^ ERROR no method named

0 commit comments

Comments
 (0)