Awaiting a function returning a never type does not raise unreachable code after the await. Is this a rust or a tokio issue? #6736
-
Hi guys I recently noticed that if you pub async fn endless() -> ! {
loop {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
}
pub async fn does_not_warn_unreachable() {
endless().await;
println!("Hello, world!"); // No warning
} compiles without a warning, but the non-async version pub fn endless() -> ! {
loop {
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
pub fn warns_unreachable() {
endless();
println!("Hello, world!"); // warning: unreachable statement
} warns about an unreachable statement after Is this a general rust Thanks for your help :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Please file a bug with the Rust compiler instead. |
Beta Was this translation helpful? Give feedback.
-
Moved to rust-lang/rust#128434 |
Beta Was this translation helpful? Give feedback.
Please file a bug with the Rust compiler instead.