Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected "unreachable expression" warning in function with a loop #52

Closed
nicholasbishop opened this issue May 9, 2020 · 2 comments
Closed

Comments

@nicholasbishop
Copy link

Example code:

use fehler::throws;
use std::io::Error;

fn no_warning() -> Result<(), Error> {
    loop {
        return Ok(());
    }
}

#[throws]
fn unexpected_warning() {
    loop {
        return;
    }
}

fn main() {
    no_warning().unwrap();
    unexpected_warning().unwrap();
}

Gives this warning:

warning: unreachable expression
  --> src/main.rs:10:1
   |
10 |   #[throws]
   |   ^^^^^^^^^ unreachable expression
11 |   fn unexpected_warning() {
12 | /     loop {
13 | |         return;
14 | |     }
   | |_____- any code following this expression is unreachable
   |
   = note: `#[warn(unreachable_code)]` on by default
   = note: this warning originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
$ rustc --version
rustc 1.43.0 (4fb7144ed 2020-04-20)
@withoutboats
Copy link
Owner

Can you build against git master of fehler and confirm if this warning is still given?

@nicholasbishop
Copy link
Author

Looks like it's fixed in master, specifically in df2e3d4. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants