]> git.lizzy.rs Git - rust.git/commitdiff
suggest: Put the `use` in suggested code inside the quotes
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Fri, 26 Feb 2016 00:23:07 +0000 (01:23 +0100)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Fri, 26 Feb 2016 00:25:21 +0000 (01:25 +0100)
Change import a trait suggestion from:

   help: candidate #1: use `std::io::Write`

to

   help: candidate #1: `use std::io::Write`

so that the code can be copied directly.

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

index 1367db16314e2f53e3cbae16406546d320b5d5af..e7d84efdaa2f7a50f1051ff08aaf1dd286699051 100644 (file)
@@ -271,7 +271,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 
         for (i, trait_did) in candidates.iter().enumerate() {
             err.fileline_help(span,
-                              &format!("candidate #{}: use `{}`",
+                              &format!("candidate #{}: `use {}`",
                                         i + 1,
                                         fcx.tcx().item_path_str(*trait_did)));
         }
index 08c848a09ab09c14e800c77c5000f334e79911a9..1683db811cf040ec6ab18aa9c5b5d79c1e00872b 100644 (file)
@@ -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 `foo::Bar`
-    //~^^^^ HELP `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 `foo::Bar`
-    //~^^^^ HELP `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 `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 `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 `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 `no_method_suggested_traits::foo::PubPub`
+    //~^^^ HELP `use no_method_suggested_traits::foo::PubPub`
 
     Foo.method();
     //~^ ERROR no method named