]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #47210 - zackmdavis:the_3rd_of_2_hardest_problems_in_computer_science...
authorkennytm <kennytm@gmail.com>
Mon, 8 Jan 2018 17:58:45 +0000 (01:58 +0800)
committerGitHub <noreply@github.com>
Mon, 8 Jan 2018 17:58:45 +0000 (01:58 +0800)
fix the doc-comment-decoration-trimming edge-case rustdoc ICE

This `horizontal_trim` function strips the leading whitespace from
doc-comments that have a left-asterisk-margin:

```
  /**
   * You know what I mean—
   *
   * comments like this!
   */
```

The index of the column of asterisks is `i`, and if trimming is deemed
possible, we slice each line from `i+1` to the end of the line. But if, in
particular, `i` was 0 _and_ there was an empty line (as in the example
given in the reporting issue), we ended up panicking trying to slice an
empty string from 0+1 (== 1).

Let's tighten our check to say that we can't trim when `i` is even the same
as the length of the line, not just when it's greater. (Any such cases
would panic trying to slice `line` from `line.len()+1`.)

Resolves #47197.


Trivial merge