Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

False positive for unnecessary_filter_map #4434

Closed
emabee opened this issue Aug 22, 2019 · 1 comment
Closed

False positive for unnecessary_filter_map #4434

emabee opened this issue Aug 22, 2019 · 1 comment

Comments

@emabee
Copy link

emabee commented Aug 22, 2019

cargo clippy -V
clippy 0.0.212 (e3cb40e 2019-06-25)

A warning is produced from

#[warn(clippy::unnecessary_filter_map)]
let errors: Vec<ServerError> = server_errors
    .into_iter()
    .filter_map(|se| match se.severity() {
        Severity::Warning => {
            self.warnings.push(se);
            None
        }
        _ => Some(se),
    })
    .collect();

The code splits moves some items from one collection into a second. If I'd use filter, as recommended, then I would have to clone the ses, and discard the original instances.

@ghost
Copy link

ghost commented Aug 22, 2019

duplicate of #4433 .
please close 😉

@phansch phansch closed this as completed Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants