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

fix intra-doc links on nested use and extern crate items #113958

Merged
merged 5 commits into from
Jul 25, 2023

Conversation

lukas-code
Copy link
Member

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.

During AST->HIR lowering, nested use items are desugared like this:

pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;

Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with Resolver::local_def_id, which returns the (private) list stem for nested use items.

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

@rustbot
Copy link
Collaborator

rustbot commented Jul 22, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 22, 2023
@petrochenkov petrochenkov self-assigned this Jul 22, 2023
@GuillaumeGomez
Copy link
Member

Looks good to me, thanks!

Might be worth to have @petrochenkov take a look as well.

@davidtwco davidtwco removed their assignment Jul 24, 2023
@petrochenkov
Copy link
Contributor

r=me after fixing the articles.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2023
@petrochenkov
Copy link
Contributor

@bors r=GuillaumeGomez,petrochenkov

@bors
Copy link
Contributor

bors commented Jul 24, 2023

📌 Commit 637ea3f has been approved by GuillaumeGomez,petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 24, 2023
@bors
Copy link
Contributor

bors commented Jul 25, 2023

⌛ Testing commit 637ea3f with merge beef07f...

@bors
Copy link
Contributor

bors commented Jul 25, 2023

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez,petrochenkov
Pushing beef07f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 25, 2023
@bors bors merged commit beef07f into rust-lang:master Jul 25, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 25, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (beef07f): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.2%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 652.747s -> 650.991s (-0.27%)

@lukas-code lukas-code deleted the doc-links branch July 25, 2023 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic documenting local juice repo
7 participants