Skip to content

Struct constructors can resolve to structs that are shadowed by type parameters #32120

Closed
@jseyfried

Description

@jseyfried

For example,

struct T { i: i32 }
impl T {
    fn new() -> Self { unimplemented!() }
}

fn f<T>() {
    let t = T { i: 0 }; // This use of `T` refers to the struct
    let t = T::new(); // This use of `T` refers to the type parameter (and so is an error)
}

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