Skip to content

Confusing error with :: on struct #10551

Closed
@comex

Description

@comex

The following code was my incorrect attempt to explicitly specialize a static method:

trait Test {
    fn hello();
}

fn main() {
    struct T;
    impl Test for T {
        fn hello() {}
    }
    T::hello();
}

In fact, apparently the fn is not yet possible to call at all. However, the error output is needlessly confusing with an error!() message and three errors:

!!! (resolving module in lexical scope) module wasn't actually a module!
/tmp/r.rs:10:4: 10:12 error: unresolved name
/tmp/r.rs:10     T::hello();
                 ^~~~~~~~
/tmp/r.rs:10:4: 10:12 error: use of undeclared module `T`
/tmp/r.rs:10     T::hello();
                 ^~~~~~~~
!!! (resolving module in lexical scope) module wasn't actually a module!
/tmp/r.rs:10:4: 10:12 error: unresolved name `T::hello`.
/tmp/r.rs:10     T::hello();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions