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 regression: intra-doc-links not working in proc-macro crate since nightly-2023-02-12 #107950

Closed
taiki-e opened this issue Feb 12, 2023 · 3 comments · Fixed by #107951 or paritytech/jsonrpsee#1022
Assignees
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@taiki-e
Copy link
Member

taiki-e commented Feb 12, 2023

Code

I ran cargo doc with this code:

# Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true
/// [`Unpin`]
#[proc_macro_derive(F)]
pub fn derive_(t: proc_macro::TokenStream) -> proc_macro::TokenStream {
    t
}

/// [`Unpin`]
#[proc_macro_attribute]
pub fn attr(t: proc_macro::TokenStream, _: proc_macro::TokenStream) -> proc_macro::TokenStream {
    t
}

/// [`Unpin`]
#[proc_macro]
pub fn func(t: proc_macro::TokenStream) -> proc_macro::TokenStream {
    t
}

I expected to see this happen: intra-doc-links work and no warning

Instead, this happened:

intra-doc-links is not working in the generated docs.

doc

And I got broken_intra_doc_links warnings:

warning: unresolved link to `Unpin`
 --> src/lib.rs:1:7
  |
1 | /// [`Unpin`]
  |       ^^^^^ no item named `Unpin` in scope
  |
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unresolved link to `Unpin`
 --> src/lib.rs:7:7
  |
7 | /// [`Unpin`]
  |       ^^^^^ no item named `Unpin` in scope
  |
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `Unpin`
  --> src/lib.rs:13:7
   |
13 | /// [`Unpin`]
   |       ^^^^^ no item named `Unpin` in scope
   |
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Version it worked on

It most recently worked on: nightly-2023-02-11

doc-old

Version with regression

rustc --version --verbose:

rustc 1.69.0-nightly (585f3eef2 2023-02-11)
binary: rustc
commit-hash: 585f3eef26f04440bca726c29193af7b4fa90e54
commit-date: 2023-02-11
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

@taiki-e taiki-e added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Feb 12, 2023
@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Feb 12, 2023
taiki-e added a commit to taiki-e/pin-project that referenced this issue Feb 12, 2023
rust-lang/rust#107950

```
error: unresolved link to `core::pin`
   --> pin-project-internal/src/lib.rs:486:23
    |
486 | /// [pin-projection]: core::pin#projections-and-structural-pinning
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope
    |
    = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:100:34
    |
100 | /// 1. The struct must only be [`Unpin`] if all the structural fields are
    |                                  ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:101:10
    |
101 | ///    [`Unpin`].
    |          ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:103:73
    |
103 | ///    To enforce this, this attribute will automatically generate an [`Unpin`]
    |                                                                         ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:105:20
    |
105 | ///    fields be [`Unpin`].
    |                    ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:107:39
    |
107 | ///    If you attempt to provide an [`Unpin`] impl, the blanket impl will then
    |                                       ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:111:42
    |
111 | ///    If you wish to provide a manual [`Unpin`] impl, you can do so via the
    |                                          ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:127:39
    |
127 | ///    If you attempt to provide an [`Drop`] impl, the blanket impl will then
    |                                       ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:131:42
    |
131 | ///    If you wish to provide a custom [`Drop`] impl, you can annotate an impl
    |                                          ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `core::pin::Pin`
   --> pin-project-internal/src/lib.rs:483:14
    |
483 | /// [`Pin`]: core::pin::Pin
    |              ^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `core::pin`
   --> pin-project-internal/src/lib.rs:485:23
    |
485 | /// [drop-guarantee]: core::pin#drop-guarantee
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `core::pin::Pin::as_mut`
   --> pin-project-internal/src/lib.rs:481:22
    |
481 | /// [`Pin::as_mut`]: core::pin::Pin::as_mut
    |                      ^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:289:34
    |
289 | /// If you want to ensure that [`Unpin`] is not implemented, use the `!Unpin`
    |                                  ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `core::marker::PhantomPinned`
   --> pin-project-internal/src/lib.rs:480:24
    |
480 | /// [`PhantomPinned`]: core::marker::PhantomPinned
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:321:32
    |
321 | /// If you want to implement [`Unpin`] manually, you must use the `UnsafeUnpin`
    |                                ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:338:7
    |
338 | /// [`Unpin`] trait. [`UnsafeUnpin`] behaves exactly like [`Unpin`], except that
    |       ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:338:61
    |
338 | /// [`Unpin`] trait. [`UnsafeUnpin`] behaves exactly like [`Unpin`], except that
    |                                                             ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Unpin`
   --> pin-project-internal/src/lib.rs:342:7
    |
