-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: Regression in display of macro_rules!
matchers
#86208
Comments
This bug doesn't occur for |
I wonder if #80339 is related? |
@camelid you can test by bisecting |
That line of code is rust/src/librustdoc/clean/inline.rs Line 545 in 0a8629b
which hasn't changed in 2 years. So either span or to_src has changed.
|
But I don't have an MCVE to bisect with. Can you bisect |
@camelid sure, it will just take a while 😅 |
I meant in terms of getting |
@camelid you can use a custom script with bisect-rustc, it's a little tricky but it should work. |
Ok, since this issue is present on beta but not stable, I think the regression occurred in 61edfd5...8a9fa36 (the merge-bases between master and stable/beta), so that narrows it down a bit. |
I started scrolling through |
Aha! I came up with a super simple repro: pub use std::todo; |
Unfortunately, this bug seems even weirder than I thought, because the bisection pointed to 2020-03-11 as the regression date, which is bizarre because the bug is not present on stable. The commit range I got was 3dbade6...1581278. The command I used was: $ cargo bisect-rustc --prompt --start=2020-01-01 --end=2021-05-01 -- doc --open |
Based on looking through the commit range, these are the two PRs that seem most likely to have caused the regression: #66364 and #69677. #66364 seems especially likely to me, as it changed macro definitions in metadata, which is more likely to cause cross-crate macro issues. I still don't understand why this issue is not present on stable, given that it regressed more than a year ago. |
@camelid if you build from source with |
I asked about this regression on Zulip, and Eric Huss gave a very helpful response, explaining that the reason the bisection gave such weird results is because there was a regression in March 2020 that was then fixed in April 2020, but then regressed again recently, in April 2021. Eric was able to determine that the PR that most recently caused the regression was #84233, which I was able to confirm by re-bisecting. searched nightlies: from nightly-2021-01-01 to nightly-2021-05-01 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-apple-darwin cargo bisect-rustc --prompt --start=2021-01-01 --end=2021-05-01 --with-src -- doc --open |
Just on a hunch, 39648ea seems likely to be the commit that caused the regression. It also explains why I was not able to minimize the regression without using |
I think the more interesting question is why rustdoc depends on having the source available, that seems like a bug. |
Yeah, I was thinking about that. We should probably switch to pretty-printing the matchers. |
I think this change would make sense independently of this bug, for the reason mentioned in #86208 (comment), but the one issue is that it won't fix the underlying regression that this bug is a symptom of. |
@camelid what underlying regression? Nothing in the compiler should depend on if the source of dependencies is available IMO |
Are there no other places where we use EDIT: I looked and it seems like everywhere else handles no source gracefully. |
I'm currently trying out a fix that switches us to using |
This test does not test the output as well as I would like, but I think I am limited by htmldocck. I would really just like to strip all the HTML tags from the output for the sake of the different `@has` checks, but that doesn't seem to be currently possible.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
…uillaumeGomez rustdoc: Preserve rendering of macro_rules matchers when possible Fixes rust-lang#92331. This approach restores the behavior prior to rust-lang#86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus rust-lang#86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
Oddly enough, the two lines (and the areas around them) that show up when I grep for
"macro_rules!
in rustdoc don't appear to have changed at all in a while, so I'm not sure what caused this regression. Perhaps the span of the matcher changed? I wasn't able to reproduce this locally, even when I tried using a cross-crate re-export with a copy-pasted version ofcore::todo
(modulo replacing$crate::
with::std::
). Also, the bug doesn't appear with, e.g.,panic!
, but does withcompile_error!
. So, this seems to be a subtle bug.beta (incorrect)
stable (correct)
The text was updated successfully, but these errors were encountered: