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

regression 1.49: rustdoc runs indented documentation immediately after a header as a doctest #79911

Closed
Mark-Simulacrum opened this issue Dec 10, 2020 · 16 comments
Assignees
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. relnotes Marks issues that should be documented in the release notes of the next release. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

My guess is that rustdoc's behavior on parsing doc attributes has changed or something like that -- I recall seeing a PR changing how we handle things. Maybe for example previously \n in an attribute worked and now doesn't?

cc @rust-lang/rustdoc

@Mark-Simulacrum Mark-Simulacrum added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Dec 10, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 10, 2020
@Mark-Simulacrum Mark-Simulacrum added this to the 1.49.0 milestone Dec 10, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

Is there a way to see the full source for this? The error sounds like it's a doctest or something, not documentation directly.

@Mark-Simulacrum
Copy link
Member Author

It's a public repo, https://github.com/bes/google-datastore1-generated/blob/master/src/lib.rs#L1

@Mark-Simulacrum
Copy link
Member Author

https://crater-reports.s3.amazonaws.com/beta-1.49-1/beta-2020-11-26/reg/auto-0.0.8/log.txt might also be related (that one is on crates.io)

@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

The bug is that this is being interpreted as a doctest instead of normal documentation. Not sure why yet.

@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

I think this was fa1b15f.

@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

MCVE:

//!# Header
//!    x

Stable ignores it, beta runs x as a doctest.

@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

For context,

//!# Header
//!
//!    x

is run on a doctest on stable. So maybe newlines are getting discarded somewhere?

@jyn514 jyn514 changed the title regression 1.49: rustdoc doc attribute parsing newlines? regression 1.49: rustdoc runs indented documentation immediately after a header as a doctest Dec 10, 2020
@jyn514 jyn514 removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 10, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 10, 2020

searched toolchains nightly-2020-10-01 through nightly-2020-12-01


********************************************************************************
Regression in nightly-2020-11-05
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-11-04/channel-rust-nightly-git-commit-hash.txt
ERROR: Tarball not found at https://static.rust-lang.org/dist/2020-11-04/channel-rust-nightly-git-commit-hash.txt

I confirmed locally that reverting #78400 fixes the issue.

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

It's because the header starts with //!# Header. Because there is no space before //!, everything is aligned to this, making //! x a doctest because there are 4 spaces. So this is the expected behavior, it was just buggy before. :)

@rylev
Copy link
Member

rylev commented Dec 10, 2020

@GuillaumeGomez can you clarify why this is expected behavior (not sure I fully follow your explanation above). This seems very unexpected to me.

@GuillaumeGomez
Copy link
Member

So I wrote a whole blog post explaining this change here. TLDR:

Since the minimum indent is "0" because of //!# Header (where there is no whitespace before #), the line //! x has an indent of 4, making it a code block based on the markdown spec.

If you don't want x to be a code block, add a whitespace before # Header or remove a whitespace from //! x.

@Mark-Simulacrum Mark-Simulacrum self-assigned this Dec 11, 2020
@Mark-Simulacrum
Copy link
Member Author

Will close as won't fix, but we should include in release notes.

@camelid camelid added relnotes Marks issues that should be documented in the release notes of the next release. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 11, 2020
@Mark-Simulacrum
Copy link
Member Author

@XAMPPRocky Can we add an entry to the 1.49 release notes for this issue? It sounds like roughly

  • Leading whitespace is stripped more uniformly in documentation comments, which may change behavior. Read this post for more details.

@GuillaumeGomez
Copy link
Member

That'd be a good idea indeed!

@XAMPPRocky
Copy link
Member

Closing, as it's now in relnotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. relnotes Marks issues that should be documented in the release notes of the next release. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants