Skip to content

Commit 378c4ab

Browse files
committed
Make public API, docs algorithm-agnostic
1 parent c2f2a3c commit 378c4ab

File tree

16 files changed

+81
-73
lines changed

16 files changed

+81
-73
lines changed

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1313
use rustc_hir::PredicateOrigin;
1414
use rustc_index::vec::{Idx, IndexVec};
1515
use rustc_middle::ty::{DefIdTree, ResolverAstLowering, TyCtxt};
16-
use rustc_span::lev_distance::find_best_match_for_name;
16+
use rustc_span::edit_distance::find_best_match_for_name;
1717
use rustc_span::source_map::DesugaringKind;
1818
use rustc_span::symbol::{kw, sym, Ident};
1919
use rustc_span::{Span, Symbol};

compiler/rustc_hir_analysis/src/astconv/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir as hir;
66
use rustc_hir::def_id::DefId;
77
use rustc_middle::ty;
88
use rustc_session::parse::feature_err;
9-
use rustc_span::lev_distance::find_best_match_for_name;
9+
use rustc_span::edit_distance::find_best_match_for_name;
1010
use rustc_span::symbol::{sym, Ident};
1111
use rustc_span::{Span, Symbol, DUMMY_SP};
1212

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use rustc_middle::ty::DynKind;
3434
use rustc_middle::ty::GenericParamDefKind;
3535
use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitable};
3636
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
37+
use rustc_span::edit_distance::find_best_match_for_name;
3738
use rustc_span::edition::Edition;
38-
use rustc_span::lev_distance::find_best_match_for_name;
3939
use rustc_span::symbol::{kw, Ident, Symbol};
4040
use rustc_span::{sym, Span, DUMMY_SP};
4141
use rustc_target::spec::abi;

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use rustc_middle::ty::subst::SubstsRef;
4545
use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitable};
4646
use rustc_session::errors::ExprParenthesesNeeded;
4747
use rustc_session::parse::feature_err;
48+
use rustc_span::edit_distance::find_best_match_for_name;
4849
use rustc_span::hygiene::DesugaringKind;
49-
use rustc_span::lev_distance::find_best_match_for_name;
5050
use rustc_span::source_map::{Span, Spanned};
5151
use rustc_span::symbol::{kw, sym, Ident, Symbol};
5252
use rustc_target::spec::abi::Abi::RustIntrinsic;

