-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc
: compute correct line number for indented rust code blocks.
#87489
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @CraftSpider (or someone else) soon. Please see the contribution instructions for more information. |
// If there are characters between the preceding line ending and | ||
// this code block, `str::lines` will return an additional line, | ||
// which we subtract here. | ||
if nb_lines != 0 && !&doc[prev_offset..offset.start].ends_with("\n") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm pretty sure this &
is unnecessary.
Sorry for the delay! I think this looks good. I'm fine with the nit being fixed later, given how long this has been waiting. |
📌 Commit e66dafc has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c9db3e0): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
This PR fixes a bug in
rustdoc
where it computes the wrong line number for indented rust code blocks (and subsequent blocks) it finds in markdown strings. To fix this issue, we decrement the line number if we find characters between the code block and the preceding line ending. I noticed this issue as I was trying to userustdoc
to extract examples from The Rust Reference and run them through the Rust Model Checker.