-
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
Improve how rustdoc warnings are displayed #44350
Conversation
The following version of fn check_attributes(attrs1: &HashMap<String, String>, attrs2: &HashMap<String, String>) -> bool {
/// For strings that match "something-N", returns "something", else returns the whole string
fn extract_attr(value: &str) -> &str {
let mut iter = value.rsplitn(2, '-');
if let (Some(n), Some(tag)) = (iter.next(), iter.next()) {
if n.parse::<usize>().is_ok() {
tag
} else {
value
}
} else {
value
}
}
if let (Some(id1), Some(id2)) = (attrs1.get("id"), attrs2.get("id")) {
let tag1 = extract_attr(id1);
let tag2 = extract_attr(id2);
tag1 == tag2
} else {
!attrs1.contains_key("id") && !attrs2.contains_key("id")
}
} |
On the other hand, even with that change, it still prints the warning, just now it doesn't print the actual difference. You'll need to float whether to print the warning at all out of |
This isn't a false positive, it's just a bug in rustdoc. The issue is that by rendering the Markdown twice |
@ollie27: Yes, that's why we need to catch it (I precised it in the code change I think). |
d423bb2
to
884989a
Compare
Updated. |
Fantastic! This cuts down on rendering warnings by an order of magnitude or more when rendering Rocket's dependencies (the first crate i checked). @bors r+ |
📌 Commit 884989a has been approved by |
I've submitted a PR to actually fix the bug so that none of this is necessary: #44368. |
Ooh, nice! @bors r- While i check out this other PR. The "don't print the warning heading" thing is still useful, but the bit about checking the header numbering may be better served with the new PR. |
The second commit will still be relevant though. ;) (for other checks) |
Since #44368 solves the "headers with diverging IDs" problem in a nicer fashion than the check introduced here, i want to pull that one in. However, like we've both said, this PR does more than that now. If you can yank out that first commit (good thinking, separating them like that 😛) and just keep the second one, we can make this PR focus on that instead. |
☔ The latest upstream changes (presumably #44474) made this pull request unmergeable. Please resolve the merge conflicts. |
@GuillaumeGomez ping to make sure this stays on your radar |
@alexcrichton: We now need to confirm that the other PR made this one useless. Waiting for your confirmation @QuietMisdreavus! ;) |
Yes, the bit that compared the IDs is superfluous now; #44368 took care of that. However, this PR as a whole isn't "useless", per se:
|
@QuietMisdreavus: Doing it! |
5ac512f
to
74652b7
Compare
Updated. |
src/librustdoc/html/render.rs
Outdated
ref elem_attributes, | ||
ref opposite_elem_attributes, | ||
.. } => { | ||
if !check_attributes(elem_attributes, opposite_elem_attributes) { |
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 thought we agreed that check_attributes
didn't need to be there any more >_>
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.
Ah my bad, completely misunderstood. ><
74652b7
to
5072972
Compare
5072972
to
7aa5367
Compare
The PR was patched up to take out the (now-superfluous) @bors r+ |
📌 Commit 7aa5367 has been approved by |
…eavus Improve how rustdoc warnings are displayed cc @rust-lang/dev-tools r? @nrc
☀️ Test successful - status-appveyor, status-travis |
cc @rust-lang/dev-tools
r? @nrc