-
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
Move lev_distance to rustc_ast, make non-generic #79000
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Ping? |
@bors r+ |
📌 Commit 954f7e68a3ccefbdc7e3f7b2951c42dcd11963fc has been approved by |
⌛ Testing commit 954f7e68a3ccefbdc7e3f7b2951c42dcd11963fc with merge ba97da43eb217b8a82764e1773459c116155cc63... |
💔 Test failed - checks-actions |
954f7e6
to
63117ba
Compare
@bors r+ |
📌 Commit 63117ba70b2276f2ef796870af1d41ca72a602fc has been approved by |
The update 63117ba was just a rebase. There were no merge conflicts. |
⌛ Testing commit 63117ba70b2276f2ef796870af1d41ca72a602fc with merge e576ed0a8f3fbc79cb86ccf7075a18f0000d34f2... |
@bors r- retry Can we squash commit history here into one commit? You can see https://rustc-dev-guide.rust-lang.org/git.html#advanced-rebasing for some help on how to do that or we can do it for you if that'd be helpful :) |
Certainly. I thought GitHub handled that as one of its forms of committing? I know ADO does, but I just assumed GH did, too. |
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST would not have any dependency its lexer, for minimizing unnecessarily design-time dependencies. Breaking this dependency would also have practical benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast. This commit does not remove the rustc_ast --> rustc_lexer dependency, but it does remove one of the sources of this dependency, which is the code that handles fuzzy matching between symbol names for making suggestions in diagnostics. Since that code depends only on Symbol, it is easy to move it to rustc_span. It might even be best to move it to a separate crate, since other tools such as Cargo use the same algorithm, and have simply contain a duplicate of the code. This changes the signature of find_best_match_for_name so that it is no longer generic over its input. I checked the optimized binaries, and this function was duplicated at nearly every call site, because most call sites used short-lived iterator chains, generic over Map and such. But there's no good reason for a function like this to be generic, since all it does is immediately convert the generic input (the Iterator impl) to a concrete Vec<Symbol>. This has all of the costs of generics (duplicated method bodies) with no benefit. Changing find_best_match_for_name to be non-generic removed about 10KB of code from the optimized binary. I know it's a drop in the bucket, but we have to start reducing binary size, and beginning to tame over-use of generics is part of that.
63117ba
to
5481c1b
Compare
Squashed, fetched, rebased, push-f'd. :) |
@bors r+ |
📌 Commit 5481c1b has been approved by |
🌲 The tree is currently closed for pull requests below priority 500, this pull request will be tested once the tree is reopened |
…as-schievink Rollup of 10 pull requests Successful merges: - rust-lang#77758 (suggest turbofish syntax for uninferred const arguments) - rust-lang#79000 (Move lev_distance to rustc_ast, make non-generic) - rust-lang#79362 (Lower patterns before using the bound variable) - rust-lang#79365 (Upgrades the coverage map to Version 4) - rust-lang#79402 (Fix typos) - rust-lang#79412 (Clean up rustdoc tests by removing unnecessary features) - rust-lang#79413 (Fix persisted doctests on Windows / when using workspaces) - rust-lang#79420 (Fixes a word typo in librustdoc) - rust-lang#79421 (Fix docs formatting for `thir::pattern::_match`) - rust-lang#79428 (Fixup compiler docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.
This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.
This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated for nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec. This has all of the costs of generics (duplicated method bodies)
with no benefit.
Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.