aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_pattern.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-12 21:35:53 +0100
committerAleksey Kladov <[email protected]>2019-09-13 14:24:10 +0100
commit51e2d76b9839410020c75ac02ad602675b0a5aa9 (patch)
tree989afd660d62db28196a8792cec2affb7bfd50a7 /crates/ra_ide_api/src/completion/complete_pattern.rs
parent1adf0519bcc8286c06e12aa7e5b16298addfea4a (diff)
Specify desirable namespace when calling resolve
That way, we are able to get rid of a number of unreachable statements
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_pattern.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_pattern.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs
index fb7f9feb8..c17b5b7ee 100644
--- a/crates/ra_ide_api/src/completion/complete_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_pattern.rs
@@ -7,22 +7,20 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
7 } 7 }
8 // FIXME: ideally, we should look at the type we are matching against and 8 // FIXME: ideally, we should look at the type we are matching against and
9 // suggest variants + auto-imports 9 // suggest variants + auto-imports
10 let names = ctx.analyzer.all_names(ctx.db); 10 ctx.analyzer.process_all_names(ctx.db, &mut |name, res| {
11 for (name, res) in names.into_iter() { 11 let def = match &res {
12 let r = res.as_ref(); 12 hir::ScopeDef::ModuleDef(def) => def,
13 let def = match r.take_types().or_else(|| r.take_values()) { 13 _ => return,
14 Some(hir::Resolution::Def(def)) => def,
15 _ => continue,
16 }; 14 };
17 match def { 15 match def {
18 hir::ModuleDef::Adt(hir::Adt::Enum(..)) 16 hir::ModuleDef::Adt(hir::Adt::Enum(..))
19 | hir::ModuleDef::EnumVariant(..) 17 | hir::ModuleDef::EnumVariant(..)
20 | hir::ModuleDef::Const(..) 18 | hir::ModuleDef::Const(..)
21 | hir::ModuleDef::Module(..) => (), 19 | hir::ModuleDef::Module(..) => (),
22 _ => continue, 20 _ => return,
23 } 21 }
24 acc.add_resolution(ctx, name.to_string(), &res) 22 acc.add_resolution(ctx, name.to_string(), &res)
25 } 23 });
26} 24}
27 25
28#[cfg(test)] 26#[cfg(test)]