Skip to content

Document association of generic arguments in path segments #2275

@ehuss

Description

@ehuss

There are some subtle behaviors around where generic arguments can appear in a path, particularly with enum variants. For example:

enum E<T> {
    V1 { x: T },
}

fn main() {
    // These seem to be the same.
    E::V1::<i32> { x: 1 };
    E::<i32>::V1 { x: 1 };
}

Are these exactly the same? I'm wondering if there are other oddities like this? This came up when looking at rust-lang/rust#154971.

#2165 is adding more documentation on generic arguments and how they are associated, but I don't think it covers this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions