rust/compiler/rustc_span/src
Jonas Schievink 6fcd589025
Rollup merge of #79000 - sivadeilra:user/ardavis/lev_distance, r=wesleywiser
Move lev_distance to rustc_ast, make non-generic

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<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.
2020-11-26 13:39:05 +01:00
..
analyze_source_file mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
lev_distance Move lev_distance to rustc_ast, make non-generic 2020-11-24 16:12:23 -08:00
source_map mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
symbol mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
analyze_source_file.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
caching_source_map_view.rs rustc_span: represent line bounds with Range 2020-10-27 15:47:29 -07:00
def_id.rs Add some docs to rustdoc::clean::inline and def_id functions 2020-10-06 09:46:00 +00:00
edition.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
fatal_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
hygiene.rs Show the inline stack of MIR lints that only occur after inlining 2020-10-27 14:08:07 +00:00
lev_distance.rs Move lev_distance to rustc_ast, make non-generic 2020-11-24 16:12:23 -08:00
lib.rs Move lev_distance to rustc_ast, make non-generic 2020-11-24 16:12:23 -08:00
source_map.rs Use RwLock instead of Lock for SourceMap::files 2020-10-29 18:09:53 +01:00
span_encoding.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
symbol.rs Rename optin_builtin_traits to auto_traits 2020-11-23 14:14:06 -08:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00