9

fix intra-doc links on nested `use` and `extern crate` items by lukas-code · Pul...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/113958
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested use or extern crate items, for example:

/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested use items that are declared pub.

  std 
  stdfmt
  stdio

For extern crate, there was a hack in rustdoc that stored the DefId of the crate itself in the cleaned item, instead of the DefId of the extern crate item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the extern crate item. I've removed this hack and instead translate the DefId in the appropriate places.

As as side effect of fixing extern crate, i've turned

#[doc(masked)]
extern crate self as _;

into a no-op instead of hiding all trait impls. Proper verification for doc(masked) is included as a bonus.

fixes #113896


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK