- Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
The explicit_counter_loop
lint is incorrectly triggered in this case:
let vec = vec![1,2,3]; let mut index = 0; for _v in &vec { index += 1 } run(|| { println!("index: {}", index); })
This is incorrect because the counter is used after the loop. Note that if the counter were used directly and not in a closure, the lint would not get triggered.
Rust playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3f1f1216aa7a4344d6891fc9e4ccdd5c
> cargo clippy -V clippy 0.0.212 (3aea860 2019-09-03)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy