Skip to content

Commit d75cacc

Browse files
Use stdx::always
1 parent 61e292f commit d75cacc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/ide/src/typing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn on_char_typed_inner(file: &SourceFile, offset: TextSize, char_typed: char) ->
7979
/// Inserts a closing `}` when the user types an opening `{`, wrapping an existing expression in a
8080
/// block.
8181
fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
82-
assert_eq!(file.syntax().text().char_at(offset), Some('{'));
82+
stdx::always!(file.syntax().text().char_at(offset) == Some('{'));
8383
let brace_token = file.syntax().token_at_offset(offset).right_biased()?;
8484
let block = ast::BlockExpr::cast(brace_token.parent()?)?;
8585

@@ -90,7 +90,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
9090
Some(ast::Stmt::ExprStmt(it)) => {
9191
// Use the expression span to place `}` before the `;`
9292
it.expr()?.syntax().text_range().end()
93-
},
93+
}
9494
None => block.tail_expr()?.syntax().text_range().end(),
9595
_ => return None,
9696
}
@@ -103,7 +103,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
103103
/// this works when adding `let =`.
104104
// FIXME: use a snippet completion instead of this hack here.
105105
fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
106-
assert_eq!(file.syntax().text().char_at(offset), Some('='));
106+
stdx::always!(file.syntax().text().char_at(offset) == Some('='));
107107
let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?;
108108
if let_stmt.semicolon_token().is_some() {
109109
return None;
@@ -125,7 +125,7 @@ fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
125125

126126
/// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
127127
fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
128-
assert_eq!(file.syntax().text().char_at(offset), Some('.'));
128+
stdx::always!(file.syntax().text().char_at(offset) == Some('.'));
129129
let whitespace =
130130
file.syntax().token_at_offset(offset).left_biased().and_then(ast::Whitespace::cast)?;
131131

@@ -154,7 +154,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
154154
/// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }`
155155
fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
156156
let file_text = file.syntax().text();
157-
assert_eq!(file_text.char_at(offset), Some('>'));
157+
stdx::always!(file_text.char_at(offset) == Some('>'));
158158
let after_arrow = offset + TextSize::of('>');
159159
if file_text.char_at(after_arrow) != Some('{') {
160160
return None;

0 commit comments

Comments
 (0)