mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
b97eaab558
[`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()` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |