@@ -531,7 +531,7 @@ impl FunctionBody {
531
531
532
532
fn extracted_from_trait_impl ( & self ) -> bool {
533
533
match self . node ( ) . ancestors ( ) . find_map ( ast:: Impl :: cast) {
534
- Some ( c) => return c. trait_ ( ) . is_some ( ) ,
534
+ Some ( c) => c. trait_ ( ) . is_some ( ) ,
535
535
None => false ,
536
536
}
537
537
}
@@ -1048,23 +1048,17 @@ impl GenericParent {
1048
1048
fn generic_parents ( parent : & SyntaxNode ) -> Vec < GenericParent > {
1049
1049
let mut list = Vec :: new ( ) ;
1050
1050
if let Some ( parent_item) = parent. ancestors ( ) . find_map ( ast:: Item :: cast) {
1051
- match parent_item {
1052
- ast:: Item :: Fn ( ref fn_) => {
1053
- if let Some ( parent_parent) = parent_item
1054
- . syntax ( )
1055
- . parent ( )
1056
- . and_then ( |it| it. parent ( ) )
1057
- . and_then ( ast:: Item :: cast)
1058
- {
1059
- match parent_parent {
1060
- ast:: Item :: Impl ( impl_) => list. push ( GenericParent :: Impl ( impl_) ) ,
1061
- ast:: Item :: Trait ( trait_) => list. push ( GenericParent :: Trait ( trait_) ) ,
1062
- _ => ( ) ,
1063
- }
1051
+ if let ast:: Item :: Fn ( ref fn_) = parent_item {
1052
+ if let Some ( parent_parent) =
1053
+ parent_item. syntax ( ) . parent ( ) . and_then ( |it| it. parent ( ) ) . and_then ( ast:: Item :: cast)
1054
+ {
1055
+ match parent_parent {
1056
+ ast:: Item :: Impl ( impl_) => list. push ( GenericParent :: Impl ( impl_) ) ,
1057
+ ast:: Item :: Trait ( trait_) => list. push ( GenericParent :: Trait ( trait_) ) ,
1058
+ _ => ( ) ,
1064
1059
}
1065
- list. push ( GenericParent :: Fn ( fn_. clone ( ) ) ) ;
1066
1060
}
1067
- _ => ( ) ,
1061
+ list . push ( GenericParent :: Fn ( fn_ . clone ( ) ) ) ;
1068
1062
}
1069
1063
}
1070
1064
list
@@ -1728,7 +1722,7 @@ fn make_body(
1728
1722
let block = match & fun. body {
1729
1723
FunctionBody :: Expr ( expr) => {
1730
1724
let expr = rewrite_body_segment ( ctx, & fun. params , & handler, expr. syntax ( ) ) ;
1731
- let expr = ast:: Expr :: cast ( expr) . unwrap ( ) ;
1725
+ let expr = ast:: Expr :: cast ( expr) . expect ( "Body segment should be an expr" ) ;
1732
1726
match expr {
1733
1727
ast:: Expr :: BlockExpr ( block) => {
1734
1728
// If the extracted expression is itself a block, there is no need to wrap it inside another block.
@@ -1868,9 +1862,8 @@ fn with_tail_expr(block: ast::BlockExpr, tail_expr: ast::Expr) -> ast::BlockExpr
1868
1862
1869
1863
if let Some ( stmt_list) = block. stmt_list ( ) {
1870
1864
stmt_list. syntax ( ) . children_with_tokens ( ) . for_each ( |node_or_token| {
1871
- match & node_or_token {
1872
- syntax:: NodeOrToken :: Token ( _) => elements. push ( node_or_token) ,
1873
- _ => ( ) ,
1865
+ if let syntax:: NodeOrToken :: Token ( _) = & node_or_token {
1866
+ elements. push ( node_or_token)
1874
1867
} ;
1875
1868
} ) ;
1876
1869
}
@@ -1934,12 +1927,18 @@ fn fix_param_usages(ctx: &AssistContext<'_>, params: &[Param], syntax: &SyntaxNo
1934
1927
Some ( ast:: Expr :: RefExpr ( node) )
1935
1928
if param. kind ( ) == ParamKind :: MutRef && node. mut_token ( ) . is_some ( ) =>
1936
1929
{
1937
- ted:: replace ( node. syntax ( ) , node. expr ( ) . unwrap ( ) . syntax ( ) ) ;
1930
+ ted:: replace (
1931
+ node. syntax ( ) ,
1932
+ node. expr ( ) . expect ( "RefExpr::expr() cannot be None" ) . syntax ( ) ,
1933
+ ) ;
1938
1934
}
1939
1935
Some ( ast:: Expr :: RefExpr ( node) )
1940
1936
if param. kind ( ) == ParamKind :: SharedRef && node. mut_token ( ) . is_none ( ) =>
1941
1937
{
1942
- ted:: replace ( node. syntax ( ) , node. expr ( ) . unwrap ( ) . syntax ( ) ) ;
1938
+ ted:: replace (
1939
+ node. syntax ( ) ,
1940
+ node. expr ( ) . expect ( "RefExpr::expr() cannot be None" ) . syntax ( ) ,
1941
+ ) ;
1943
1942
}
1944
1943
Some ( _) | None => {
1945
1944
let p = & make:: expr_prefix ( T ! [ * ] , usage. clone ( ) ) . clone_for_update ( ) ;
0 commit comments