@@ -79,7 +79,7 @@ fn on_char_typed_inner(file: &SourceFile, offset: TextSize, char_typed: char) ->
79
79
/// Inserts a closing `}` when the user types an opening `{`, wrapping an existing expression in a
80
80
/// block.
81
81
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 ( '{' ) ) ;
83
83
let brace_token = file. syntax ( ) . token_at_offset ( offset) . right_biased ( ) ?;
84
84
let block = ast:: BlockExpr :: cast ( brace_token. parent ( ) ?) ?;
85
85
@@ -90,7 +90,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
90
90
Some ( ast:: Stmt :: ExprStmt ( it) ) => {
91
91
// Use the expression span to place `}` before the `;`
92
92
it. expr ( ) ?. syntax ( ) . text_range ( ) . end ( )
93
- } ,
93
+ }
94
94
None => block. tail_expr ( ) ?. syntax ( ) . text_range ( ) . end ( ) ,
95
95
_ => return None ,
96
96
}
@@ -103,7 +103,7 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
103
103
/// this works when adding `let =`.
104
104
// FIXME: use a snippet completion instead of this hack here.
105
105
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 ( '=' ) ) ;
107
107
let let_stmt: ast:: LetStmt = find_node_at_offset ( file. syntax ( ) , offset) ?;
108
108
if let_stmt. semicolon_token ( ) . is_some ( ) {
109
109
return None ;
@@ -125,7 +125,7 @@ fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
125
125
126
126
/// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
127
127
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 ( '.' ) ) ;
129
129
let whitespace =
130
130
file. syntax ( ) . token_at_offset ( offset) . left_biased ( ) . and_then ( ast:: Whitespace :: cast) ?;
131
131
@@ -154,7 +154,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdit> {
154
154
/// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }`
155
155
fn on_arrow_typed ( file : & SourceFile , offset : TextSize ) -> Option < TextEdit > {
156
156
let file_text = file. syntax ( ) . text ( ) ;
157
- assert_eq ! ( file_text. char_at( offset) , Some ( '>' ) ) ;
157
+ stdx :: always !( file_text. char_at( offset) == Some ( '>' ) ) ;
158
158
let after_arrow = offset + TextSize :: of ( '>' ) ;
159
159
if file_text. char_at ( after_arrow) != Some ( '{' ) {
160
160
return None ;
0 commit comments