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

suspiciously_else_formatting triggered for right code #7024

Closed
jdortiz opened this issue Apr 3, 2021 · 3 comments
Closed

suspiciously_else_formatting triggered for right code #7024

jdortiz opened this issue Apr 3, 2021 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@jdortiz
Copy link

jdortiz commented Apr 3, 2021

Lint name:
suspiciously_else_formatting

I tried this code:

#[post("/login", format = "application/json", data = "<user>")]
pub fn login(user: Json<User>) -> Result<Json<Token>, Status> {
    //! Some comment
    //! Some other comment
    let user = user.into_inner();
    if let Some(token) = security::login(user) {
        Ok(Json(Token { token }))
    } else {
        Err(Status::Unauthorized)
    }
}

I expected to see this happen: No warning emitted

Instead, this happened: This warning emitted

warning: this is an `else {..}` but the formatting might hide it
  --> worker-api/src/api/auth.rs:9:1
   |
9  | / pub fn login(user: Json<User>) -> Result<Json<Token>, Status> {
10 | |     //! Some comment
11 | |     //! Some other comment
12 | |     let user = user.into_inner();
...  |
17 | |     }
18 | | }
   | |_^
   |
   = note: `#[warn(clippy::suspicious_else_formatting)]` on by default
   = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting

Meta

  • cargo clippy -V: clippy 0.1.51 (2fd73fab 2021-03-23)
  • rustc -Vv:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-apple-darwin
release: 1.51.0
LLVM version: 11.0.1

@jdortiz jdortiz added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Apr 3, 2021
@phansch phansch self-assigned this Apr 14, 2021
@camsteffen camsteffen added the E-medium Call for participation: Medium difficulty level problem and requires some initial experience. label May 3, 2021
@phansch phansch removed their assignment Aug 26, 2021
@extrawurst
Copy link

sounds related to #6249

@Jarcho
Copy link
Contributor

Jarcho commented Apr 6, 2022

This should have been fixed by #7707

@y21
Copy link
Member

y21 commented Oct 22, 2024

Closing as this no longer reproduces (presumably fixed by the PR that added the proc macro check like the other comments have said)

@y21 y21 closed this as completed Oct 22, 2024
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 E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

6 participants