-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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: Avoid duplicating macros in sidebar #94002
rustdoc: Avoid duplicating macros in sidebar #94002
Conversation
@@ -250,6 +250,8 @@ impl<'tcx> Context<'tcx> { | |||
fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap<String, Vec<NameDoc>> { | |||
// BTreeMap instead of HashMap to get a sorted output | |||
let mut map: BTreeMap<_, Vec<_>> = BTreeMap::new(); | |||
let mut inserted: FxHashMap<ItemType, FxHashSet<Symbol>> = FxHashMap::default(); |
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.
Using a map to skip duplicates doesn't seem like the correct approach to me. We shouldn't have two macros with the same name in the module in the first place, right?
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.
It's possible because of reexports. Initially, I had rewrote using a BTreeMap
but then I discovered that we had an option to keep the declaration order. So I had to revert that and instead using a Hashmap
alongside...
// This test ensures that there is no macro duplicates in the sidebar. | ||
goto: file://|DOC_PATH|/test_docs/macro.a.html | ||
// Waiting for the elements in the sidebar to be rendered. | ||
wait-for: ".sidebar-elems .others .macro" | ||
// Check there is only one macro named "a" listed in the sidebar. | ||
assert-count: ( | ||
"//*[@class='sidebar-elems']//*[@class='others']/*[@class='block macro']//li/a[text()='a']", | ||
1, | ||
) | ||
// Check there is only one macro named "b" listed in the sidebar. | ||
assert-count: ( | ||
"//*[@class='sidebar-elems']//*[@class='others']/*[@class='block macro']//li/a[text()='b']", | ||
1, | ||
) |
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 should be a regular HTML test using @count
, not a GUI test.
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.
It's generated by the JS, so can't do that. ^^'
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.
It is? Somewhat off-topic, but why?
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.
I'm wondering the same thing... Will need to dive into this to understand.
It's documented in the JS that does it: for crates with large numbers of
items, there would be an n^2 blowup in size, if each page contained a
listing of all other pages in its sidebar.
|
Thanks for the explanation! :) |
I guess this PR seems correct, but I don't have time to check further unfortunately. r? @jsha |
@notriddle might know this area better. Well, we'll see. 😉 |
This looks like a reasonable choice to me. |
Then let's go! @bors: r=notriddle rollup |
📌 Commit d9ea7bc has been approved by |
…acro, r=notriddle rustdoc: Avoid duplicating macros in sidebar Fixes rust-lang#93912. cc `@jsha` (for the GUI test) r? `@camelid`
…acro, r=notriddle rustdoc: Avoid duplicating macros in sidebar Fixes rust-lang#93912. cc ``@jsha`` (for the GUI test) r? ``@camelid``
…acro, r=notriddle rustdoc: Avoid duplicating macros in sidebar Fixes rust-lang#93912. cc ```@jsha``` (for the GUI test) r? ```@camelid```
…acro, r=notriddle rustdoc: Avoid duplicating macros in sidebar Fixes rust-lang#93912. cc ````@jsha```` (for the GUI test) r? ````@camelid````
…acro, r=notriddle rustdoc: Avoid duplicating macros in sidebar Fixes rust-lang#93912. cc `````@jsha````` (for the GUI test) r? `````@camelid`````
…askrgr Rollup of 14 pull requests Successful merges: - rust-lang#93580 (Stabilize pin_static_ref.) - rust-lang#93639 (Release notes for 1.59) - rust-lang#93686 (core: Implement ASCII trim functions on byte slices) - rust-lang#94002 (rustdoc: Avoid duplicating macros in sidebar) - rust-lang#94019 (removing architecture requirements for RustyHermit) - rust-lang#94023 (adapt static-nobundle test to use llvm-nm) - rust-lang#94091 (Fix rustdoc const computed value) - rust-lang#94093 (Fix pretty printing of enums without variants) - rust-lang#94097 (Add module-level docs for `rustc_middle::query`) - rust-lang#94112 (Optimize char_try_from_u32) - rust-lang#94113 (document rustc_middle::mir::Field) - rust-lang#94122 (Fix miniz_oxide types showing up in std docs) - rust-lang#94142 (rustc_typeck: adopt let else in more places) - rust-lang#94146 (Adopt let else in more places) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #93912.
cc @jsha (for the GUI test)
r? @camelid