Skip to content

Excess semicolon lint produces wrong diagnostics with async main and derive macro #63947

Closed
@Kobzol

Description

@Kobzol

The new lint for excess semicolons (#62984) has some weird behaviour when the lint is triggered inside an async function that is transformed using a procedural macro.

Rustc version: 1.39.0-nightly (9b91b9c 2019-08-26)

Compiling this:

#[tokio::main]
async fn main() -> Result<(), ()> {
    let mut workers = 5;;
    Ok(())
}

gives this output:

warning: unused variable: `workers`
 --> examples/test.rs:1:1
  |
1 | #[tokio::main]
  | ^ help: consider prefixing with an underscore: `_workers`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
 --> examples/test.rs:1:1
  |
1 | #[tokio::main]
  | ^ help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

note how the spans are all targeting the procedural macro instead of the correct line.

If I remove the procedural macro or if I remove the excess semicolon, the spans are fine. This leads me to believe that it's an error in the lint, not in the macro, but maybe I'm wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions