]> git.lizzy.rs Git - rust.git/commitdiff
Add help for static method invalid use
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 14 Aug 2017 18:56:54 +0000 (20:56 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 14 Aug 2017 18:56:54 +0000 (20:56 +0200)
src/librustc_typeck/check/method/suggest.rs
src/test/ui/issue-41652/issue_41652.stderr
src/test/ui/span/issue-7575.stderr

index 56eacc3194d1c8404c60d7c8e6dc073cc768af5c..11c043750357f5a6d1ba846a420480fa97e5c4b7 100644 (file)
@@ -260,6 +260,7 @@ macro_rules! report_function {
                 if !static_sources.is_empty() {
                     err.note("found the following associated functions; to be used as methods, \
                               functions must have a `self` parameter");
+                    err.help(&format!("try with `{}::{}`", self.ty_to_string(actual), item_name));
 
                     report_candidates(&mut err, static_sources);
                 }
index 8a55c9989e18c1b9d9cb358e194ee4bda7085fe7..5d1436979082379bc4a2453bf36a76cdba05df96 100644 (file)
@@ -5,6 +5,7 @@ error[E0599]: no method named `f` found for type `{integer}` in the current scop
    |           ^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+   = help: try with `{integer}::f`
 note: candidate #1 is defined in the trait `issue_41652_b::Tr`
   --> $DIR/auxiliary/issue_41652_b.rs:14:5
    |
index ff62adbfbd5fcc20cb54569979ee59e24607954d..08ec2a87fcdc4cfc584c54d22e9799d261e1fbf5 100644 (file)
@@ -5,6 +5,7 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope
    |                  ^^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+   = help: try with `usize::f9`
 note: candidate #1 is defined in the trait `CtxtFn`
   --> $DIR/issue-7575.rs:16:5
    |
@@ -36,6 +37,7 @@ error[E0599]: no method named `fff` found for type `Myisize` in the current scop
    |                              ^^^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+   = help: try with `Myisize::fff`
 note: candidate #1 is defined in an impl for the type `Myisize`
   --> $DIR/issue-7575.rs:51:5
    |
@@ -51,6 +53,7 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope
    |       ^^^^^^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+   = help: try with `T::is_str`
 note: candidate #1 is defined in the trait `ManyImplTrait`
   --> $DIR/issue-7575.rs:57:5
    |