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: Hide #text in doc-tests #84445

Merged
merged 1 commit into from
Apr 23, 2021
Merged

rustdoc: Hide #text in doc-tests #84445

merged 1 commit into from
Apr 23, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 22, 2021

Since #![attr] and #[attr] are the only valid syntax that start with #, we can just special case those two tokens.

Fixes #83284.

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-doctests Area: Documentation tests, run by rustdoc labels Apr 22, 2021
@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2021
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

Not really, for example:

let s = "hello
#because why not?";

@jyn514
Copy link
Member Author

jyn514 commented Apr 22, 2021

@GuillaumeGomez that's already broken today if you use

let s = "hello
# because why not?";

@jyn514
Copy link
Member Author

jyn514 commented Apr 22, 2021

Really the problem is that rustdoc chose an ambiguous syntax, it needs to both use something that's both an invalid token normally and also follow string open-closing marks. The string thing might be possible but it will be a real pain. I don't this should be blocked on that improvement given that's there's other valid code that's already broken by the # syntax.

@rust-log-analyzer

This comment has been minimized.

Since `#![attr]` and `#[attr]` are the only valid syntax that start with `#`, we can just special case those two tokens.
@GuillaumeGomez
Copy link
Member

Can't we use the ast parser to get some help there?

@jyn514
Copy link
Member Author

jyn514 commented Apr 23, 2021

Can't we use the ast parser to get some help there?

@GuillaumeGomez I think this may be possible, but it will be a lot of hard work for very little benefit. If you're worried about breakage, maybe it makes sense to do a crater run instead? I don't think the exact whitespace you can use with # was ever documented, and I would hate to accidentally stabilize it when we don't need to.

@jyn514
Copy link
Member Author

jyn514 commented Apr 23, 2021

@bors try (in case you want a crater run)

@bors
Copy link
Contributor

bors commented Apr 23, 2021

⌛ Trying commit af6c320 with merge 9a35232...

@GuillaumeGomez
Copy link
Member

No, my problem is more like that this isn't a real fix, more like a patchwork over a few others. I don't mind merging as is. But maybe in the long run, we should try to take a long at this to have a "definitive" fix.

@jyn514
Copy link
Member Author

jyn514 commented Apr 23, 2021

Ok, I opened #84478 for the proper fix. I still think this is a good change in the meantime that makes the behavior less surprising.

@GuillaumeGomez
Copy link
Member

Fine by me, thanks for opening the issue and thanks for this PR!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Apr 23, 2021

📌 Commit af6c320 has been approved by GuillaumeGomez

@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 Apr 23, 2021
@bors
Copy link
Contributor

bors commented Apr 23, 2021

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing 9a35232 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 23, 2021
@bors bors merged commit 9a35232 into rust-lang:master Apr 23, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 23, 2021
@jyn514 jyn514 deleted the hidden branch April 23, 2021 14:34
@SergioBenitez
Copy link
Contributor

SergioBenitez commented Apr 24, 2021

This change is not backwards compatible and has broken Rocket's test suite. Please revert.

Rocket has:

// This (long, contrived) form string...
# assert_form_parses! { Foo,
"[k:top_key][i][k:sub_key]name=Bobert&\
[k:top_key][i][k:sub_key]age=22&\
[k:top_key][i][sub_key]=1337&\
[top_key][7]name=Builder&\
[top_key][7]age=99",

// We could also set the top-level value's key explicitly:
// [top_key][k:7]=7
# "[k:top_key][i][k:sub_key]name=Bobert&\
# [k:top_key][i][k:sub_key]age=22&\
# [top_key][k:7]=7&\
# [k:top_key][i][sub_key]=1337&\
# [top_key][7]name=Builder&\
# [top_key][7]age=99",
# =>

Previously, the #s in the second string were stripped by rustdoc, and so the string passed to the macro did not contain the leading #s. Now, they are not stripped, and so a string with #s gets passed to the macro, causing the test to fail.

@m-ou-se
Copy link
Member

m-ou-se commented Apr 24, 2021

What bors did here was.. interesting. The try build was still running when this PR was approved. And then it merged the try commit (the one with r=<try> instead of r=$reviewer) into the main branch without running the full CI for it first.

cc @rust-lang/infra

@kennytm
Copy link
Member

kennytm commented Apr 24, 2021

feels like rust-lang/homu#47 😢

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2021
…Gomez

Revert "rustdoc: Hide `#text` in doc-tests"

See discussion in rust-lang#84502 - I'm worried that rust-lang#84445 may cause a lot of breakages if this were to hit stable, so I think it's safer to revert and work on the known correct fix rust-lang#84478.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc 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.

Rustdoc unhelpful error message on missing whitespace after #
9 participants