Skip to content

type_repetition_in_bounds should not trigger on macro-generated code #4326

Closed
@dtolnay

Description

@dtolnay

See an example from Serde in serde-rs/serde#1595.

I consider this a false positive because in code generators we optimize for readability of the macro code, not readability of the code that gets generated.

As a simple example, a macro might want to add a where-clause:

generics.where_clause.predicates.push(parse_quote!(#param: Serialize));

It wouldn't make sense here to have extra logic to detect whether the where-clause in the macro input happens to already have some bounds on the same type parameter and if so then insert bounds into the same predicate, otherwise add a new predicate.

Mentioning @xd009642, @oli-obk, @flip1995 from #3766.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-macrosType: Issues with macros and macro expansiongood 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

    No branches or pull requests

    Issue actions