-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Support multiple crate versions in --extern-html-root-url #143465
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
base: master
Are you sure you want to change the base?
Conversation
Tracks association between `self.sess.opts.externs` (aliases in `--extern alias=rlib`) and resolved `CrateNum` Intended to allow Rustdoc match the aliases in `--extern-html-root-url` rust-lang#76296 Force-injected extern crates aren't included, since they're meant for the linker only
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
And f9f6a70 is just a bit of redundant code I've noticed in the process, too small to give it a separate PR. |
This comment has been minimized.
This comment has been minimized.
cc @aDotInTheVoid @obi1kenobi - i haven’t checked if this will help distinguish versions for the json backend too but i think it might |
Yes, the URL is in the JSON, and can be creatively used to identify the crates. |
to be clear i do not think html-root-url should be used for this, i’m saying the new metadata you’ve added to CrateRoot might allow the json backend to emit structured metadata. |
#76296 doesn't demonstrate the entirety of how rustdoc has issues with resolving crate versions. There's also the case of non-renamed transitively reëxported multiple versions of a single package name. |
/// Save the name used to resolve the extern crate in the local crate | ||
/// | ||
/// The name isn't always the crate's own name, because `sess.opts.externs` can assign it another name. | ||
/// It's also not always the same as the `DefId`'s symbol due to renames `extern crate name as defid_name`. |
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.
nit: possibly intended with an underscore?
/// It's also not always the same as the `DefId`'s symbol due to renames `extern crate name as defid_name`. | |
/// It's also not always the same as the `DefId`'s symbol due to renames `extern crate_name as defid_name`. |
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.
No, extern crate
is a language construct.
Rustdoc's
--extern-html-root-url
used to usetcx.crate_name()
to identify crates, but that used crates' internal names from their metadata, instead of names given to them in--extern
. That was confusing, because both--extern…
arguments seem related and use similar syntax. Crucially, this didn't work correctly with Cargo's package aliases or multiple versions of crates.sess.opts.externs
lacksCrateNum
, andResolver.extern_prelude
gets destroyed beforerustdoc
has a chance to see it, so I've had to save this mapping inCStore
.Just in case, I've kept the previous mapping by crate name as a fallback for crates that weren't matched by their extern name.
Fixes #76296