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 ICE when documentation includes intra-doc-link #66211

Merged
merged 2 commits into from
Nov 14, 2019

Conversation

kinnison
Copy link
Contributor

@kinnison kinnison commented Nov 8, 2019

When collecting intra-doc-links we could trigger the loading of extra crates into the crate store due to name resolution finding crates referred to in documentation but not in code. This might be due to
configuration differences or simply referring to something else.

This would cause an ICE because the newly loaded crate metadata existed in a crate store associated with the rustdoc global context, but the resolver had its own crate store cloned just before the documentation processing began and as such it could try and look up crates in a store which lacked them.

In this PR, I add support for --extern-private to the rustdoc tool so that it is supported for compiletest to then pass the crates in; and then I fix the issue by forcing the resolver to look over all the crates before we then lower the input ready for processing into documentation.

The first commit (the --extern-private) could be replaced with a commit which adds support for --extern to compiletest if preferred, though I think that adding --extern-private to rustdoc is more useful anyway since it makes the CLI a little more like rustc's which might help reduce surprise for someone running it by hand or in their own test code.

The PR is meant to fix #66159 though it may also fix #65840.

cc @GuillaumeGomez

This makes `rustdoc` support `--extern-private` but treats it
the same as `--extern` which is useful for making the CLI more
similar to `rustc` to ease test suite integration.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
In order that we can successfully later resolve paths in crates
which weren't loaded as a result of merely parsing the crate
we're documenting, we force the resolution of the path to each
crate before cloning the resolver to use later.  Closes rust-lang#66159

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
@GuillaumeGomez
Copy link
Member

Just to be sure: if we don't pass the --external-private, does it still crash?

@kinnison
Copy link
Contributor Author

kinnison commented Nov 8, 2019

Just to be sure: if we don't pass the --external-private, does it still crash?

No, I had to add the capability in order to trigger the crash, otherwise it's just an unresolvable path.

@Dylan-DPC-zz Dylan-DPC-zz added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 9, 2019
@Dylan-DPC-zz
Copy link

r? @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

Then it's all good for me. Thanks a lot @kinnison !

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 13, 2019

📌 Commit 33ded3e has been approved by GuillaumeGomez

@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 Nov 13, 2019
@bors
Copy link
Contributor

bors commented Nov 13, 2019

⌛ Testing commit 33ded3e with merge 3f07f1c...

bors added a commit that referenced this pull request Nov 13, 2019
Fix ICE when documentation includes intra-doc-link

When collecting intra-doc-links we could trigger the loading of extra crates into the crate store due to name resolution finding crates referred to in documentation but not in code.  This might be due to
configuration differences or simply referring to something else.

This would cause an ICE because the newly loaded crate metadata existed in a crate store associated with the rustdoc global context, but the resolver had its own crate store cloned just before the documentation processing began and as such it could try and look up crates in a store which lacked them.

In this PR, I add support for `--extern-private` to the `rustdoc` tool so that it is supported for `compiletest` to then pass the crates in; and then I fix the issue by forcing the resolver to look over all the crates before we then lower the input ready for processing into documentation.

The first commit (the `--extern-private`) could be replaced with a commit which adds support for `--extern` to `compiletest` if preferred, though I think that adding `--extern-private` to `rustdoc` is more useful anyway since it makes the CLI a little more like `rustc`'s which might help reduce surprise for someone running it by hand or in their own test code.

The PR is meant to fix #66159 though it may also fix #65840.

cc @GuillaumeGomez
@bors
Copy link
Contributor

bors commented Nov 14, 2019

☀️ Test successful - checks-azure
Approved by: GuillaumeGomez
Pushing 3f07f1c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 14, 2019
@bors bors merged commit 33ded3e into rust-lang:master Nov 14, 2019
@bors bors mentioned this pull request Nov 14, 2019
@@ -142,6 +142,10 @@ fn opts() -> Vec<RustcOptGroup> {
stable("extern", |o| {
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
}),
stable("extern-private", |o| {
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be stable, it's not even stable in rustc: #66655

@GuillaumeGomez
Copy link
Member

@ollie27 Good catch! Sending a fix.

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.
Projects
None yet
6 participants