Skip to content

Calling a static method on a type with no static methods results in "module wasn't actually a module!" error #14225

Closed
@huonw

Description

@huonw
struct Foo;
fn main() {
    Foo::bar();
}
ERROR:rustc::middle::resolve: !!! (resolving module in lexical scope) module wasn't actually a module!
<anon>:18:21: 18:29 error: unresolved name
<anon>:18         struct Foo; Foo::bar()
                              ^~~~~~~~
<anon>:18:21: 18:29 error: use of undeclared module `Foo`
<anon>:18         struct Foo; Foo::bar()
                              ^~~~~~~~
ERROR:rustc::middle::resolve: !!! (resolving module in lexical scope) module wasn't actually a module!
<anon>:18:21: 18:29 error: unresolved name `Foo::bar`.
<anon>:18         struct Foo; Foo::bar()
                              ^~~~~~~~
error: aborting due to 3 previous errors
playpen: application terminated with error code 101

If there is some other static method, then calling a non-existent method gives a sensible "cannot resolve method Foo::bar" error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions