-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustdoc: improve refdef handling in the unresolved link lint #136363
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: improve refdef handling in the unresolved link lint #136363
Conversation
/// The [cln][] link here is going to be unresolved, because `struct@Clone` gets //~ERROR link | ||
/// rejected in Markdown for not being URL-shaped enough. |
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 comment was wrong.
struct@Clone
is URL-ish enough to match CommonMark's refdef grammar. The reason it was rejected before was because the //~ERROR link
hot comment got fed to the markdown parser, and, as a result, caused the refdef to not get parsed there.
By using a below-the-line comment, I can work around that and demonstrate the change correctly.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
27c6b66
to
d15dfe7
Compare
|
||
links.push(preprocess_link(&dest_url)); | ||
} | ||
_ => {} | ||
} | ||
} | ||
|
||
for (label, refdef) in event_iter.reference_definitions().iter() { |
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 logic is run on a compiler's happy path, when rustdoc and its lints are not involved.
Could you do a perf run before merging this?
Not a problem. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…unused-refdef, r=<try> rustdoc: improve refdef handling in the unresolved link lint This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes. Closes rust-lang#133150 since this lint would have caught the mistake in that issue, and, along with rust-lang/rust-clippy#13707, most mistakes in this class should produce a warning from one of them.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (230bb73): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -1.6%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -2.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 779.425s -> 779.101s (-0.04%) |
The two regressions are both |
It's really cool, great idea! Perf impact seems acceptable to me. Not sure if we are waiting on petrochenkov or not so I'll let you r+. |
The result of the lint is no perf impacts other than rustdoc, so it shouldn't be a problem. @bors r=GuillaumeGomez |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
…unused-refdef, r=GuillaumeGomez rustdoc: improve refdef handling in the unresolved link lint This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes. Closes rust-lang#133150 since this lint would have caught the mistake in that issue, and, along with rust-lang/rust-clippy#13707, most mistakes in this class should produce a warning from one of them.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes.
d15dfe7
to
4d551dd
Compare
Rebased it. This change required weird-syntax.stderr to be re-blessed because of a minor output change: - LL | /// [cln]: trait@Clone
- | ~~~~~~
+ LL - /// [cln]: struct@Clone
+ LL + /// [cln]: trait@Clone @bors r=GuillaumeGomez |
☀️ Test successful - checks-actions |
Finished benchmarking commit (23032f3): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 790.759s -> 789.651s (-0.14%) |
This commit takes advantage of a feature in pulldown-cmark that makes the list of link definitions available to the consuming application. It produces unresolved link warnings for refdefs that aren't used, and can now produce exact spans for the dest even when it has escapes.
Closes #133150 since this lint would have caught the mistake in that issue, and, along with rust-lang/rust-clippy#13707, most mistakes in this class should produce a warning from one of them.