(from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string, callee?: RustClosureCallee)
| 620 | else bindings.set(name, [binding]); |
| 621 | }; |
| 622 | const bindPattern = (from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string, callee?: RustClosureCallee): void => { |
| 623 | const emit: Emit = (name, at, site) => add(name, { at, kind, from: scopeFrom, to: scopeTo, site, scrutinee, callee }); |
| 624 | // A tuple pattern, `(k, v)` or `(i, mut x)`: a name alone at its top is |
| 625 | // the tuple's field at its place (a site with no path). |
| 626 | const open = skipSpace(code, from); |
| 627 | const end = code[open] === '(' ? close.get(open) : undefined; |
| 628 | if (end !== undefined && end < to && skipSpace(code, end + 1) >= to) { |
| 629 | let index = 0; |
| 630 | for (const [a, b] of splitTop(code, open + 1, end, close, false)) { |
| 631 | const text = code.slice(a, b); |
| 632 | const simple = /^\s*(?:ref\s+)?(?:mut\s+)?([A-Za-z_]\w*)\s*$/.exec(text); |
| 633 | if (simple && isBindingName(simple[1]!)) emit(simple[1]!, a + text.lastIndexOf(simple[1]!), { path: '', index }); |
| 634 | else walkPattern(code, a, b, close, undefined, emit); |
| 635 | index++; |
| 636 | } |
| 637 | return; |
| 638 | } |
| 639 | walkPattern(code, from, to, close, undefined, emit); |
| 640 | }; |
| 641 | // A parameter `pattern: Type`, or a closure's `pattern`. |
| 642 | const param = (from: number, to: number, kind: 'param' | 'closure', scopeFrom: number, scopeTo: number, callee?: RustClosureCallee): void => { |
| 643 | const colon = topColon(code, from, to, close); |
no test coverage detected