Skip to content

shadowed trait in a generic argument causes incorrect name resolution. #10707

Closed
@jhgg

Description

@jhgg

Consider this code:

trait A {
    fn woop(&self);
}
trait B {
    const X: usize;
    fn woop(&self);
}

impl<A> B for A
where
    A: B,
{
    const X: usize = 1;

    fn woop(&self) {
        println!("{}", A::X);
        //             ^ this is considered as `trait A` not the generic param `A` by r-a.
    }
}

fn main() {}

See:

image

This also impacts rename, which gets a tad confused:

2021-11-05_14-40-02

Rustc however does resolve this properly and the program provided compiles fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-nameresname, path and module resolutionC-bugCategory: bugS-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions