Unnamed repository; edit this file 'description' to name the repository.
Replace unwrap with expect
Lukas Wirth 2023-10-04
parent 34d3490 · commit c266387
-rw-r--r--crates/ide-assists/src/handlers/apply_demorgan.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ide-assists/src/handlers/apply_demorgan.rs b/crates/ide-assists/src/handlers/apply_demorgan.rs
index 74db300465..2d41243c20 100644
--- a/crates/ide-assists/src/handlers/apply_demorgan.rs
+++ b/crates/ide-assists/src/handlers/apply_demorgan.rs
@@ -219,7 +219,12 @@ pub(crate) fn apply_demorgan_iterator(acc: &mut Assists, ctx: &AssistContext<'_>
.and_then(ast::PrefixExpr::cast)
.filter(|prefix_expr| matches!(prefix_expr.op_kind(), Some(ast::UnaryOp::Not)))
{
- edit.delete(prefix_expr.op_token().unwrap().text_range());
+ edit.delete(
+ prefix_expr
+ .op_token()
+ .expect("prefix expression always has an operator")
+ .text_range(),
+ );
} else {
edit.insert(method_call.syntax().text_range().start(), "!");
}