rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

`single_range_in_vec_init` should detect all kind of ranges

Open samueltardieu opened this issue 10 months ago • 13 comments

Description

Right now, it looks like only a..b ranges are recognized. ..a, a.., and a..=b won't trigger the lint.

clippy_utils::higher::Range might be useful here.

Version

rustc 1.95.0-nightly (366a1b93e 2026-02-03)
binary: rustc
commit-hash: 366a1b93e7f466ebe559477add05f064873d0c71
commit-date: 2026-02-03
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Additional Labels

No response

samueltardieu avatar Feb 04 '26 13:02 samueltardieu

Possible reproducer: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=ed39f90831f528bc21f5db251ca604c6

From the reddit thread where the bug was discussed: https://www.reddit.com/r/rust/s/OyVxUVoahT

JSorngard avatar Feb 05 '26 05:02 JSorngard

Possible reproducer: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=ed39f90831f528bc21f5db251ca604c6

I would even expect single_element_loop in this example. A better reproducer for the current issue would be akin _ = [..10];.

samueltardieu avatar Feb 05 '26 06:02 samueltardieu

@rustbot claim

Carlos-Chong200 avatar Feb 08 '26 09:02 Carlos-Chong200

Hi @samueltardieu ! I’m interested in working on this issue.
Is it still open and looking for a contribution?

Carlos-Chong200 avatar Feb 08 '26 09:02 Carlos-Chong200

Sure

samueltardieu avatar Feb 08 '26 10:02 samueltardieu

Hi!

@samueltardieu If Carlos is done with it, would it be okay for me to take over?

zayutaha avatar Feb 19 '26 08:02 zayutaha

If Carlos is done with it, would it be okay for me to take over?

Sure!

samueltardieu avatar Feb 19 '26 08:02 samueltardieu

@rustbot claim

zayutaha avatar Feb 20 '26 03:02 zayutaha

@rustbot claim, Hi @zayutaha @samueltardieu I am interested in helping with this. I see this is currently assigned, so I do not want to duplicate work. If the assignee is no longer working on it, I can pick up the task.

arunsingh avatar May 18 '26 15:05 arunsingh

Error: Parsing assign command in comment failed: expected end of command when parsing: claim[!], Hi @zayu

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

rustbot avatar May 18 '26 15:05 rustbot

Hi @arunsingh, they didn’t respond to the pull request, which is why there hasn’t been any activity. I’m going to give it another try, and if they still don’t respond, you can have it.

zayutaha avatar May 19 '26 06:05 zayutaha

Hi @arunsingh, I reached out again but didn’t get a response, so I think it makes sense to hand this over. Feel free to pick it up if you’d still like to work on it.

zayutaha avatar May 29 '26 09:05 zayutaha

thanks @zayutaha, fine I will take this issue

arunsingh avatar Jun 02 '26 17:06 arunsingh