From 380d53fb2c2190204b977a86ffc9fe74c083af5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Mon, 17 Jan 2022 00:00:00 +0000 Subject: [PATCH] Check namespace before computing the Levenshtein distance --- compiler/rustc_typeck/src/check/method/probe.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 9efaa37633e3..d082b4aac483 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()