about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2022-01-17 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2022-01-26 10:43:14 +0100
commit380d53fb2c2190204b977a86ffc9fe74c083af5c (patch)
tree7022111d9adb9540df420dfcb95983eee10ecc19
parentf93bd000a35bee3ae18225d348d2d16c123aea53 (diff)
downloadrust-380d53fb2c2190204b977a86ffc9fe74c083af5c.tar.gz
rust-380d53fb2c2190204b977a86ffc9fe74c083af5c.zip
Check namespace before computing the Levenshtein distance
-rw-r--r--compiler/rustc_typeck/src/check/method/probe.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs
index 9efaa37633e..d082b4aac48 100644
--- a/compiler/rustc_typeck/src/check/method/probe.rs
+++ b/compiler/rustc_typeck/src/check/method/probe.rs
@@ -1904,8 +1904,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                     .associated_items(def_id)
                     .in_definition_order()
                     .filter(|x| {
+                        if x.kind.namespace() != Namespace::ValueNS {
+                            return false;
+                        }
                         let dist = lev_distance(name.as_str(), x.name.as_str());
-                        x.kind.namespace() == Namespace::ValueNS && dist > 0 && dist <= max_dist
+                        dist > 0 && dist <= max_dist
                     })
                     .copied()
                     .collect()