Skip to content
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

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

bdalrhm
Copy link
Contributor

@bdalrhm bdalrhm commented Jul 26, 2021

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 use rustdoc to extract examples from The Rust Reference and run them through the Rust Model Checker.

@rust-highfive
Copy link
Contributor

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 26, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2021
@inquisitivecrystal inquisitivecrystal added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 24, 2021
// 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") {
Copy link
Member

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.

@CraftSpider
Copy link
Contributor

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.
@bors r+

@bors
Copy link
Collaborator

bors commented Sep 7, 2021

📌 Commit e66dafc has been approved by CraftSpider

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 7, 2021
@bors
Copy link
Collaborator

bors commented Sep 8, 2021

⌛ Testing commit e66dafc with merge c9db3e0...

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

☀️ Test successful - checks-actions
Approved by: CraftSpider
Pushing c9db3e0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 8, 2021
@bors bors merged commit c9db3e0 into rust-lang:master Sep 8, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 8, 2021
@rust-timer
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants