diff options
| author | bors <bors@rust-lang.org> | 2024-10-29 22:27:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-29 22:27:34 +0000 |
| commit | 15ad8245b23cdb537454b3fb6f34d5c96a6a35ea (patch) | |
| tree | c47c3282d6be0a10aca0f150fcf36be5c4c146d5 /compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp | |
| parent | 35a7095d8c440663b1beb77bafb12b0f3d482b43 (diff) | |
| parent | acc3842d438028bf5649e9715b74791ea4ec6c83 (diff) | |
| download | rust-15ad8245b23cdb537454b3fb6f34d5c96a6a35ea.tar.gz rust-15ad8245b23cdb537454b3fb6f34d5c96a6a35ea.zip | |
Auto merge of #13034 - rspencer01:trivial_map_over_range, r=y21
Add new `trivial_map_over_range` lint
This lint checks for code that looks like
```rust
let something : Vec<_> = (0..100).map(|_| {
1 + 2 + 3
}).collect();
```
which is more clear as
```rust
let something : Vec<_> = std::iter::repeat_with(|| {
1 + 2 + 3
}).take(100).collect();
```
That is, a map over a range which does nothing with the parameter passed to it is simply a function (or closure) being called `n` times and could be more semantically expressed using `take`.
- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`
changelog: new lint: [`trivial_map_over_range`] `restriction`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
