Skip to content

Shadowing of types via Generic Parameter #380

@Havvy

Description

@Havvy
struct Foo {}

struct<Foo> Bar { f: Foo }

Should warn that Foo in Bar shadows the struct Foo declared previously.

Summary Notes

Generated by triagebot, see help for how to add more

Activity

added
E-hardCall for participation: This a hard problem and requires more experience or effort to work on
T-middleType: Probably requires verifiying types
A-lintArea: New lints
on Oct 12, 2015
samueltardieu

samueltardieu commented on May 8, 2025

@samueltardieu
Member

In modern Rust, a test-case could be

struct Foo;
struct Bar<Foo> { f: Foo };

Also, with today's compiler structure, working with a HIR visitor should be enough to detect such shadowing.

@rustbot label +good-first-issue -E-hard -T-middle
@rustbot note test-case-example

added
good first issueThese issues are a good way to get started with Clippy
and removed
E-hardCall for participation: This a hard problem and requires more experience or effort to work on
T-middleType: Probably requires verifiying types
on May 8, 2025
linked a pull request that will close this issue on Jun 22, 2025
devodev

devodev commented on Jun 22, 2025

@devodev

I'd like to try and tackle this as my first contribution.

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @samueltardieu@Havvy@Manishearth@rustbot@devodev

    Issue actions

      Shadowing of types via Generic Parameter · Issue #380 · rust-lang/rust-clippy