From e94ffb118dad3e723bdb82c73dbf6b7ae87203f2 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 3 Feb 2021 18:12:22 -0800 Subject: [PATCH] Silence generated unreachable code. --- src/expand.rs | 1 + tests/test.rs | 1 - tests/ui/unreachable.rs | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/ui/unreachable.rs diff --git a/src/expand.rs b/src/expand.rs index 9dfc895..6d17deb 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -321,6 +321,7 @@ fn transform_block( #(#stmts)* }; + #[allow(unreachable_code)] __ret }) ); diff --git a/tests/test.rs b/tests/test.rs index fe0d8f0..80e44e5 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -216,7 +216,6 @@ pub async fn test_internal_items() { pub async fn test_unimplemented() { #[async_trait] - #[allow(unreachable_code)] pub trait Trait { async fn f() { unimplemented!() diff --git a/tests/ui/unreachable.rs b/tests/ui/unreachable.rs new file mode 100644 index 0000000..f546a58 --- /dev/null +++ b/tests/ui/unreachable.rs @@ -0,0 +1,20 @@ +#![deny(warnings)] + +use async_trait::async_trait; + +#[async_trait] +pub trait Trait { + async fn f() { + unimplemented!() + } +} + +#[async_trait] +pub trait TraitFoo { + async fn f() { + let y = unimplemented!(); + let z = y; + } +} + +fn main() {}