compiler/rustc_hir_typeck/src/method/probe.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use rustc_middle::ty::{InternalSubsts, SubstsRef};
2525
use rustc_session::lint;
2626
use rustc_span::def_id::DefId;
2727
use rustc_span::def_id::LocalDefId;
28-
use rustc_span::lev_distance::{
29-
find_best_match_for_name_with_substrings, lev_distance_with_substrings,
28+
use rustc_span::edit_distance::{
29+
edit_distance_with_substrings, find_best_match_for_name_with_substrings,
3030
};
3131
use rustc_span::symbol::sym;
3232
use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
@@ -70,7 +70,7 @@ struct ProbeContext<'a, 'tcx> {
7070
impl_dups: FxHashSet<DefId>,
7171

7272
/// When probing for names, include names that are close to the
73-
/// requested name (by Levenshtein distance)
73+
/// requested name (by edit distance)
7474
allow_similar_names: bool,
7575

7676
/// Some(candidate) if there is a private candidate
@@ -1794,7 +1794,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
17941794

17951795
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
17961796
/// candidate method where the method name may have been misspelled. Similarly to other
1797-
/// Levenshtein based suggestions, we provide at most one such suggestion.
1797+
/// edit distance based suggestions, we provide at most one such suggestion.
17981798
fn probe_for_similar_candidate(&mut self) -> Result<Option<ty::AssocItem>, MethodError<'tcx>> {
17991799
debug!("probing for method names similar to {:?}", self.method_name);
18001800

@@ -2052,8 +2052,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
20522052
if self.matches_by_doc_alias(x.def_id) {
20532053
return true;
20542054
}
2055-
match lev_distance_with_substrings(name.as_str(), x.name.as_str(), max_dist)
2056-
{
2055+
match edit_distance_with_substrings(
2056+
name.as_str(),
2057+
x.name.as_str(),
2058+
max_dist,
2059+
) {
20572060
Some(d) => d > 0,
20582061
None => false,
20592062
}

compiler/rustc_hir_typeck/src/method/suggest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::ty::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitabl
3131
use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef};
3232
use rustc_span::symbol::{kw, sym, Ident};
3333
use rustc_span::Symbol;
34-
use rustc_span::{lev_distance, source_map, ExpnKind, FileName, MacroKind, Span};
34+
use rustc_span::{edit_distance, source_map, ExpnKind, FileName, MacroKind, Span};
3535
use rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedNote;
3636
use rustc_trait_selection::traits::error_reporting::on_unimplemented::TypeErrCtxtExt as _;
3737
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
@@ -1014,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10141014
// that had unsatisfied trait bounds
10151015
if unsatisfied_predicates.is_empty() && rcvr_ty.is_enum() {
10161016
let adt_def = rcvr_ty.ty_adt_def().expect("enum is not an ADT");
1017-
if let Some(suggestion) = lev_distance::find_best_match_for_name(
1017+
if let Some(suggestion) = edit_distance::find_best_match_for_name(
10181018
&adt_def.variants().iter().map(|s| s.name).collect::<Vec<_>>(),
10191019
item_name.name,
10201020
None,

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKi
1414
use rustc_middle::middle::stability::EvalResult;
1515
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitable};
1616
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
17+
use rustc_span::edit_distance::find_best_match_for_name;
1718
use rustc_span::hygiene::DesugaringKind;
18-
use rustc_span::lev_distance::find_best_match_for_name;
1919
use rustc_span::source_map::{Span, Spanned};
2020
use rustc_span::symbol::{kw, sym, Ident};
2121
use rustc_span::{BytePos, DUMMY_SP};

compiler/rustc_interface/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use rustc_session::filesearch::sysroot_candidates;
1414
use rustc_session::lint::{self, BuiltinLintDiagnostics, LintBuffer};
1515
use rustc_session::parse::CrateConfig;
1616
use rustc_session::{early_error, filesearch, output, Session};
17+
use rustc_span::edit_distance::find_best_match_for_name;
1718
use rustc_span::edition::Edition;
18-
use rustc_span::lev_distance::find_best_match_for_name;
1919
use rustc_span::source_map::FileLoader;
2020
use rustc_span::symbol::{sym, Symbol};
2121
use session::CompilerIO;

compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use rustc_middle::ty::{self, print::Printer, subst::GenericArg, RegisteredTools,
3939
use rustc_session::lint::{BuiltinLintDiagnostics, LintExpectationId};
4040
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
4141
use rustc_session::Session;
42-
use rustc_span::lev_distance::find_best_match_for_name;
42+
use rustc_span::edit_distance::find_best_match_for_name;
4343
use rustc_span::symbol::{sym, Ident, Symbol};
4444
use rustc_span::{BytePos, Span};
4545
use rustc_target::abi;

compiler/rustc_parse/src/parser/item.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use rustc_errors::{
1919
struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult,
2020
StashKey,
2121
};
22+
use rustc_span::edit_distance::edit_distance;
2223
use rustc_span::edition::Edition;
23-
use rustc_span::lev_distance::lev_distance;
2424
use rustc_span::source_map::{self, Span};
2525
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2626
use rustc_span::DUMMY_SP;
@@ -459,7 +459,8 @@ impl<'a> Parser<'a> {
459459
// Maybe the user misspelled `macro_rules` (issue #91227)
460460
if self.token.is_ident()
461461
&& path.segments.len() == 1
462-
&& lev_distance("macro_rules", &path.segments[0].ident.to_string(), 3).is_some()
462+
&& edit_distance("macro_rules", &path.segments[0].ident.to_string(), 3)
463+
.is_some()
463464
{
464465
err.span_suggestion(
465466
path.span,

compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE;
2121
use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
2222
use rustc_session::lint::BuiltinLintDiagnostics;
2323
use rustc_session::Session;
24+
use rustc_span::edit_distance::find_best_match_for_name;
2425
use rustc_span::edition::Edition;
2526
use rustc_span::hygiene::MacroKind;
26-
use rustc_span::lev_distance::find_best_match_for_name;
2727
use rustc_span::source_map::SourceMap;
2828
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2929
use rustc_span::{BytePos, Span, SyntaxContext};

compiler/rustc_resolve/src/imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use rustc_middle::span_bug;
2121
use rustc_middle::ty;
2222
use rustc_session::lint::builtin::{PUB_USE_OF_PRIVATE_EXTERN_CRATE, UNUSED_IMPORTS};
2323
use rustc_session::lint::BuiltinLintDiagnostics;
24+
use rustc_span::edit_distance::find_best_match_for_name;
2425
use rustc_span::hygiene::LocalExpnId;
25-
use rustc_span::lev_distance::find_best_match_for_name;
2626
use rustc_span::symbol::{kw, Ident, Symbol};
2727
use rustc_span::Span;
2828

compiler/rustc_resolve/src/late/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use rustc_middle::ty::DefIdTree;
2525
use rustc_session::lint;
2626
use rustc_session::parse::feature_err;
2727
use rustc_session::Session;
28+
use rustc_span::edit_distance::find_best_match_for_name;
2829
use rustc_span::edition::Edition;
2930
use rustc_span::hygiene::MacroKind;
30-
use rustc_span::lev_distance::find_best_match_for_name;
3131
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3232
use rustc_span::{BytePos, Span};
3333

@@ -542,7 +542,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
542542
}
543543
}
544544

545-
// Try Levenshtein algorithm.
545+
// Try finding a suitable replacement.
546546
let typo_sugg =
547547
self.lookup_typo_candidate(path, source.namespace(), is_expected).to_opt_suggestion();
548548
if path.len() == 1 && self.self_type_is_available() {
@@ -770,7 +770,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
770770
_ => {}
771771
}
772772

773-
// If the trait has a single item (which wasn't matched by Levenshtein), suggest it
773+
// If the trait has a single item (which wasn't matched by the algorithm), suggest it
774774
let suggestion = self.get_single_associated_item(&path, &source, is_expected);
775775
if !self.r.add_typo_suggestion(err, suggestion, ident_span) {
776776
fallback = !self.let_binding_suggestion(err, ident_span);

compiler/rustc_span/src/lev_distance.rs renamed to compiler/rustc_span/src/edit_distance.rs

+34-30
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
//! Damerau-Levenshtein distances.
1+
//! Edit distances.
22
//!
3-
//! The [Damerau-Levenshtein distance] is a metric for measuring the difference between two strings.
4-
//! This implementation is a restricted version of the algorithm, as it does not permit modifying
5-
//! characters that have already been transposed.
3+
//! The [edit distance] is a metric for measuring the difference between two strings.
64
//!
7-
//! [Damerau-Levenshtein distance]: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
5+
//! [edit distance]: https://en.wikipedia.org/wiki/Edit_distance
6+
7+
// The current implementation is the restricted Damerau-Levenshtein algorithm. It is restricted
8+
// because it does not permit modifying characters that have already been transposed. The specific
9+
// algorithm should not matter to the caller of the methods, which is why it is not noted in the
10+
// documentation.
811

912
use crate::symbol::Symbol;
1013
use std::{cmp, mem};
1114

1215
#[cfg(test)]
1316
mod tests;
1417

15-
/// Finds the restricted Damerau-Levenshtein distance between two strings. Characters that have
16-
/// already been transposed may not be modified.
18+
/// Finds the [edit distance] between two strings.
19+
///
20+
/// Returns `None` if the distance exceeds the limit.
1721
///
18-
/// Returns None if the distance exceeds the limit.
19-
pub fn lev_distance(a: &str, b: &str, limit: usize) -> Option<usize> {
22+
/// [edit distance]: https://en.wikipedia.org/wiki/Edit_distance
23+
pub fn edit_distance(a: &str, b: &str, limit: usize) -> Option<usize> {
2024
let mut a = &a.chars().collect::<Vec<_>>()[..];
2125
let mut b = &b.chars().collect::<Vec<_>>()[..];
2226

@@ -95,29 +99,29 @@ pub fn lev_distance(a: &str, b: &str, limit: usize) -> Option<usize> {
9599
}
96100

97101
/// Provides a word similarity score between two words that accounts for substrings being more
98-
/// meaningful than a typical Levenshtein distance. The lower the score, the closer the match.
99-
/// 0 is an identical match.
102+
/// meaningful than a typical edit distance. The lower the score, the closer the match. 0 is an
103+
/// identical match.
100104
///
101-
/// Uses the Levenshtein distance between the two strings and removes the cost of the length
102-
/// difference. If this is 0 then it is either a substring match or a full word match, in the
103-
/// substring match case we detect this and return `1`. To prevent finding meaningless substrings,
104-
/// eg. "in" in "shrink", we only perform this subtraction of length difference if one of the words
105-
/// is not greater than twice the length of the other. For cases where the words are close in size
106-
/// but not an exact substring then the cost of the length difference is discounted by half.
105+
/// Uses the edit distance between the two strings and removes the cost of the length difference.
106+
/// If this is 0 then it is either a substring match or a full word match, in the substring match
107+
/// case we detect this and return `1`. To prevent finding meaningless substrings, eg. "in" in
108+
/// "shrink", we only perform this subtraction of length difference if one of the words is not
109+
/// greater than twice the length of the other. For cases where the words are close in size but not
110+
/// an exact substring then the cost of the length difference is discounted by half.
107111
///
108112
/// Returns `None` if the distance exceeds the limit.
109-
pub fn lev_distance_with_substrings(a: &str, b: &str, limit: usize) -> Option<usize> {
113+
pub fn edit_distance_with_substrings(a: &str, b: &str, limit: usize) -> Option<usize> {
110114
let n = a.chars().count();
111115
let m = b.chars().count();
112116

113117
// Check one isn't less than half the length of the other. If this is true then there is a
114118
// big difference in length.
115119
let big_len_diff = (n * 2) < m || (m * 2) < n;
116120
let len_diff = if n < m { m - n } else { n - m };
117-
let lev = lev_distance(a, b, limit + len_diff)?;
121+
let distance = edit_distance(a, b, limit + len_diff)?;
118122

119123
// This is the crux, subtracting length difference means exact substring matches will now be 0
120-
let score = lev - len_diff;
124+
let score = distance - len_diff;
121125

122126
// If the score is 0 but the words have different lengths then it's a substring match not a full
123127
// word match
@@ -136,12 +140,12 @@ pub fn lev_distance_with_substrings(a: &str, b: &str, limit: usize) -> Option<us
136140

137141
/// Finds the best match for given word in the given iterator where substrings are meaningful.
138142
///
139-
/// A version of [`find_best_match_for_name`] that uses [`lev_distance_with_substrings`] as the score
140-
/// for word similarity. This takes an optional distance limit which defaults to one-third of the
141-
/// given word.
143+
/// A version of [`find_best_match_for_name`] that uses [`edit_distance_with_substrings`] as the
144+
/// score for word similarity. This takes an optional distance limit which defaults to one-third of
145+
/// the given word.
142146
///
143-
/// Besides the modified Levenshtein, we use case insensitive comparison to improve accuracy
144-
/// on an edge case with a lower(upper)case letters mismatch.
147+
/// We use case insensitive comparison to improve accuracy on an edge case with a lower(upper)case
148+
/// letters mismatch.
145149
pub fn find_best_match_for_name_with_substrings(
146150
candidates: &[Symbol],
147151
lookup: Symbol,
@@ -156,8 +160,8 @@ pub fn find_best_match_for_name_with_substrings(
156160
/// an optional limit for the maximum allowable edit distance, which defaults
157161
/// to one-third of the given word.
158162
///
159-
/// Besides Levenshtein, we use case insensitive comparison to improve accuracy
160-
/// on an edge case with a lower(upper)case letters mismatch.
163+
/// We use case insensitive comparison to improve accuracy on an edge case with a lower(upper)case
164+
/// letters mismatch.
161165
pub fn find_best_match_for_name(
162166
candidates: &[Symbol],
163167
lookup: Symbol,
@@ -178,7 +182,7 @@ fn find_best_match_for_name_impl(
178182

179183
// Priority of matches:
180184
// 1. Exact case insensitive match
181-
// 2. Levenshtein distance match
185+
// 2. Edit distance match
182186
// 3. Sorted word match
183187
if let Some(c) = candidates.iter().find(|c| c.as_str().to_uppercase() == lookup_uppercase) {
184188
return Some(*c);
@@ -188,9 +192,9 @@ fn find_best_match_for_name_impl(
188192
let mut best = None;
189193
for c in candidates {
190194
match if use_substring_score {
191-
lev_distance_with_substrings(lookup, c.as_str(), dist)
195+
edit_distance_with_substrings(lookup, c.as_str(), dist)
192196
} else {
193-
lev_distance(lookup, c.as_str(), dist)
197+
edit_distance(lookup, c.as_str(), dist)
194198
} {
195199
Some(0) => return Some(*c),
196200
Some(d) => {

compiler/rustc_span/src/lev_distance/tests.rs renamed to compiler/rustc_span/src/edit_distance/tests.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
use super::*;
22

33
#[test]
4-
fn test_lev_distance() {
4+
fn test_edit_distance() {
55
// Test bytelength agnosticity
66
for c in (0..char::MAX as u32).filter_map(char::from_u32).map(|i| i.to_string()) {
7-
assert_eq!(lev_distance(&c[..], &c[..], usize::MAX), Some(0));
7+
assert_eq!(edit_distance(&c[..], &c[..], usize::MAX), Some(0));
88
}
99

1010
let a = "\nMäry häd ä little lämb\n\nLittle lämb\n";
1111
let b = "\nMary häd ä little lämb\n\nLittle lämb\n";
1212
let c = "Mary häd ä little lämb\n\nLittle lämb\n";
13-
assert_eq!(lev_distance(a, b, usize::MAX), Some(1));
14-
assert_eq!(lev_distance(b, a, usize::MAX), Some(1));
15-
assert_eq!(lev_distance(a, c, usize::MAX), Some(2));
16-
assert_eq!(lev_distance(c, a, usize::MAX), Some(2));
17-
assert_eq!(lev_distance(b, c, usize::MAX), Some(1));
18-
assert_eq!(lev_distance(c, b, usize::MAX), Some(1));
13+
assert_eq!(edit_distance(a, b, usize::MAX), Some(1));
14+
assert_eq!(edit_distance(b, a, usize::MAX), Some(1));
15+
assert_eq!(edit_distance(a, c, usize::MAX), Some(2));
16+
assert_eq!(edit_distance(c, a, usize::MAX), Some(2));
17+
assert_eq!(edit_distance(b, c, usize::MAX), Some(1));
18+
assert_eq!(edit_distance(c, b, usize::MAX), Some(1));
1919
}
2020

2121
#[test]
22-
fn test_lev_distance_limit() {
23-
assert_eq!(lev_distance("abc", "abcd", 1), Some(1));
24-
assert_eq!(lev_distance("abc", "abcd", 0), None);
25-
assert_eq!(lev_distance("abc", "xyz", 3), Some(3));
26-
assert_eq!(lev_distance("abc", "xyz", 2), None);
22+
fn test_edit_distance_limit() {
23+
assert_eq!(edit_distance("abc", "abcd", 1), Some(1));
24+
assert_eq!(edit_distance("abc", "abcd", 0), None);
25+
assert_eq!(edit_distance("abc", "xyz", 3), Some(3));
26+
assert_eq!(edit_distance("abc", "xyz", 2), None);
2727
}
2828

2929
#[test]
3030
fn test_method_name_similarity_score() {
31-
assert_eq!(lev_distance_with_substrings("empty", "is_empty", 1), Some(1));
32-
assert_eq!(lev_distance_with_substrings("shrunk", "rchunks", 2), None);
33-
assert_eq!(lev_distance_with_substrings("abc", "abcd", 1), Some(1));
34-
assert_eq!(lev_distance_with_substrings("a", "abcd", 1), None);
35-
assert_eq!(lev_distance_with_substrings("edf", "eq", 1), None);
36-
assert_eq!(lev_distance_with_substrings("abc", "xyz", 3), Some(3));
37-
assert_eq!(lev_distance_with_substrings("abcdef", "abcdef", 2), Some(0));
31+
assert_eq!(edit_distance_with_substrings("empty", "is_empty", 1), Some(1));
32+
assert_eq!(edit_distance_with_substrings("shrunk", "rchunks", 2), None);
33+
assert_eq!(edit_distance_with_substrings("abc", "abcd", 1), Some(1));
34+
assert_eq!(edit_distance_with_substrings("a", "abcd", 1), None);
35+
assert_eq!(edit_distance_with_substrings("edf", "eq", 1), None);
36+
assert_eq!(edit_distance_with_substrings("abc", "xyz", 3), Some(3));
37+
assert_eq!(edit_distance_with_substrings("abcdef", "abcdef", 2), Some(0));
3838
}
3939

4040
#[test]

compiler/rustc_span/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use hygiene::{ExpnData, ExpnHash, ExpnId, LocalExpnId, SyntaxContext};
4747
use rustc_data_structures::stable_hasher::HashingControls;
4848
pub mod def_id;
4949
use def_id::{CrateNum, DefId, DefPathHash, LocalDefId, LOCAL_CRATE};
50-
pub mod lev_distance;
50+
pub mod edit_distance;
5151
mod span_encoding;
5252
pub use span_encoding::{Span, DUMMY_SP};
5353

0 commit comments

Comments
 (0)