diff options
| author | bors <bors@rust-lang.org> | 2017-08-16 23:40:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-16 23:40:01 +0000 |
| commit | be0f77dc8a12c40c184a47e5d51ec9001c4bd360 (patch) | |
| tree | 2026a4301f09c6d194fce0bbd30bc8dca2046f90 | |
| parent | 7ac979d8cbe97241fd39f4037e1d4069caaff4d2 (diff) | |
| parent | 20167abe90eb21e3f9a153ed002ce341b4da4756 (diff) | |
| download | rust-be0f77dc8a12c40c184a47e5d51ec9001c4bd360.tar.gz rust-be0f77dc8a12c40c184a47e5d51ec9001c4bd360.zip | |
Auto merge of #43864 - GuillaumeGomez:static-method-invalid-use, r=eddyb
Add help for static method invalid use Fixes #30391.
| -rw-r--r-- | src/librustc_typeck/check/method/suggest.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/issue-41652/issue_41652.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/span/issue-7575.stderr | 3 |
3 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 2337e989be4..c8b828f3a43 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -260,6 +260,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { 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); } diff --git a/src/test/ui/issue-41652/issue_41652.stderr b/src/test/ui/issue-41652/issue_41652.stderr index 8a55c9989e1..5d143697908 100644 --- a/src/test/ui/issue-41652/issue_41652.stderr +++ b/src/test/ui/issue-41652/issue_41652.stderr @@ -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 | diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index ff62adbfbd5..08ec2a87fcd 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -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 | |
