Skip to content

rustdoc: Regression in whitespacing inside macro_rules matchers #92331

Description

@dtolnay
#[macro_export]
macro_rules! repro {
    ($e:expr, std::path) => {};
}

Before:

This preserves the spacing in the way that the macro author wrote, and exactly the way that they intend for the macro user to write those spaces on their end.

Screenshot from 2021-12-27 13-13-25

After:

The person calling the macro needs to reverse engineer where to add/delete spaces in order to get a readable result.

Screenshot from 2021-12-27 13-13-46

I haven't bisected but it seems likely from skimming the implementation that this is related to #86282. Overall I think #86282 would tend to be net negative for the vast majority of macros. @camelid @jyn514 is there perhaps some other way to deal with the edge cases that didn't have proper source code for rustdoc to copy?

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    on Dec 27, 2021
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Dec 27, 2021
  3. camelid commented on Dec 28, 2021

    @camelid
    Member

    Yeah, I know the formatting regressions from that PR were not great, but it fixed a bunch of bugs. In general, I think rustdoc shouldn't be relying on the source code except for the actual source code view.

  4. added 6 commits that reference this issue on Jan 9, 2022
    86e463b
    6d11bfa
    5501751
    770f532
    7ea5770
    ac81a13
  5. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jan 14, 2022
  6. added a commit that references this issue on Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions