Skip to content

Add help for static method invalid use #43864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/issue-41652/issue_41652.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/span/issue-7575.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down Expand Up @@ -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
|
Expand All @@ -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
|
Expand Down