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

Clippy suggests invalid code as being better (useless_let_if_seq) #975

Closed
dhylands opened this issue Jun 3, 2016 · 1 comment
Closed
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@dhylands
Copy link

dhylands commented Jun 3, 2016

I'm using clippy 0.0.71

I have this code snippet:

        let mut udn = try_get!(service.description, "/root/device/UDN").clone();
        if udn.starts_with("uuid:") {
            udn = String::from(&udn[5..]);
        }

and clippy suggests that I should use the following code, which is clearly incorrect:

src/adapters/ip_camera/upnp_listener.rs:57:9: 63:10 warning: `if _ { .. } else { .. }` is an expression
src/adapters/ip_camera/upnp_listener.rs:57         let mut udn = try_get!(service.description, "/root/device/UDN").clone();
                                                   ^
src/main.rs:18:9: 18:27 note: lint level defined here
src/main.rs:18 #![warn(useless_let_if_seq)]
                       ^~~~~~~~~~~~~~~~~~
src/adapters/ip_camera/upnp_listener.rs:57:9: 63:10 help: it is more idiomatic to write
src/adapters/ip_camera/upnp_listener.rs:           let <mut> udn = if udn.starts_with("uuid:") { String::from(&udn[5..]) } else { try_get!(service.description, "/root/device/UDN").clone() };
src/adapters/ip_camera/upnp_listener.rs:57:9: 63:10 note: you might not need `mut` at all
src/adapters/ip_camera/upnp_listener.rs:57:9: 63:10 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#useless_let_if_seq

For reference, the complete code is here:
https://github.com/fxbox/foxbox/blob/master/src/adapters/ip_camera/upnp_listener.rs#L57-L63

@mcarton mcarton added the C-bug Category: Clippy is not doing the correct thing label Jun 3, 2016
@mcarton mcarton self-assigned this Jun 3, 2016
@mcarton
Copy link
Member

mcarton commented Jun 3, 2016

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants