Skip to content

Incorrect mixing of reexport and definition documentation of proc macros #64251

Closed
@LukasKalbertodt

Description

@LukasKalbertodt

The PR #62855 improved the situation about documenting proc macros. Thanks for that! However, I noticed a bug with it. I'm using rustc 1.39.0-nightly (6e19f3f38 2019-09-06).

Cargo.toml

[package]
name = "doc-bug"
version = "0.1.0"
authors = ["me"]
edition = "2018"

[dependencies]
macros = { path = "macros" }

src/lib.rs

/// Reexport `foo`.
pub use macros::foo;

/// Reexport `Bar`.
pub use macros::Bar;

/// Reexport `Baz`.
pub use macros::Baz;

macros/Cargo.toml

[package]
name = "macros"
version = "0.1.0"
authors = ["me"]
edition = "2018"

[lib]
proc-macro = true

macros/src/lib.rs

extern crate proc_macro;

use proc_macro::TokenStream;

/// Definition `foo`.
#[proc_macro]
pub fn foo(input: TokenStream) -> TokenStream {
    input
}

/// Definition `Bar`.
#[proc_macro_derive(Bar)]
pub fn bar(input: TokenStream) -> TokenStream {
    input
}

/// Definition `Baz`.
#[proc_macro_derive(Baz)]
pub fn baz(input: TokenStream) -> TokenStream {
    input
}

Running cargo doc results in this:

image

Looks like a simple typo or off-by-one or something like that bug. When using only proc_macro and not proc_macro_derives, everything looks good to me.

CC @Aaron1011

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.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

    Issue actions