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

Should Result::ok() be #[must_use]? #138413

Closed
Kyuuhachi opened this issue Mar 12, 2025 · 1 comment
Closed

Should Result::ok() be #[must_use]? #138413

Kyuuhachi opened this issue Mar 12, 2025 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Kyuuhachi
Copy link
Contributor

Code

fn main() {
    fallible().ok();
}

fn fallible() -> Result<(), ()> { unimplemented!() }

Current output

None

Desired output

warning: unused return value of `ok` that must be used

Rationale and extra context

Same for Result::err() of course. Option::ok_or() is already must_use since it returns Result.

Other cases

Rust Version

1.85.0 on playground

Anything else?

No response

@Kyuuhachi Kyuuhachi added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 12, 2025
@slanterns
Copy link
Contributor

duplicate of #66116.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants