Skip to content

Calling a static method on a type alias for a generic struct does not compile #19130

Closed
@donkopotamus

Description

@donkopotamus

Suppose a type declaration is used to provide a shorter name for a specific example of a generic struct

struct X<T>;

impl<T> X<T> {
    fn go() -> int {-1}
}

struct A;
type Alias = X<A>;

then its not possible to call a static method via Alias

fn main() {
    let a = X::<A>::go();  // Works
    let b = Alias::go();   // Won't compile - error: failed to resolve. Use of undeclared module `Alias`
}

Should the compiler expand type declarations in path expressions (ie Alias => X::<T>)?

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