Skip to content

Commit 6506f9c

Browse files
author
Julian Kulesh
committed
Add case insensitive comparison, besides Levenstein
1 parent 1dc0b57 commit 6506f9c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/librustc_resolve/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,6 +3212,18 @@ impl<'a> Resolver<'a> {
32123212
let name = path[path.len() - 1].node.name;
32133213
// Make sure error reporting is deterministic.
32143214
names.sort_by_key(|name| name.as_str());
3215+
3216+
3217+
// Ugly code, just to see if using case insensitive comparison will help
3218+
let exact_match = names.iter().find(|x| x.as_str().to_uppercase() == name.as_str().to_uppercase());
3219+
// do not use Levenstein, just return the value we found (if any)
3220+
if exact_match.is_some() {
3221+
return match exact_match {
3222+
Some(found) => Some(found.clone()),
3223+
_ => None,
3224+
}
3225+
}
3226+
32153227
match find_best_match_for_name(names.iter(), &name.as_str(), None) {
32163228
Some(found) if found != name => Some(found),
32173229
_ => None,

src/test/ui/issue46332.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Original problem is Levenstein distance.
2+
3+
fn TyUint() {
4+
println!("TyUint");
5+
}
6+
7+
fn TyInt() {
8+
println!("TyInt");
9+
}
10+
11+
12+
fn main() {
13+
TyUInt();
14+
}

0 commit comments

Comments
 (0)