Skip to content

Unused result lint should not fail if the result is contained by a struct #15681

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

Closed
carllerche opened this issue Jul 15, 2014 · 1 comment
Closed
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@carllerche
Copy link
Member

In my opinion, the following should not fail:

#![deny(unused_result)]

pub struct Zomg {
    res: Result<(), ()>
}

fn zomg() -> Zomg {
    Zomg { res: Ok(()) }
}

pub fn main() {
    zomg();
}
@huonw huonw added the A-lint label Jul 15, 2014
@alexcrichton
Copy link
Member

There are actually two lints in play here, the unused_result and unused_must_use lint. The latter is turned on by default, whereas the former is not turned on by default.

The unused_result lint is much broader than the unused_must_use lint where it applies to any type, not just those marked with #[must_use]. In this example you're opting-in to the more strict semantics instead of relying on just unused_must_use.

Just the must-use lint will not warn about this program, so I'm going to close this as working as intended.

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
Add config option to use `rust-analyzer` specific target dir

Adds a Rust Analyzer configuration option to set a custom target directory for builds. This is a workaround for Rust Analyzer blocking debug builds while running `cargo check`. This change should close rust-lang#6007.

This is my first time contributing to this project, so any feedback regarding best practices that I'm not aware of are greatly appreciated! Thanks to all the maintainers for their hard work on this project and reviewing contributions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants