about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-11-17 19:40:57 +0100
committerGitHub <noreply@github.com>2016-11-17 19:40:57 +0100
commitb633767b1049c9f8ca93f7399a5f4bf68bd487b9 (patch)
tree8bb6392b35fbf8762ca45ed546ee86b94faa0f7c
parent5c8824da0766e678ca3f3306098cc7035cfff48c (diff)
parentf3a71d3e8be80af5e8112bd9ae40f3384ea1c759 (diff)
downloadrust-b633767b1049c9f8ca93f7399a5f4bf68bd487b9.tar.gz
rust-b633767b1049c9f8ca93f7399a5f4bf68bd487b9.zip
Rollup merge of #37759 - robinst:trait-use-message-add-semicolon, r=eddyb
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;

r? @eddyb
-rw-r--r--src/librustc_typeck/check/method/suggest.rs2
-rw-r--r--src/test/compile-fail/no-method-suggested-traits.rs16
2 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index 0cb8cf2a588..d15795730a8 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -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)));
             }
diff --git a/src/test/compile-fail/no-method-suggested-traits.rs b/src/test/compile-fail/no-method-suggested-traits.rs
index 9ccc7cc75ad..ea8796d38f9 100644
--- a/src/test/compile-fail/no-method-suggested-traits.rs
+++ b/src/test/compile-fail/no-method-suggested-traits.rs
@@ -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