Skip to content

Bug in rust automatic deref for methods of generic traits #48145

@porky11

Description

@porky11

Normally generics should just work like specialized versions, just substituted with the correct type.
For example trait MyTrait<T> {…} is intended to work for a type MyType as if I defined trait MyTrait_MyType {…}.
This doesn't apply, when one specialized version of a generic trait is implemented for a type T, which derefs to U, which implements a different specialization of the same trait.
Then the specialized version for T also shadows the specialized version for U, even if they could both be called on this type.

I made an example to show, what this means here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions