(from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string)
| 513 | else bindings.set(name, [binding]); |
| 514 | }; |
| 515 | const bindPattern = (from: number, to: number, kind: RustBinding['kind'], scopeFrom: number, scopeTo: number, scrutinee?: string): void => { |
| 516 | const emit: Emit = (name, at, site) => add(name, { at, kind, from: scopeFrom, to: scopeTo, site, scrutinee }); |
| 517 | // A tuple pattern, `(k, v)` or `(i, mut x)`: a name alone at its top is |
| 518 | // the tuple's field at its place (a site with no path). |
| 519 | const open = skipSpace(code, from); |
| 520 | const end = code[open] === '(' ? close.get(open) : undefined; |
| 521 | if (end !== undefined && end < to && skipSpace(code, end + 1) >= to) { |
| 522 | let index = 0; |
| 523 | for (const [a, b] of splitTop(code, open + 1, end, close, false)) { |
| 524 | const text = code.slice(a, b); |
| 525 | const simple = /^\s*(?:ref\s+)?(?:mut\s+)?([A-Za-z_]\w*)\s*$/.exec(text); |
| 526 | if (simple && isBindingName(simple[1]!)) emit(simple[1]!, a + text.lastIndexOf(simple[1]!), { path: '', index }); |
| 527 | else walkPattern(code, a, b, close, undefined, emit); |
| 528 | index++; |
| 529 | } |
| 530 | return; |
| 531 | } |
| 532 | walkPattern(code, from, to, close, undefined, emit); |
| 533 | }; |
| 534 | // A parameter `pattern: Type`, or a closure's `pattern`. |
| 535 | const param = (from: number, to: number, kind: 'param' | 'closure', scopeFrom: number, scopeTo: number): void => { |
| 536 | const colon = topColon(code, from, to, close); |
no test coverage detected