Skip to content

unwrap_used not triggered when chained from get() or get_mut() #8124

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
doy opened this issue Dec 14, 2021 · 5 comments · Fixed by #8372
Closed

unwrap_used not triggered when chained from get() or get_mut() #8124

doy opened this issue Dec 14, 2021 · 5 comments · Fixed by #8372
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@doy
Copy link

doy commented Dec 14, 2021

Summary

it appears that the unwrap_used lint does not trigger for code of the form foo.get(i).unwrap() or foo.get_mut(i).unwrap()

Lint Name

unwrap_used

Reproducer

I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2ed9ce35f88fd2d4c16151aeed566134

I expected to see this happen:

all three functions should trigger the unwrap_used lint

Instead, this happened:
the second function does not trigger the lint

Version

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
@doy doy added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Dec 14, 2021
@giraffate
Copy link
Contributor

We have the get_unwrap lint, so can you use this?

@doy
Copy link
Author

doy commented Dec 15, 2021

i could, but this still feels like very surprising behavior

@giraffate
Copy link
Contributor

It might be better to merge unwrap_used and get_unwrap like this. It looks good to post on the Clippy zulip channel to get other's opinions.

@giraffate
Copy link
Contributor

@giraffate giraffate added the good-first-issue These issues are a good way to get started with Clippy label Jan 28, 2022
@tamaroning
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
3 participants