diff --git a/src/expand.rs b/src/expand.rs index 9b9cf09..8179ee7 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -409,6 +409,7 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { } else { quote! { if let ::core::option::Option::Some(__ret) = ::core::option::Option::None::<#ret> { + #[allow(unreachable_code)] return __ret; } #(#decls)* diff --git a/tests/test.rs b/tests/test.rs index 0d5aacd..e868941 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,6 +1,6 @@ #![cfg_attr( async_trait_nightly_testing, - feature(impl_trait_in_assoc_type, min_specialization) + feature(impl_trait_in_assoc_type, min_specialization, never_type) )] #![deny(rust_2021_compatibility, unused_qualifications)] #![allow( @@ -252,6 +252,25 @@ pub async fn test_unimplemented() { let _ = <() as Trait>::f; } +#[cfg(async_trait_nightly_testing)] +pub async fn test_divering_function() { + #[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)); + } + } + } + + let _ = <() as Trait>::f; +} + // https://github.com/dtolnay/async-trait/issues/1 pub mod issue1 { use async_trait::async_trait;