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: Fix ICE for intra-doc link on intermediate re-export #109330

Merged

Conversation

GuillaumeGomez
Copy link
Member

Fixes #109282.

This PR is based on #109266 as it includes its commit to make this work.

@petrochenkov: It was exactly as you predicted, adding the DefId to the attributes fixed the error for intermediate re-exports as well. Thanks a lot!

r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 18, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 18, 2023

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

@petrochenkov petrochenkov added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 18, 2023
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

Blocked on #109312.

@bors

This comment was marked as resolved.

@petrochenkov petrochenkov removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Mar 23, 2023
@petrochenkov
Copy link
Contributor

#109312 has landed.
@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 23, 2023
@GuillaumeGomez GuillaumeGomez force-pushed the intermediate-reexport-intra-doc-ice branch from a685837 to c8c342c Compare March 23, 2023 11:53
@GuillaumeGomez
Copy link
Member Author

Rebased.

@bors ready

@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 23, 2023
@petrochenkov petrochenkov 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 Mar 23, 2023
@GuillaumeGomez
Copy link
Member Author

I used Cow to avoid clones as much as possible. It's still necessary in one place (where we edit an attribute) but it's the only place. It also allowed to remove the need to create temporary Vec, which is quite nice.

As for AttributesExt: its cfg method is used in a lot of different places, which in itself isn't a problem, except that if the function was moved out of the trait, it would require to instead either:

  • Write two functions, each taking a different kind of iterable data.
  • Take two callbacks to get the iterators.

I think none of these options is better than the current status so I preferred to keep it as is. One think I did though was to remove its span associated function since it was used only in place, so no need to keep it there.

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

@GuillaumeGomez
Could you check whether this PR fixes the linked issues - #109631 #109614 #109424?
(And add "fixes" annotations to the PR description if they do.)

@GuillaumeGomez
Copy link
Member Author

Sure.

@GuillaumeGomez
Copy link
Member Author

Checked the 3 issues with the fix and the 3 still fail.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 27, 2023

📌 Commit 87ea994 has been approved by 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 27, 2023
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#109330 (rustdoc: Fix ICE for intra-doc link on intermediate re-export)
 - rust-lang#109354 (Remove the `NodeId` of `ast::ExprKind::Async`)
 - rust-lang#109445 (Allow passing the --nocapture flag to compiletest)
 - rust-lang#109512 (bump `askama_derive` to 0.12.1)
 - rust-lang#109637 (Add missing needs-asm-support annotation to ui/simple_global_asm.rs)
 - rust-lang#109666 (Correct ASCII case comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 52c8084 into rust-lang:master Mar 27, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 27, 2023
@GuillaumeGomez GuillaumeGomez deleted the intermediate-reexport-intra-doc-ice branch March 28, 2023 08:20
let mut visitor = OneLevelVisitor::new(hir_map, target_def_id);
let mut visited = FxHashSet::default();

// If the item is an import and has at least a path with two parts, we go into it.
while let hir::ItemKind::Use(path, _) = item.kind && visited.insert(item.hir_id()) {
let import_parent = cx.tcx.opt_local_parent(prev_import).map(|def_id| def_id.to_def_id());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GuillaumeGomez
This PR wasn't rebased correctly, after #109312 doc fragment contain ids of imports themselves, not their parent modules.
This is most likely the reason why this PR doesn't fix the rustix issues it was supposed to fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this during rebase of #109500.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. It's surprising that the test I added was still working then. Well, great that your PR fixed it.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 9, 2023
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with rust-lang#109330 and therefore
Fixes rust-lang#109631
Fixes rust-lang#109614
Fixes rust-lang#109424
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Jun 1, 2023
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with rust-lang/rust#109330 and therefore
Fixes rust-lang/rust#109631
Fixes rust-lang/rust#109614
Fixes rust-lang/rust#109424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Fix ICE for intra-doc link on intermediate re-export
5 participants