diff options
| author | bors <bors@rust-lang.org> | 2023-07-20 10:55:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-20 10:55:30 +0000 |
| commit | fca1f9aec544e9b7d6a23827a30d0835a103a124 (patch) | |
| tree | 295e3d0998c522d0ce01f09c7d765e69b656194b /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | fbe292e5634749db0712c14caf2de31955b1699f (diff) | |
| parent | 8d258c15080f23b13b5268ac757c8f71adbe38b6 (diff) | |
| download | rust-fca1f9aec544e9b7d6a23827a30d0835a103a124.tar.gz rust-fca1f9aec544e9b7d6a23827a30d0835a103a124.zip | |
Auto merge of #11106 - syvb:literal_unwrap_ice, r=dswij
[`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()`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
