ruff/crates/ruff_macros/src
Micha Reiser 31db1b6e16
Remove long Iterator::chain sequence in RuleCodePrefix::iter (#10452)
## Summary

This PR removes the `Iterator::chain(...)` sequence in
`RuleCodePrefix::iter()` with `Vec::expand` to avoid an
overlong-recursive types.

The existing `RuleCodePrefix::iter` method chains all rule group
iterators together. This leads to very long recursive types
`Chain<Map<Chain<Map<Chain<Map.....>>>>` (proportional to the number of
rule groups).

This PR rewrites the macro to use `Vec::extend` instead, which removes
the long recursive type (at the cost of introducing a potential
allocation).

## Alternatives

An alternative would be to use a stack allocated array by unrolling the
`Linter::iter` methods (generated by `EnumIter`).
I don't think it's worth the extra complexity, considering that
`RuleCodePrefix::iter` isn't a hot function.

## Test Plan

`cargo test`
2024-03-18 16:51:20 +01:00
..
cache_key.rs Add #[automatically_derived] to derived impls (#8080) 2023-10-20 00:12:27 +00:00
combine_options.rs Add #[automatically_derived] to derived impls (#8080) 2023-10-20 00:12:27 +00:00
config.rs Add deprecation message for top-level lint settings (#9582) 2024-02-01 13:35:02 -06:00
derive_message_formats.rs Format let-else with rustfmt nightly (#5461) 2023-07-03 02:13:35 +00:00
lib.rs Spellcheck & grammar (#10375) 2024-03-13 02:34:23 +00:00
map_codes.rs Remove long Iterator::chain sequence in RuleCodePrefix::iter (#10452) 2024-03-18 16:51:20 +01:00
newtype_index.rs remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
rule_code_prefix.rs Add internal hidden rules for testing (#9747) 2024-02-01 08:44:51 -06:00
rule_namespace.rs Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
violation.rs Add #[automatically_derived] to derived impls (#8080) 2023-10-20 00:12:27 +00:00