@@ -111,7 +111,7 @@ fn find_bool_node(ctx: &AssistContext<'_>) -> Option<BoolNodeData> {
111
111
initializer : let_stmt. initializer ( ) ,
112
112
definition : Definition :: Local ( def) ,
113
113
} )
114
- } else if let Some ( const_) = name. syntax ( ) . ancestors ( ) . find_map ( ast:: Const :: cast) {
114
+ } else if let Some ( const_) = name. syntax ( ) . parent ( ) . and_then ( ast:: Const :: cast) {
115
115
let def = ctx. sema . to_def ( & const_) ?;
116
116
if !def. ty ( ctx. db ( ) ) . is_bool ( ) {
117
117
cov_mark:: hit!( not_applicable_non_bool_const) ;
@@ -125,7 +125,7 @@ fn find_bool_node(ctx: &AssistContext<'_>) -> Option<BoolNodeData> {
125
125
initializer : const_. body ( ) ,
126
126
definition : Definition :: Const ( def) ,
127
127
} )
128
- } else if let Some ( static_) = name. syntax ( ) . ancestors ( ) . find_map ( ast:: Static :: cast) {
128
+ } else if let Some ( static_) = name. syntax ( ) . parent ( ) . and_then ( ast:: Static :: cast) {
129
129
let def = ctx. sema . to_def ( & static_) ?;
130
130
if !def. ty ( ctx. db ( ) ) . is_bool ( ) {
131
131
cov_mark:: hit!( not_applicable_non_bool_static) ;
@@ -140,7 +140,7 @@ fn find_bool_node(ctx: &AssistContext<'_>) -> Option<BoolNodeData> {
140
140
definition : Definition :: Static ( def) ,
141
141
} )
142
142
} else {
143
- let field = name. syntax ( ) . ancestors ( ) . find_map ( ast:: RecordField :: cast) ?;
143
+ let field = name. syntax ( ) . parent ( ) . and_then ( ast:: RecordField :: cast) ?;
144
144
if field. name ( ) ? != name {
145
145
return None ;
146
146
}
0 commit comments