-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New lint [unnecessary_unwrap_unchecked
]
#11139
Conversation
r? @giraffate (rustbot has picked a reviewer for you, use r? to override) |
&& let Some(unchecked_ident) = unchecked_ident(&last_path_segment(&qpath).ident) | ||
&& let Some(unchecked_def_id) = children | ||
.iter() | ||
.find(|child| child.ident == unchecked_ident) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably check if it's a DefKind::Fn
as well
52f2545
to
e42d365
Compare
/// ### What it does | ||
/// Checks for calls to `unwrap_unchecked` when an `_unchecked` variant of the function exists. | ||
/// | ||
/// ### Why is this bad? | ||
/// Calling the `_unchecked` variant instead alleviates a check that's entirely redundant if | ||
/// `unwrap_unchecked` is called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be rewritten...
☔ The latest upstream changes (presumably #11116) made this pull request unmergeable. Please resolve the merge conflicts. |
Hey this is triage, I'm closing this due to inactivity. Currently, @Centri3 sadly doesn't have the time to continue this implementation. If anyone is interested in continuing this PR, you're more than welcome to create a new PR and push it over the finish line. :D Thank you to @Centri3 and the reviewers for the time, that you already put into this! @rustbot label +S-inactive-closed -S-waiting-on-author -S-waiting-on-review |
Triaging my old PRs in case someone wants to pick them up, I don't really think this needs much more work, but we should definitely create utils functions to do this a bit more cleanly. Also, we definitely need a chapter in the book on |
Closes #11108
Really proud of the solution I came up with for this one ^^ didn't expect there to be enough info to generalize this (i.e., not hardcoding
_unchecked
functions)changelog: New lint [
unnecessary_unwrap_unchecked
]#11139