Skip to content

Bad spans from type error within code expanded from proc macro attribute #71968

Closed
tokio-rs/tokio
#3766
@euclio

Description

@euclio

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7d0f526db1b816572e927bbaaad2750e

#[tokio::main]
async fn main() {
    Ok(())
}

I expected to see this happen: Type error reported on Ok(())

Instead, this happened: Got this diagnostic:

error[E0308]: mismatched types
 --> src/main.rs:1:1
  |
1 | #[tokio::main]
  | ^^^^^^^^^^^^^^- help: try adding a semicolon: `;`
  | |
  | expected `()`, found enum `std::result::Result`
  |
  = note: expected unit type `()`
                  found enum `std::result::Result<(), _>`
  = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (1836e3b42 2020-05-06)
binary: rustc
commit-hash: 1836e3b42a5b2f37fd79104eedbe8f48a5afdee6
commit-date: 2020-05-06
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-proc-macrosArea: Procedural macrosC-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