dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.84k stars 85 forks source link

Fix unreachable code warning for functions that return `!` #265

Closed de-vri-es closed 7 months ago

de-vri-es commented 7 months ago

The generated code for function bodies produces an unreachable_code warning if the function has a ! return type.

The offending bit is:

if let Some(__ret) == None::<!> {
  // unreachable
}

This PR fixes the warning by simply adding #[allow(unreachable_code)] to the return statement. It also adds a test for it.

This problem can only be triggered on nightly with the never_type feature enabled, but it is easy to fix here.

dtolnay commented 7 months ago

Published in async-trait 0.1.80.