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

elseif being shown, when it doesn't exist. #7318

Closed
MGlolenstine opened this issue Jun 4, 2021 · 1 comment · Fixed by #8729
Closed

elseif being shown, when it doesn't exist. #7318

MGlolenstine opened this issue Jun 4, 2021 · 1 comment · Fixed by #8729
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@MGlolenstine
Copy link

MGlolenstine commented Jun 4, 2021

I tried this code:

let index = if let Ok(index) = index.parse::<i32>(){
    index
}else{
    if let Ok(id) = a.property("id") {
        let id = id.get::<&str>().unwrap();
        println!("id: {}", id);
        let id = &id[2..];
        id.parse::<i32>().unwrap()
    }else{
        -1
    }
};

I expected to see this happen: I expected to be warned about turning it into }else if let

help: collapse nested if block
   |
64 |                 }else if let Ok(id) = a.property("id") {
65 |                     let id = id.get::<&str>().unwrap();
66 |                     println!("id: {}", id);
67 |                     let id = &id[2..];
68 |                     id.parse::<i32>().unwrap()
69 |                 }else{

Instead, this happened: Instead, I got }elseif let.

help: collapse nested if block
   |
64 |                 }elseif let Ok(id) = a.property("id") {
65 |                     let id = id.get::<&str>().unwrap();
66 |                     println!("id: {}", id);
67 |                     let id = &id[2..];
68 |                     id.parse::<i32>().unwrap()
69 |                 }else{

Meta

  • cargo clippy -V: clippy 0.1.52 (9bc8c42 2021-05-09)
  • rustc -Vv:
rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0
@MGlolenstine MGlolenstine added the C-bug Category: Clippy is not doing the correct thing label Jun 4, 2021
@Serial-ATA
Copy link
Contributor

@rustbot claim

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

Successfully merging a pull request may close this issue.

2 participants