342 | /// [`Unpin`].
    |       ^^^^^ no item named `Unpin` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:348:65
    |
348 | /// In order to correctly implement pin projections, a type's [`Drop`] impl must
    |                                                                 ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop::drop`
   --> pin-project-internal/src/lib.rs:350:7
    |
350 | /// [`Drop::drop`] takes `&mut Self`, not [`Pin`]`<&mut Self>`.
    |       ^^^^^^^^^^ no item named `Drop` in scope

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:353:22
    |
353 | /// will provide a [`Drop`] impl for you. This [`Drop`] impl will delegate to
    |                      ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:353:50
    |
353 | /// will provide a [`Drop`] impl for you. This [`Drop`] impl will delegate to
    |                                                  ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:357:47
    |
357 | /// This impl block acts just like a normal [`Drop`] impl,
    |                                               ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:370:46
    |
370 | /// `#[pin_project]` implements the actual [`Drop`] trait via `PinnedDrop` you
    |                                              ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `drop`
   --> pin-project-internal/src/lib.rs:371:73
    |
371 | /// implemented. To drop a type that implements `PinnedDrop`, use the [`drop`]
    |                                                                         ^^^^ no item named `drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:372:67
    |
372 | /// function just like dropping a type that directly implements [`Drop`].
    |                                                                   ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop::drop`
   --> pin-project-internal/src/lib.rs:375:7
    |
375 | /// [`Drop::drop`].
    |       ^^^^^^^^^^ no item named `Drop` in scope

error: unresolved link to `core::pin::Pin::set`
   --> pin-project-internal/src/lib.rs:482:19
    |
482 | /// [`Pin::set`]: core::pin::Pin::set
    |                   ^^^^^^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `core::marker::PhantomData`
   --> pin-project-internal/src/lib.rs:479:22
    |
479 | /// [`PhantomData`]: core::marker::PhantomData
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `Sized`
   --> pin-project-internal/src/lib.rs:425:63
    |
425 | /// This method is opt-in, because it is only supported for [`Sized`] types, and
    |                                                               ^^^^^ no item named `Sized` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:498:55
    |
498 | /// An attribute used for custom implementations of [`Drop`].
    |                                                       ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:504:7
    |
504 | /// [`Drop`] impl, except for the following two:
    |       ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `core::pin::Pin`
   --> pin-project-internal/src/lib.rs:573:14
    |
573 | /// [`Pin`]: core::pin::Pin
    |              ^^^^^^^^^^^^^^ no item named `core` in scope

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:516:46
    |
516 | /// `#[pin_project]` implements the actual [`Drop`] trait via `PinnedDrop` you
    |                                              ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `drop`
   --> pin-project-internal/src/lib.rs:517:73
    |
517 | /// implemented. To drop a type that implements `PinnedDrop`, use the [`drop`]
    |                                                                         ^^^^ no item named `drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:518:67
    |
518 | /// function just like dropping a type that directly implements [`Drop`].
    |                                                                   ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop::drop`
   --> pin-project-internal/src/lib.rs:521:7
    |
521 | /// [`Drop::drop`].
    |       ^^^^^^^^^^ no item named `Drop` in scope

error: unresolved link to `Drop::drop`
   --> pin-project-internal/src/lib.rs:557:23
    |
557 | /// the same way as [`Drop::drop`], but the library cannot do it. So, by using
    |                       ^^^^^^^^^^ no item named `Drop` in scope

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:568:32
    |
568 | /// This allows implementing [`Drop`] safely using `#[pinned_drop]`.
    |                                ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `drop`
   --> pin-project-internal/src/lib.rs:569:25
    |
569 | /// Also by using the [`drop`] function just like dropping a type that directly
    |                         ^^^^ no item named `drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: unresolved link to `Drop`
   --> pin-project-internal/src/lib.rs:570:18
    |
570 | /// implements [`Drop`], can drop safely a type that implements `PinnedDrop`.
    |                  ^^^^ no item named `Drop` in scope
    |
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
```
@petrochenkov petrochenkov self-assigned this Feb 12, 2023
@petrochenkov
Copy link
Contributor

Fixed in #107951.

@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 13, 2023
@fmease

This comment was marked as resolved.

@rustbot rustbot added the A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name label Feb 13, 2023
@bors bors closed this as completed in 4a0f088 Feb 19, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 16, 2023
@Megadash452
Copy link

This seems to still be a problem with re-exports of proc-macros, except that cargo doc does not give any warnings. The only intra-doc-links that work are for other macros defined by that proc-macro crate.

Using a library crate on 1.83.0, but I also noticed this on earlier versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
7 participants