Skip to content
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 has different URLs for re-exported builtin derives than in the current crate #80414

Open
jyn514 opened this issue Dec 27, 2020 · 1 comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 27, 2020

I tried this code:

#![no_std]
#[doc(no_inline)]
pub use core::marker::Copy;

I expected to see this happen: Rustdoc links to https://doc.rust-lang.org/nightly/core/macro.Copy.html.

Instead, this happened: Rustdoc links to https://doc.rust-lang.org/nightly/core/marker/derive.Copy.html.

This is wrong in two ways:

  1. It uses macro.Item.html and derive.Item.html inconsistently
  2. It links to the marker submodule in the re-export crate but not when documenting core (pub macro defined in submodule is shown at the wrong path #74355).

This issue is only for tracking 1.

Thanks @danielhenrymantilla for the bug report!

Meta

rustdoc --version: rustdoc 1.50.0-nightly (0edce6f 2020-12-24)

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. labels Dec 27, 2020
@danielhenrymantilla
Copy link
Contributor

danielhenrymantilla commented Dec 27, 2020

This seems to stem from the way macro builtins and AST-cleaning work:

  • Built-in macros are "#[lang]-declared" with a "dummy" macro definition, so they are seen, AST-wise / within rustdoc::clean, as the latter: as a TypeKind::Macro

  • within a downstream crate that refers to it without inlining its definition, Res's DefKind has "correctly" resolved such macros to their actual nature (e.g., Derive).

FWIW, the "downstream crate that refers to a lang derive macro with a macro definition without inlining it" doesn't seem to happen in practice, hence it not being spotted. So we live in a world of macro.Copy.html and the like, which seems to be the bug, albeit a consistent one 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants