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

Add must_use to Error constructors #229

Merged
merged 5 commits into from Mar 7, 2022
Merged

Add must_use to Error constructors #229

merged 5 commits into from Mar 7, 2022

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Mar 7, 2022

This catches the following bug:

use anyhow::anyhow;

fn main() -> anyhow::Result<()> {
    if true {
        // meant to write bail!
        anyhow!("it failed");
    }
    Ok(())
}
warning: unused return value of `must_use` that must be used
 --> tests/ui/must-use.rs:8:9
  |
8 |         anyhow!("it failed");
  |         ^^^^^^^^^^^^^^^^^^^^

@dtolnay dtolnay merged commit c8a3e42 into master Mar 7, 2022
@dtolnay dtolnay deleted the must_use branch March 7, 2022 20:52
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

Successfully merging this pull request may close these issues.

None yet

1 participant