maybeCaptureFnRefs with RUST_SPEC's dispatch: arguments→args, assignment_expression→rhs(right), field_initializer→value(value), array_expression→list, static_item/let_declaration→varinit(value). No layers/unwrap/special — only bare identifiers qualify (`&handler` captures nothing). QUIRK: const_item is NOT in the dispatch.
(&mut self, node: Node<'t>)
| 1158 | /// No layers/unwrap/special — only bare identifiers qualify (`&handler` |
| 1159 | /// captures nothing). QUIRK: const_item is NOT in the dispatch. |
| 1160 | fn maybe_capture_fn_refs(&mut self, node: Node<'t>) { |
| 1161 | enum Mode { |
| 1162 | Args, |
| 1163 | Rhs, |
| 1164 | Value, |
| 1165 | List, |
| 1166 | Varinit, |
| 1167 | } |
| 1168 | let mode = match node.kind() { |
| 1169 | "arguments" => Mode::Args, |
| 1170 | "assignment_expression" => Mode::Rhs, |
| 1171 | "field_initializer" => Mode::Value, |
| 1172 | "array_expression" => Mode::List, |
| 1173 | "static_item" | "let_declaration" => Mode::Varinit, |
| 1174 | _ => return, |
| 1175 | }; |
| 1176 | if self.stack.is_empty() { |
| 1177 | return; |
| 1178 | } |
| 1179 | let from = self.top_row(); |
| 1180 | |
| 1181 | let mut values: Vec<Node> = Vec::new(); |
| 1182 | match mode { |
| 1183 | Mode::Args | Mode::List => { |
| 1184 | for i in 0..node.named_child_count() { |
| 1185 | if let Some(c) = node.named_child(i) { |
| 1186 | values.push(c); |
| 1187 | } |
| 1188 | } |
| 1189 | } |
| 1190 | Mode::Rhs => { |
| 1191 | if let Some(rhs) = node.child_by_field_name("right") { |
| 1192 | // Param-storage skip: `o.cb = cb`. |
| 1193 | let lhs_text = node |
| 1194 | .child_by_field_name("left") |
| 1195 | .map(|l| self.text(l)) |
| 1196 | .unwrap_or(""); |
| 1197 | let lhs_last = util::lhs_last_name() |
| 1198 | .captures(lhs_text) |
| 1199 | .and_then(|c| c.get(1)) |
| 1200 | .map(|m| m.as_str()); |
| 1201 | if !(lhs_last.is_some() && lhs_last == Some(self.text(rhs).trim())) { |
| 1202 | values.push(rhs); |
| 1203 | } |
| 1204 | } |
| 1205 | } |
| 1206 | Mode::Value => { |
| 1207 | let v = node.child_by_field_name("value").or_else(|| { |
| 1208 | if node.named_child_count() > 0 { |
| 1209 | node.named_child(node.named_child_count() - 1) |
| 1210 | } else { |
| 1211 | None |
| 1212 | } |
| 1213 | }); |
| 1214 | if let Some(v) = v { |
| 1215 | values.push(v); |
| 1216 | } |
| 1217 | } |
no test coverage detected