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

ok_unwrap lint #1435

Closed
clarfonthey opened this issue Jan 11, 2017 · 2 comments · Fixed by #8606
Closed

ok_unwrap lint #1435

clarfonthey opened this issue Jan 11, 2017 · 2 comments · Fixed by #8606
Assignees
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-pedantic Lint: Belongs in the pedantic lint group

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Jan 11, 2017

Right now the result_unwrap and option_unwrap lints are allow by default, meaning that result.ok().unwrap() will not be linted, even though result.ok().expect(...) is.

We could also do the same for result.err().unwrap(), suggesting unwrap_err.

This seems like a problem that should be addressed with a new lint which is allow by default.

@clarfonthey
Copy link
Contributor Author

Note: I added a pull request to upstream to suggest adding an expect_err method to Result, allowing us to also lint result.err().expect(...).

bors referenced this issue in rust-lang/rust Jan 14, 2017
expect_err for Result.

This adds an `expect_err` method to `Result`. Considering how `unwrap_err` already exists, this seems to make sense. Inconsistency noted in Manishearth/rust-clippy#1435.
@camsteffen camsteffen added L-pedantic Lint: Belongs in the pedantic lint group good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints labels Nov 14, 2021
@b-ncMN
Copy link
Contributor

b-ncMN commented Mar 27, 2022

@rustbot claim

bors added a commit that referenced this issue Apr 6, 2022
Add [`err_expect`] lint

[`expect_err`] lint

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

Fixes #1435

changelog:
Added a lint to detect usage of .err().expect()
@bors bors closed this as completed in 409a936 Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-pedantic Lint: Belongs in the pedantic lint group
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants