about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDouglas Campos <qmx@qmx.me>2018-07-05 13:36:17 +0000
committerDouglas Campos <qmx@qmx.me>2018-08-16 19:19:36 +0000
commitb4aa1f2f90f9cd4e7182f9f695835c19d61704c4 (patch)
tree236a0134d042c7b85956e8115810a35adec88105 /src
parentaf727dfd3f86ab7f907fadccde013bfaa99fc48c (diff)
downloadrust-b4aa1f2f90f9cd4e7182f9f695835c19d61704c4.tar.gz
rust-b4aa1f2f90f9cd4e7182f9f695835c19d61704c4.zip
extract helper fn
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/lib.rs29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 992ea12ffa2..958c496d984 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -4232,16 +4232,10 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
         }
     }
 
-    /// When name resolution fails, this method can be used to look up candidate
-    /// entities with the expected name. It allows filtering them using the
-    /// supplied predicate (which should be used to only accept the types of
-    /// definitions expected e.g. traits). The lookup spans across all crates.
-    ///
-    /// NOTE: The method does not look into imports, but this is not a problem,
-    /// since we report the definitions (thus, the de-aliased imports).
-    fn lookup_import_candidates<FilterFn>(&mut self,
+    fn lookup_import_candidates_from_module<FilterFn>(&mut self,
                                           lookup_name: Name,
                                           namespace: Namespace,
+                                          start_module: &'a ModuleData<'a>,
                                           filter_fn: FilterFn)
                                           -> Vec<ImportSuggestion>
         where FilterFn: Fn(Def) -> bool
@@ -4249,7 +4243,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
         let mut candidates = Vec::new();
         let mut worklist = Vec::new();
         let mut seen_modules = FxHashSet();
-        worklist.push((self.graph_root, Vec::new(), false));
+        worklist.push((start_module, Vec::new(), false));
 
         while let Some((in_module,
                         path_segments,
@@ -4318,6 +4312,23 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
         candidates
     }
 
+    /// When name resolution fails, this method can be used to look up candidate
+    /// entities with the expected name. It allows filtering them using the
+    /// supplied predicate (which should be used to only accept the types of
+    /// definitions expected e.g. traits). The lookup spans across all crates.
+    ///
+    /// NOTE: The method does not look into imports, but this is not a problem,
+    /// since we report the definitions (thus, the de-aliased imports).
+    fn lookup_import_candidates<FilterFn>(&mut self,
+                                          lookup_name: Name,
+                                          namespace: Namespace,
+                                          filter_fn: FilterFn)
+                                          -> Vec<ImportSuggestion>
+        where FilterFn: Fn(Def) -> bool
+    {
+        self.lookup_import_candidates_from_module(lookup_name, namespace, self.graph_root, filter_fn)
+    }
+
     fn find_module(&mut self,
                    module_def: Def)
                    -> Option<(Module<'a>, ImportSuggestion)>