mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
fca1f9aec5
[`unnecessary_literal_unwrap`]: Fix ICE on None.unwrap_or_default() Fixes #11099 Fixes #11064 I'm running into #11099 (cc `@y21)` on my Rust codebase. Clippy ICEs on this code when evaluating the `unnecessary_literal_unwrap` lint: ```rust fn main() { let val1: u8 = None.unwrap_or_default(); } ``` This fixes that ICE and adds an message specifically for that case: ``` error: used `unwrap_or_default()` on `None` value --> $DIR/unnecessary_literal_unwrap.rs:26:5 | LL | None::<String>.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `String::default()` ``` This PR also fixes the same ICE with `None.unwrap_or_else` (by giving the generic error message for the lint in that case). changelog: Fix ICE in `unnecessary_literal_unwrap` on `None.unwrap_or_default()` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |