Skip to content

clippy::unused_peekable triggers when peek is called in a closure #9462

New issue

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

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

Already on GitHub? # to your account

Closed
nikomatsakis opened this issue Sep 11, 2022 · 0 comments · Fixed by #9465
Closed

clippy::unused_peekable triggers when peek is called in a closure #9462

nikomatsakis opened this issue Sep 11, 2022 · 0 comments · Fixed by #9465

Comments

@nikomatsakis
Copy link
Contributor

Description

Example code that triggers clippy::unused_peekable (but ought not to):

fn main() {
    let mut x = vec![1, 2, 3].into_iter().peekable();
    let mut y = std::iter::from_fn(move || {
        match x.peek() { _ => () }
        None::<u32>
    });
    y.next();
}

Playground

Version

No response

Additional Labels

No response

@bors bors closed this as completed in 9c9aa92 Sep 14, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 15, 2022
Clippy pre beta branch fix

Before beta is branched on Friday, I want to move the `unused_peekable` lint  that was added in this release cycle (1.65) to `nursery`. This lint was already reported twice (rust-lang/rust-clippy#9456, rust-lang/rust-clippy#9462) in a short time, so it is probably a good idea to fix it before it hits beta and then stable.

r? `@Manishearth`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Sep 22, 2022
Clippy pre beta branch fix

Before beta is branched on Friday, I want to move the `unused_peekable` lint  that was added in this release cycle (1.65) to `nursery`. This lint was already reported twice (rust-lang#9456, rust-lang#9462) in a short time, so it is probably a good idea to fix it before it hits beta and then stable.

r? `@Manishearth`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant