Skip to content
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

Don't suggest using fields in a static method #33613

Closed
Ms2ger opened this issue May 13, 2016 · 4 comments
Closed

Don't suggest using fields in a static method #33613

Ms2ger opened this issue May 13, 2016 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented May 13, 2016

fn f(_: bool) {}

struct Foo {
    cx: bool,
}

impl Foo {
    fn bar() {
        f(cx);
    }
}

fn main() {}
<anon>:9:11: 9:13 error: unresolved name `cx`. Did you mean `self.cx`? [E0425]
<anon>:9         f(cx);
                   ^~
@GuillaumeGomez
Copy link
Member

Working on it.

@mboecker
Copy link

I think if the error is just "unknown variable cx", then it will confuse beginners. It's not obvious for beginners that this is static method.

@GuillaumeGomez
Copy link
Member

It's possible to add a note saying "you're in a static method so you don't have access to this type's fields".

@mboecker
Copy link

That would be perfect.

@sanxiyn sanxiyn added the A-diagnostics Area: Messages for errors, warnings, and lints label May 14, 2016
bors added a commit that referenced this issue May 25, 2016
Don't suggest using fields in a static method

Fixes #33613.

cc @LeoTestard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

4 participants