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

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

Closed
dtolnay opened this issue Apr 11, 2024 · 0 comments · Fixed by #265
Closed

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

dtolnay opened this issue Apr 11, 2024 · 0 comments · Fixed by #265

Comments

@dtolnay
Copy link
Owner

dtolnay commented Apr 11, 2024

#![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)
@dtolnay dtolnay linked a pull request Apr 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant