Skip to content

make unwrap_used also trigger on .get().unwrap() #8125

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
wants to merge 1 commit into from

Conversation

doy
Copy link

@doy doy commented Dec 15, 2021

Please write a short comment explaining your change (or "none" for internal only changes)

changelog: Fix the [unwrap_used] lint to also trigger for code of the form .get(i).unwrap() and .get_mut(i).unwrap()

fixes #8124

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @giraffate (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 15, 2021
Comment on lines +23 to +47
#[warn(clippy::get_unwrap)]
fn unwrap_get2() {
let v = vec![1, 2, 3];
let _ = v.get(0).unwrap();
}

#[warn(clippy::get_unwrap)]
fn unwrap_get_mut2() {
let mut v = vec![1, 2, 3];
let _ = v.get_mut(0).unwrap();
}

#[warn(clippy::get_unwrap)]
#[allow(clippy::unwrap_used)]
fn unwrap_get3() {
let v = vec![1, 2, 3];
let _ = v.get(0).unwrap();
}

#[warn(clippy::get_unwrap)]
#[allow(clippy::unwrap_used)]
fn unwrap_get_mut3() {
let mut v = vec![1, 2, 3];
let _ = v.get_mut(0).unwrap();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to tet get_unwrap in this file. It's tested in tests/ui/get_unwrap.rs.

@giraffate
Copy link
Contributor

@doy ping from triage. There are still things that needs to be fixed. Any questions on how to proceed with this?

@bors
Copy link
Contributor

bors commented Jan 12, 2022

☔ The latest upstream changes (presumably #8198) made this pull request unmergeable. Please resolve the merge conflicts.

@giraffate
Copy link
Contributor

@doy ping from triage. According to the triage procedure, I'm closing this because 2 weeks have passed with no activity. If you have more time to work on this, feel free to reopen this.

@giraffate giraffate closed this Jan 28, 2022
@giraffate giraffate added S-inactive-closed Status: Closed due to inactivity and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 28, 2022
@tamaroning
Copy link
Contributor

tamaroning commented Jan 28, 2022

Hi. Can I make a new PR to complete this?

@xFrednet
Copy link
Member

xFrednet commented Jan 28, 2022

Hey @tamaroning, sure that would be appreciated. You have also already assigned yourself to the issue. Let us know if you need any help :) 🙃

@jonboh
Copy link
Contributor

jonboh commented Oct 10, 2023

@rustbot label -S-inactive-closed

@rustbot rustbot removed the S-inactive-closed Status: Closed due to inactivity label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unwrap_used not triggered when chained from get() or get_mut()
8 participants