-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Conversation
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. |
I think the name resolution method used here should be documented in the rustdoc book |
This is better than I originally assumed, the crate lookup algorithm is not changed, only some already calculated data is exposed. |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
b0125e5
to
75c2eef
Compare
This comment has been minimized.
This comment has been minimized.
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` Force-injected extern crates aren't included, since they're meant for the linker only
@petrochenkov is this okay to merge then? |
This was never marked as |
@bors r+ |
Rollup of 4 pull requests Successful merges: - #143465 (Support multiple crate versions in --extern-html-root-url) - #144308 ([rustdoc] Display total time and compilation time of merged doctests) - #144655 (clean up codegen fn attrs) - #144675 (Reject running `compiletest` self-tests against stage 0 rustc unless explicitly allowed) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #143465 - kornelski:extern-name, r=petrochenkov Support multiple crate versions in --extern-html-root-url Rustdoc's `--extern-html-root-url` used to use `tcx.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` lacks `CrateNum`, and `Resolver.extern_prelude` gets destroyed before `rustdoc` has a chance to see it, so I've had to save this mapping in `CStore`. 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
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