@@ -224,7 +224,6 @@ pub(crate) fn inline_call(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<
224
224
syntax. text_range ( ) ,
225
225
|builder| {
226
226
let replacement = inline ( & ctx. sema , file_id, function, & fn_body, & params, & call_info) ;
227
-
228
227
builder. replace_ast (
229
228
match call_info. node {
230
229
ast:: CallableExpr :: Call ( it) => ast:: Expr :: CallExpr ( it) ,
@@ -363,16 +362,22 @@ fn inline(
363
362
. collect ( ) ;
364
363
365
364
if function. self_param ( sema. db ) . is_some ( ) {
366
- let this = || make:: name_ref ( "this" ) . syntax ( ) . clone_for_update ( ) . first_token ( ) . unwrap ( ) ;
365
+ let this = || {
366
+ make:: name_ref ( "this" )
367
+ . syntax ( )
368
+ . clone_for_update ( )
369
+ . first_token ( )
370
+ . expect ( "NameRef should have had a token." )
371
+ } ;
367
372
if let Some ( self_local) = params[ 0 ] . 2 . as_local ( sema. db ) {
368
373
usages_for_locals ( self_local)
369
374
. filter_map ( |FileReference { name, range, .. } | match name {
370
375
ast:: NameLike :: NameRef ( _) => Some ( body. syntax ( ) . covering_element ( range) ) ,
371
376
_ => None ,
372
377
} )
373
- . for_each ( |it | {
374
- ted:: replace ( it , & this ( ) ) ;
375
- } )
378
+ . for_each ( |usage | {
379
+ ted:: replace ( usage , & this ( ) ) ;
380
+ } ) ;
376
381
}
377
382
}
378
383
@@ -470,7 +475,9 @@ fn inline(
470
475
}
471
476
} else if let Some ( stmt_list) = body. stmt_list ( ) {
472
477
ted:: insert_all (
473
- ted:: Position :: after ( stmt_list. l_curly_token ( ) . unwrap ( ) ) ,
478
+ ted:: Position :: after (
479
+ stmt_list. l_curly_token ( ) . expect ( "L_CURLY for StatementList is missing." ) ,
480
+ ) ,
474
481
let_stmts. into_iter ( ) . map ( |stmt| stmt. syntax ( ) . clone ( ) . into ( ) ) . collect ( ) ,
475
482
) ;
476
483
}
0 commit comments