Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type_repetition_in_bounds should not trigger on macro-generated code #4326

Closed
dtolnay opened this issue Aug 2, 2019 · 0 comments · Fixed by #5761
Closed

type_repetition_in_bounds should not trigger on macro-generated code #4326

dtolnay opened this issue Aug 2, 2019 · 0 comments · Fixed by #5761
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have T-macros Type: Issues with macros and macro expansion

Comments

@dtolnay
Copy link
Member

dtolnay commented Aug 2, 2019

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.

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion labels Aug 3, 2019
bors added a commit that referenced this issue Aug 18, 2019
…h,flip1995

Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come
bors added a commit that referenced this issue Aug 18, 2019
…h,flip1995

Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come

changelog: move `type_repetition_in_bounds` to `pedantic`
@bors bors closed this as completed in fff8e72 Jul 3, 2020
@bors bors closed this as completed in #5761 Jul 3, 2020
@rustbot rustbot added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants