Rust: Allow for crate self-references in crate graph paths#19265
Merged
hvitved merged 1 commit intogithub:mainfrom Apr 9, 2025
Merged
Rust: Allow for crate self-references in crate graph paths#19265hvitved merged 1 commit intogithub:mainfrom
hvitved merged 1 commit intogithub:mainfrom
Conversation
aibaars
approved these changes
Apr 9, 2025
Contributor
aibaars
left a comment
There was a problem hiding this comment.
Looks good to me, although I should probably improve the crate graph extractor to do the right thing at some point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extractor produces fully crate-qualified paths for entities extracted from the crate graph, which our path resolution logic handles. However, for entities where the crate-qualifier refers to the defining crate itself, the extractor should have used the special
cratequalifier instead of the name of the crate.For example, the
impl<T> Option<T>block is extracted asimpl<T> core::option::Option<T>instead ofimpl<T> crate::option::Option<T>.This PR adjusts our path resolution logic to also handle crate self-references like above, but restricted to entities from the crate graph.
DCA shows that, while we maintain performance, we reduce the number of unresolved call targets by 16 % (down 1,699,468 from 2,012,848), all numbers computed across the entire DCA suite.
cc @aibaars