Commit beacd8a
committed
fix: return canonical short prefix from
`Comment::prefix` iterated `CommentKind::BY_PREFIX` forward, so `/**/`
matched the `/**/` entry itself and returned the full 4-char string.
`block_to_line` then computed `&text[4..text.len()-2]` = `&text[4..2]`
and panicked.
Delegate `Comment::prefix` to `CommentKind::prefix`, which already
iterates in reverse and returns the canonical short form (`/*` for
non-doc block comments). The `/**/` and `/***` entries in `BY_PREFIX`
are still needed for `from_text` to classify them as non-doc blocks.
fixes #22071Comment::prefix
1 parent 26d7ba3 commit beacd8a
2 files changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
384 | 399 | | |
385 | 400 | | |
386 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 35 | + | |
40 | 36 | | |
41 | 37 | | |
42 | 38 | | |
| |||
0 commit comments