Skip to content

Commit

Permalink
Silence generated unreachable code.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Feb 4, 2021
1 parent 74005b7 commit f2c8b9a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/expand.rs
Expand Up @@ -321,6 +321,7 @@ fn transform_block(
#(#stmts)*
};

#[allow(unreachable_code)]
__ret
})
);
Expand Down
1 change: 0 additions & 1 deletion tests/test.rs
Expand Up @@ -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!()
Expand Down
20 changes: 20 additions & 0 deletions 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() {}
14 changes: 14 additions & 0 deletions tests/ui/unreachable.stderr
@@ -0,0 +1,14 @@
error: unreachable statement
--> $DIR/unreachable.rs:16:9
|
15 | let y = unimplemented!();
| ---------------- any code following this expression is unreachable
16 | let z = y;
| ^^^^^^^^^^ unreachable statement
|
note: the lint level is defined here
--> $DIR/unreachable.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unreachable_code)]` implied by `#[deny(warnings)]`

0 comments on commit f2c8b9a

Please sign in to comment.