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

lint is applied twice to function if it's async #7517

Closed
hellow554 opened this issue Jul 30, 2021 · 2 comments · Fixed by #7534
Closed

lint is applied twice to function if it's async #7517

hellow554 opened this issue Jul 30, 2021 · 2 comments · Fixed by #7534
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@hellow554
Copy link
Contributor

hellow554 commented Jul 30, 2021

I tried this code:

108 lines of code
#![warn(clippy::too_many_lines)]

pub async fn foo()  {
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
    let _a = 0;
}

fn main() {}

(Playground)

I expected to see this happen:
One single warning that the function contains two many lines:

Instead, this happened:
Two warnings with a different starting span

warning: this function has too many lines (103/100)
   --> src/main.rs:3:1
    |
3   | / pub async fn foo()  {
4   | |     let _a = 0;
5   | |     let _a = 0;
6   | |     let _a = 0;
...   |
104 | |     let _a = 0;
105 | | }
    | |_^
    |
note: the lint level is defined here
   --> src/main.rs:1:9
    |
1   | #![warn(clippy::too_many_lines)]
    |         ^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines

warning: this function has too many lines (101/100)
   --> src/main.rs:3:21
    |
3   |   pub async fn foo()  {
    |  _____________________^
4   | |     let _a = 0;
5   | |     let _a = 0;
6   | |     let _a = 0;
...   |
104 | |     let _a = 0;
105 | | }
    | |_^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines

Meta

  • cargo clippy -V: 0.1.56 (2021-07-29 4927238)
  • rustc -Vv:
rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-unknown-linux-gnu
release: 1.54.0
LLVM version: 12.0.1
@hellow554 hellow554 added the C-bug Category: Clippy is not doing the correct thing label Jul 30, 2021
@giraffate giraffate added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Aug 3, 2021
@giraffate
Copy link
Contributor

It seems not to check FnKind::Closure.

@giraffate giraffate added the good-first-issue These issues are a good way to get started with Clippy label Aug 3, 2021
@LeSeulArtichaut
Copy link
Contributor

LeSeulArtichaut commented Aug 5, 2021

@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 C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants