Skip to content

async fn() -> ! triggers "unreachable expression" warning #266

@dtolnay

Description

@dtolnay
#![feature(never_type)]

use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    async fn f() -> !;
}

#[async_trait]
impl Trait for () {
    async fn f() -> ! {
        loop {
            std::thread::sleep(std::time::Duration::from_millis(1));
        }
    }
}
warning: unreachable expression
  --> src/lib.rs:10:1
   |
10 | #[async_trait]
   | ^^^^^^^^^^^^^^
   | |
   | unreachable expression
   | any code following this expression is unreachable
   |
   = note: `#[warn(unreachable_code)]` on by default
   = note: this warning originates in the attribute macro `async_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions