From d75cacc601891eb89318b3c483b3fcfb0535f0f8 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 7 Apr 2021 01:26:22 +0200 Subject: Use stdx::always --- crates/ide/src/typing.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs index b0234d7fd..c1bdc51b0 100644 --- a/crates/ide/src/typing.rs +++ b/crates/ide/src/typing.rs @@ -79,7 +79,7 @@ fn on_char_typed_inner(file: &SourceFile, offset: TextSize, char_typed: char) -> /// Inserts a closing `}` when the user types an opening `{`, wrapping an existing expression in a /// block. fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option { - assert_eq!(file.syntax().text().char_at(offset), Some('{')); + stdx::always!(file.syntax().text().char_at(offset) == Some('{')); let brace_token = file.syntax().token_at_offset(offset).right_biased()?; let block = ast::BlockExpr::cast(brace_token.parent()?)?; @@ -90,7 +90,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option { // Use the expression span to place `}` before the `;` it.expr()?.syntax().text_range().end() - }, + } None => block.tail_expr()?.syntax().text_range().end(), _ => return None, } @@ -103,7 +103,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option Option { - assert_eq!(file.syntax().text().char_at(offset), Some('=')); + stdx::always!(file.syntax().text().char_at(offset) == Some('=')); let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?; if let_stmt.semicolon_token().is_some() { return None; @@ -125,7 +125,7 @@ fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option { /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option { - assert_eq!(file.syntax().text().char_at(offset), Some('.')); + stdx::always!(file.syntax().text().char_at(offset) == Some('.')); let whitespace = file.syntax().token_at_offset(offset).left_biased().and_then(ast::Whitespace::cast)?; @@ -154,7 +154,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option { /// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }` fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option { let file_text = file.syntax().text(); - assert_eq!(file_text.char_at(offset), Some('>')); + stdx::always!(file_text.char_at(offset) == Some('>')); let after_arrow = offset + TextSize::of('>'); if file_text.char_at(after_arrow) != Some('{') { return None; -- cgit v1.2.3