Uh oh!
There was an error while loading. Please reload this page.
fix the doc-comment-decoration-trimming edge-case rustdoc ICE - #47210
Merged
bors merged 1 commit intoJan 9, 2018
Merged
Conversation
rust-highfive
commented
Jan 5, 2018
Contributor
(rust_highfive has picked a reviewer for you, use r? to override) |
zackmdavis
commented
Jan 5, 2018
ContributorAuthor
QuietMisdreavus
commented
Jan 5, 2018
Contributor
Can you add a test for this? Something like this:
// copyright header// libsyntax ICE when trimming the blank line in the middle of that comment// @has issue_47197/fn.x.html/*** a* b*/pubfnx(){} |
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`.) Resolvesrust-lang#47197.
zackmdavisforce-pushed
the
the_3rd_of_2_hardest_problems_in_computer_science
branch
from
January 6, 2018 19:18
b6bde34 to
3cfea33Comparezackmdavis
commented
Jan 6, 2018
ContributorAuthor
(updated) |
QuietMisdreavus
commented
Jan 6, 2018
Contributor
@bors r+ rollup Thanks! |
bors
commented
Jan 6, 2018
Collaborator
📌 Commit 3cfea33 has been approved by |
kennytm added a commit
to kennytm/rust
that referenced
this pull request
Jan 8, 2018
…blems_in_computer_science, r=QuietMisdreavus 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`.) Resolvesrust-lang#47197.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This
horizontal_trimfunction strips the leading whitespace fromdoc-comments that have a left-asterisk-margin:
The index of the column of asterisks is
i, and if trimming is deemedpossible, we slice each line from
i+1to the end of the line. But if, inparticular,
iwas 0 and there was an empty line (as in the examplegiven 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
iis even the sameas the length of the line, not just when it's greater. (Any such cases
would panic trying to slice
linefromline.len()+1.)Resolves#47197.