diff options
| author | bors <bors@rust-lang.org> | 2023-08-28 20:29:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-28 20:29:42 +0000 |
| commit | b97eaab558bd37f665b10a79fd5aecea3dde920f (patch) | |
| tree | c9df2bb8a6f2391d1302454d9bc19ec8937115b0 /compiler/rustc_mir_transform/src/coverage/debug.rs | |
| parent | 5cc5f2789912f3516b37c7e79887feafa768cc44 (diff) | |
| parent | f80c55deb58424e19de1a43c7a4d7a9ab70030c9 (diff) | |
| download | rust-b97eaab558bd37f665b10a79fd5aecea3dde920f.tar.gz rust-b97eaab558bd37f665b10a79fd5aecea3dde920f.zip | |
Auto merge of #11387 - y21:issue11371, r=blyxyas
[`unnecessary_unwrap`]: lint on `.as_ref().unwrap()`
Closes #11371
This turned out to be a little more code than I originally thought, because the lint also makes sure to not lint if the user tries to mutate the option:
```rs
if option.is_some() {
option = None;
option.unwrap(); // don't lint here
}
```
... which means that even if we taught this lint to recognize `.as_mut()`, it would *still* not lint because that would count as a mutation. So we need to allow `.as_mut()` calls but reject other kinds of mutations.
Unfortunately it doesn't look like this is possible with `is_potentially_mutated` (seeing what kind of mutation happened).
This replaces it with a custom little visitor that does basically what it did before, but also allows `.as_mut()`.
changelog: [`unnecessary_unwrap`]: lint on `.as_ref().unwrap()`
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions
