Skip to content

libstd docs of re-exported macros are unformatted #26560

Closed
@durka

Description

@durka
Contributor

One example is the unreachable! macro, though I think I've seen it elsewhere. The documention of the macro in libcore is fine, but the docs of the same macro in libstd have the source formatting all weird, and the actual [src] link is broken.

Activity

durka

durka commented on Jun 25, 2015

@durka
ContributorAuthor

Of course you don't need the [src] link for a macro, but that's another issue!

sfackler

sfackler commented on Jun 25, 2015

@sfackler
Member

The formatting issue's a dup of #20923. Not sure if the src link being broken's been filed.

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Jun 26, 2015
durka

durka commented on Dec 16, 2015

@durka
ContributorAuthor

The src link at the re-exported macro is gone, so closing.

cbreeden

cbreeden commented on Jan 9, 2017

@cbreeden
Contributor

I think this issue is relevant again. The solution for the dup was to refactor error reporting system, which doesn't solve the formatting issues in the docs.

reopened this on Jan 10, 2017
changed the title [-]some macro docs are partly broken in libstd[/-] [+]libstd docs of re-exported macros are unformatted[/+] on Jan 10, 2017
cbreeden

cbreeden commented on Jan 10, 2017

@cbreeden
Contributor

I suspect that a quick solution to this problem may be to remove (or replace with ' ') all \n here https://github.com/rust-lang/rust/blob/master/src/librustdoc/clean/mod.rs#L2813.

At least it would put everything onto the same line.

durka

durka commented on Jan 10, 2017

@durka
ContributorAuthor

I don't think that's a great fix. I think the problem is that re-exported macros are stored into metadata in tokenized form, losing the original source formatting.

QuietMisdreavus

QuietMisdreavus commented on Jan 10, 2017

@QuietMisdreavus
Member

It looks more like that line you found is what prints each rule. Digging further, it seems to go through a ToSource trait which eventually calls span_to_snippet, which is where I would expect the formatting to come from.

cbreeden

cbreeden commented on Jan 10, 2017

@cbreeden
Contributor

I'm a little surprised that the highlighting doesn't work correctly, after looking at https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/highlight.rs#L245. I don't believe there is much we can do about the formatting that comes from span_to_snippet given how macros are re-exported; though this might change once Macros 2.0 is here and so macros are given a bona fide path.

Until then I think the solution would be to manually handle the formatting given a TokenStream. Last night I was going to try to do some debugging to see why the $ formatting given in the docs above didn't trigger, but didn't get around to it.

chordowl

chordowl commented on Apr 13, 2017

@chordowl
Contributor

I ran across another manifestation of this today: the reexported version of Entry in std::collections::btree_map::Entry uses where clauses for lifetime bounds, while the original version of Entry in collections::btree_map doesn't; it seems like this is not strictly limited to macros.

added
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
and removed on May 18, 2017
steveklabnik

steveklabnik commented on Oct 31, 2018

@steveklabnik
Member

Triage: the formatting is still a bit strange; the src links work great though.

jyn514

jyn514 commented on Mar 25, 2021

@jyn514
Member

I think this may be a duplicate of #36722.

jyn514

jyn514 commented on Apr 8, 2021

@jyn514
Member

This is fixed on master.
image

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

    C-bugCategory: This is a bug.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@durka@sfackler@chordowl@Mark-Simulacrum

        Issue actions

          libstd docs of re-exported macros are unformatted · Issue #26560 · rust-lang/rust