rust/compiler/rustc_lint/src
Matthias Krüger 226ce31edd
Rollup merge of #108200 - jhpratt:restricted-damerau-levenshtein-distance, r=tmiasko
Use restricted Damerau-Levenshtein distance for diagnostics

This replaces the existing Levenshtein algorithm with the Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change (a transposition) instead of two (a deletion and insertion). More specifically, this is a _restricted_ implementation, in that "ca" to "abc" cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the middle of a transposition. I believe that errors like that are sufficiently rare that it's not worth taking into account.

This was first brought up [on IRLO](https://internals.rust-lang.org/t/18227) when it was noticed that the diagnostic for `prinltn!` (transposed L and T) was `print!` and not `println!`. Only a single existing UI test was effected, with the result being an objective improvement.

~~I have left the method name and various other references to the Levenshtein algorithm untouched, as the exact manner in which the edit distance is calculated should not be relevant to the caller.~~

r? ``@estebank``

``@rustbot`` label +A-diagnostics +C-enhancement
2023-02-20 14:32:55 +01:00
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
builtin.rs Add Clause::ConstArgHasType variant 2023-02-17 09:30:33 +00:00
context.rs Make public API, docs algorithm-agnostic 2023-02-19 04:11:10 +00:00
deref_into_dyn_supertrait.rs Don't eagerly convert principal to string 2023-02-17 14:44:58 +00:00
early.rs fix issues in unused lint 2023-01-14 17:11:04 +08:00
enum_intrinsics_non_enums.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
errors.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
expect.rs Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot 2023-01-13 13:57:21 +00:00
for_loops_over_fallibles.rs if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
hidden_unicode_codepoints.rs migrate: hidden_unicode_codepoints.rs 2023-01-09 17:07:25 -05:00
internal.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
late.rs Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
let_underscore.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
levels.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
lib.rs make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
lints.rs Don't eagerly convert principal to string 2023-02-17 14:44:58 +00:00
methods.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
multiple_supertrait_upcastable.rs Reintroduce multiple_supertrait_upcastable lint 2023-01-28 15:08:07 +00:00
non_ascii_idents.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
non_fmt_panic.rs Use is_str instead of string kind comparison 2023-02-13 19:06:22 +00:00
nonstandard_style.rs Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
noop_method_call.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
opaque_hidden_inferred_bound.rs Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
pass_by_value.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
passes.rs Take a LocalDefId in hir::Visitor::visit_fn. 2023-01-28 09:51:50 +00:00
redundant_semicolon.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs refactor: cleanup 2023-01-09 18:57:02 -05:00
types.rs remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
unused.rs s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00