-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
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>
8077b91
to
33ded3e
Compare
Just to be sure: if we don't pass the |
No, I had to add the capability in order to trigger the crash, otherwise it's just an unresolvable path. |
📌 Commit 33ded3e has been approved by |
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
☀️ Test successful - checks-azure |
@@ -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| { |
There was a problem hiding this comment.
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
@ollie27 Good catch! Sending a fix. |
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 therustdoc
tool so that it is supported forcompiletest
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
tocompiletest
if preferred, though I think that adding--extern-private
torustdoc
is more useful anyway since it makes the CLI a little more likerustc
'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