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>)
| 1183 | /// No layers/unwrap/special — only bare identifiers qualify (`&handler` |
| 1184 | /// captures nothing). QUIRK: const_item is NOT in the dispatch. |
| 1185 | fn maybe_capture_fn_refs(&mut self, node: Node<'t>) { |
| 1186 | enum Mode { |
| 1187 | Args, |
| 1188 | Rhs, |
| 1189 | Value, |
| 1190 | List, |
| 1191 | Varinit, |
| 1192 | } |
| 1193 | let mode = match node.kind() { |
| 1194 | "arguments" => Mode::Args, |
| 1195 | "assignment_expression" => Mode::Rhs, |
| 1196 | "field_initializer" => Mode::Value, |
| 1197 | "array_expression" => Mode::List, |
| 1198 | "static_item" | "let_declaration" => Mode::Varinit, |
| 1199 | _ => return, |
| 1200 | }; |
| 1201 | if self.stack.is_empty() { |
| 1202 | return; |
| 1203 | } |
| 1204 | let from = self.top_row(); |
| 1205 | |
| 1206 | let mut values: Vec<Node> = Vec::new(); |
| 1207 | match mode { |
| 1208 | Mode::Args | Mode::List => { |
| 1209 | for i in 0..node.named_child_count() { |
| 1210 | if let Some(c) = node.named_child(i) { |
| 1211 | values.push(c); |
| 1212 | } |
| 1213 | } |
| 1214 | } |
| 1215 | Mode::Rhs => { |
| 1216 | if let Some(rhs) = node.child_by_field_name("right") { |
| 1217 | // Param-storage skip: `o.cb = cb`. |
| 1218 | let lhs_text = node |
| 1219 | .child_by_field_name("left") |
| 1220 | .map(|l| self.text(l)) |
| 1221 | .unwrap_or(""); |
| 1222 | let lhs_last = util::lhs_last_name() |
| 1223 | .captures(lhs_text) |
| 1224 | .and_then(|c| c.get(1)) |
| 1225 | .map(|m| m.as_str()); |
| 1226 | if !(lhs_last.is_some() && lhs_last == Some(self.text(rhs).trim())) { |
| 1227 | values.push(rhs); |
| 1228 | } |
| 1229 | } |
| 1230 | } |
| 1231 | Mode::Value => { |
| 1232 | let v = node.child_by_field_name("value").or_else(|| { |
| 1233 | if node.named_child_count() > 0 { |
| 1234 | node.named_child(node.named_child_count() - 1) |
| 1235 | } else { |
| 1236 | None |
| 1237 | } |
| 1238 | }); |
| 1239 | if let Some(v) = v { |
| 1240 | values.push(v); |
| 1241 | } |
| 1242 | } |
no test coverage detected