feat: add unnecessary literal option lint - #17819
Open
born-in-autumn wants to merge 5 commits into
Open
born-in-autumn wants to merge 5 commits into
born-in-autumn wants to merge 5 commits into
Conversation
Collaborator
|
Thanks for the pull request, and welcome! You should hear from one of our reviewers after this PR gets at least 2 reviews from the community. Please see the contribution instructions for more information. |
CommanderStorm
suggested changes
Oct 1, 2026
Contributor
There was a problem hiding this comment.
error: called `unwrap` on `x` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:46:9
... 155 lines skipped ...
| ^^^^^^^^^^^^^^
+error: used `is_some()` on `Some` value
+ --> tests/ui/checked_unwrap/simple_conditionals.rs:45:8
+ |
+LL | if x.is_some() {
+ | ^^^^^^^^^^^
+ |
+help: replace this with `true`
+ --> tests/ui/checked_unwrap/simple_conditionals.rs:44:13
+ |
+LL | let x = Some(());
+ | ^^^^^^^^
+ = note: `-D clippy::unnecessary-literal-option` implied by `-D warnings`
+ = help: to override `-D warnings` add `#[allow(clippy::unnecessary_literal_option)]`
Please go through the dogfooding errors.
You may need to expect(..) this a few times.
Author
thanks for reminding me. I spent some time fixing these CI issues. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17808
.stderrfile)cargo testpasses locallycargo dev update_lintscargo dev fmtLLM disclosure: new contrbutor, everything in this PR was written manually, without LLM assistance
changelog:
The main change is the addition of a new lint, which is based on
unnecessary_literal_unwrap, It adds lint suggestions for several different Option cases where the result is already known. It passes the UI tests. For naming conventions and comments, I followed existing code patterns. No extra logic was added.Thanks for your time!