Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #13940 - nlydv:unwrap-panic, r=lnicola
Fix panicking Option unwraping in match arm analysis Hi, first PR here! I've noticed my IDE sometimes briefly becoming pretty slow to respond while writing Rust. When checking the logs I found reams of this same error repeating itself. ``` thread 'Worker' panicked at 'called `Option::unwrap()` on a `None` value' crates/ide-assists/src/handlers/convert_match_to_let_else.rs:90:46 ``` RA seemed to have been panicking on virtually every keystroke I made whenever I was part way through writing/refactoring a match statement of relevance to this assist. The fix in this PR should be self-explanatory.
bors 2023-01-13
parent fb39efe · parent 9721505 · commit c7a3f34
-rw-r--r--crates/ide-assists/src/handlers/convert_match_to_let_else.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ide-assists/src/handlers/convert_match_to_let_else.rs b/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
index 5bf04a3ad3..fbd81c8015 100644
--- a/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
+++ b/crates/ide-assists/src/handlers/convert_match_to_let_else.rs
@@ -87,7 +87,7 @@ fn find_arms(
let mut extracting = None;
let mut diverging = None;
for arm in arms {
- if ctx.sema.type_of_expr(&arm.expr().unwrap()).unwrap().original().is_never() {
+ if ctx.sema.type_of_expr(&arm.expr()?)?.original().is_never() {
diverging = Some(arm);
} else {
extracting = Some(arm);