-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: Pre-calculate traits that are in scope for doc links #88679
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
@bors try @rust-timer queue Since encoding and decoding are performance sensitive. |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 1514df2159ed22849eaddfd75c5e57cf801de6d4 with merge 2aadece0d9989be6855d4e96bac0f4ec08f23c91... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Typo? #88679 is this PR. |
1514df2
to
1ed1f29
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 1ed1f29e01aedafd3a4dcb253de4be5da9a9eade with merge eec63217b0c2bd2bd82596fe0f8f6ccc5b9cc1a0... |
☀️ Test successful - checks-actions |
Finished benchmarking commit (788b1fe): comparison url. Summary: This benchmark run shows 43 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
@petrochenkov FYI, this seems to have broken one of my nightly CI runs, not sure if that's expected: https://github.com/trevyn/turbosql/runs/4960657119?check_suite_focus=true
|
@trevyn |
Ok, apparently this is enough to trigger it on my side, not sure I feel like minimizing Cargo.toml: [package]
edition = "2018"
name = "test"
version = "0.1.0"
[dependencies]
rusqlite = "0.26" lib.rs: use rusqlite; |
The panic in #88679 (comment) happens because an inherent impl from How is that even possible? |
I think it would happen if |
Maybe it's inlined internally, but it doesn't end up in the generated doc. |
Weird. I have no idea why that impl is being inlined then. |
I didn't figure out why that specific impl was inlined, but there are legitimate cases where inherent impls are inlined correctly, but traits in scope are not collected for them: // Dependency crate
#[derive(Clone)]
pub struct PublicStruct;
mod inner {
use super::PublicStruct;
impl PublicStruct {
/// [PublicStruct::clone]
pub fn method() {}
}
} // Main crate
pub use dependency::PublicStruct; |
Both cases (#88679 (comment) and #88679 (comment)) are fixed in #93539. |
…elwoerister rustdoc: Collect traits in scope for foreign inherent impls Inherent impls can be inlined for variety of reasons (impls of reexported types, impls available through `Deref`, impls inlined for unclear reasons like in rust-lang#88679 (comment)). If an impl is inlined, then doc links in its comments are resolved and we may need the set of traits that are in scope at that impl's definition point. So in this PR we simply collect traits in scope for *all* inherent impls from other crates if their `Self` type is public, which is very similar for the strategy for trait impls previously used in rust-lang#88679. Fixes rust-lang#93476 Fixes rust-lang#88679 (comment) Fixes rust-lang#88679 (comment)
Since rust-lang#88679, rustdoc doesn't load crates eagerly. Add an explicit `extern crate` item to make sure the crate is loaded and the bug reproduces. You can verify this fix by adding `// compile-flags: -Znormalizing-docs` and running the test.
…ompiler-errors Make the `normalize-overflow` rustdoc test actually do something Since rust-lang#88679, rustdoc doesn't load crates eagerly. Add an explicit `extern crate` item to make sure the crate is loaded and the bug reproduces. You can verify this fix by adding `// compile-flags: -Znormalize-docs` and running the test to make sure it gives an error.
…ompiler-errors Make the `normalize-overflow` rustdoc test actually do something Since rust-lang#88679, rustdoc doesn't load crates eagerly. Add an explicit `extern crate` item to make sure the crate is loaded and the bug reproduces. You can verify this fix by adding `// compile-flags: -Znormalize-docs` and running the test to make sure it gives an error.
…ompiler-errors Make the `normalize-overflow` rustdoc test actually do something Since rust-lang#88679, rustdoc doesn't load crates eagerly. Add an explicit `extern crate` item to make sure the crate is loaded and the bug reproduces. You can verify this fix by adding `// compile-flags: -Znormalize-docs` and running the test to make sure it gives an error.
This eliminates one more late use of resolver (part of #83761).
At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by
collect-intra-doc-links
pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes.r? @jyn514