Skip to content

Commit b4aa1f2

Browse files
committed
extract helper fn
1 parent af727df commit b4aa1f2

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/librustc_resolve/lib.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,24 +4232,18 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
42324232
}
42334233
}
42344234

4235-
/// When name resolution fails, this method can be used to look up candidate
4236-
/// entities with the expected name. It allows filtering them using the
4237-
/// supplied predicate (which should be used to only accept the types of
4238-
/// definitions expected e.g. traits). The lookup spans across all crates.
4239-
///
4240-
/// NOTE: The method does not look into imports, but this is not a problem,
4241-
/// since we report the definitions (thus, the de-aliased imports).
4242-
fn lookup_import_candidates<FilterFn>(&mut self,
4235+
fn lookup_import_candidates_from_module<FilterFn>(&mut self,
42434236
lookup_name: Name,
42444237
namespace: Namespace,
4238+
start_module: &'a ModuleData<'a>,
42454239
filter_fn: FilterFn)
42464240
-> Vec<ImportSuggestion>
42474241
where FilterFn: Fn(Def) -> bool
42484242
{
42494243
let mut candidates = Vec::new();
42504244
let mut worklist = Vec::new();
42514245
let mut seen_modules = FxHashSet();
4252-
worklist.push((self.graph_root, Vec::new(), false));
4246+
worklist.push((start_module, Vec::new(), false));
42534247

42544248
while let Some((in_module,
42554249
path_segments,
@@ -4318,6 +4312,23 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
43184312
candidates
43194313
}
43204314

4315+
/// When name resolution fails, this method can be used to look up candidate
4316+
/// entities with the expected name. It allows filtering them using the
4317+
/// supplied predicate (which should be used to only accept the types of
4318+
/// definitions expected e.g. traits). The lookup spans across all crates.
4319+
///
4320+
/// NOTE: The method does not look into imports, but this is not a problem,
4321+
/// since we report the definitions (thus, the de-aliased imports).
4322+
fn lookup_import_candidates<FilterFn>(&mut self,
4323+
lookup_name: Name,
4324+
namespace: Namespace,
4325+
filter_fn: FilterFn)
4326+
-> Vec<ImportSuggestion>
4327+
where FilterFn: Fn(Def) -> bool
4328+
{
4329+
self.lookup_import_candidates_from_module(lookup_name, namespace, self.graph_root, filter_fn)
4330+
}
4331+
43214332
fn find_module(&mut self,
43224333
module_def: Def)
43234334
-> Option<(Module<'a>, ImportSuggestion)>

0 commit comments

Comments
 (0)