Skip to content

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

Closed

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

Activity

  1. LukasKalbertodt commented on Sep 7, 2019

    @LukasKalbertodt
    ContributorAuthor

    Oh, and also, running cargo doc prints:

       Compiling macros v0.1.0 (/home/lukas/dev/doc-bug/macros)
     Documenting macros v0.1.0 (/home/lukas/dev/doc-bug/macros)
    warning: Trying to document proc macro crate without passing '--crate-type proc-macro to rustdoc
      |
      = warning: The generated documentation may be incorrect
    
     Documenting doc-bug v0.1.0 (/home/lukas/dev/doc-bug)
        Finished dev [unoptimized + debuginfo] target(s) in 1.71s
    

    Not sure if this warning is expected there. And not sure if related to this bug.

  2. added
    C-bugCategory: This is a bug.
    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, ..)
    on Sep 7, 2019
  3. Aaron1011 commented on Sep 8, 2019

    @Aaron1011
    Contributor

    This is a consequence of the fact that rust-lang/cargo#7159 has not yet been merged. Once it gets merged, and rust updates its Cargo submodule, this issue should go away.

  4. Aaron1011 commented on Sep 16, 2019

    @Aaron1011
    Contributor

    @LukasKalbertodt: It turns out that this issue was unrelated. I've opened a PR to fix it.

  5. LukasKalbertodt commented on Sep 16, 2019

    @LukasKalbertodt
    ContributorAuthor

    @Aaron1011 I see. Thanks for your work on this :)

  6. added a commit that references this issue on Sep 17, 2019
    3daa8bd
  7. added 3 commits that reference this issue on Sep 18, 2019
    fbd1144
    987e712
    76d34f3
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, ..)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