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

Wrong error message when calling static method using dot notation #30391

Closed
defyrlt opened this issue Dec 15, 2015 · 2 comments
Closed

Wrong error message when calling static method using dot notation #30391

defyrlt opened this issue Dec 15, 2015 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@defyrlt
Copy link

defyrlt commented Dec 15, 2015

Playpen. For some reasons I wasn't able to get this error message when struct is in the same crate.

extern crate rustc;

use rustc::middle::ty::MethodCall;

fn main() {
    let mc = MethodCall.expr(); // ERROR: unresolved name `MethodCall` [E0425]
    // let mc = MethodCall; // same error here
}

Here's the error message I get when struct is in the same crate

<anon>:10:13: 10:16 error: `Foo` is the name of a struct or struct variant, but this expression uses it like a function name [E0423]

I think it should be raised in the case with crate too.

@defyrlt defyrlt changed the title Wrong error message when calling static method with dot instead of colons Wrong error message when calling static method using dot notation Dec 15, 2015
@apasel422 apasel422 added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 15, 2015
@birkenfeld
Copy link
Contributor

This appears to be fixed (in nightly at least):

z.rs:6:14: 6:24 error: `MethodCall` is the name of a struct or struct variant, but this expression uses it like a function name [E0423]
z.rs:6     let mc = MethodCall.expr(); // ERROR: unresolved name `MethodCall` [E0425]
                    ^~~~~~~~~~
z.rs:6:14: 6:24 help: run `rustc --explain E0423` to see a detailed explanation
z.rs:6:14: 6:24 help: did you mean to write: `MethodCall { /* fields */ }`?

@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

I believe the error message today indicates the problem fairly well, though it could show the Foo::foo form, so not closing.

struct Foo;

impl Foo {
    fn foo() {
    }
}

fn bar() {
    Foo.foo();
}
error[E0599]: no method named `foo` found for type `Foo` in the current scope
 --> test.rs:9:9
  |
9 |     Foo.foo();
  |         ^^^
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: candidate #1 is defined in an impl for the type `Foo`
 --> test.rs:4:5
  |
4 | /     fn foo() {
5 | |     }
  | |_____^

error: aborting due to previous error(s)

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
bors added a commit that referenced this issue Aug 16, 2017
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 C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

5 participants