From 5db5f5cc1dc5dfbded866b59570afc50538b9091 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 12 Jan 2019 21:51:56 +0100 Subject: Small improvements from review comments --- crates/ra_hir/src/db.rs | 2 +- crates/ra_hir/src/impl_block.rs | 8 ++++---- crates/ra_hir/src/ty/method_resolution.rs | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 842f54f11..fd6336dd8 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -104,7 +104,7 @@ pub trait HirDatabase: SyntaxDatabase fn impls_in_crate(krate: Crate) -> Cancelable> { type ImplsInCrateQuery; - use fn crate::ty::method_resolution::impls_in_crate; + use fn crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query; } fn body_hir(def_id: DefId) -> Cancelable> { diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 23c1d98d5..d0b086308 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs @@ -170,10 +170,10 @@ impl ModuleImplBlocks { let (file_id, module_source) = module.definition_source(db)?; let node = match &module_source { ModuleSource::SourceFile(node) => node.syntax(), - ModuleSource::Module(node) => match node.item_list() { - Some(item_list) => item_list.syntax(), - None => return Ok(()), - }, + ModuleSource::Module(node) => node + .item_list() + .expect("inline module should have item list") + .syntax(), }; let source_file_items = db.file_items(file_id.into()); diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index ad80aa8b6..1330d03a8 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs @@ -81,23 +81,23 @@ impl CrateImplBlocks { Ok(()) } -} -pub(crate) fn impls_in_crate( - db: &impl HirDatabase, - krate: Crate, -) -> Cancelable> { - let crate_graph = db.crate_graph(); - let file_id = crate_graph.crate_root(krate.crate_id); - let source_root_id = db.file_source_root(file_id); - let mut crate_impl_blocks = CrateImplBlocks { - source_root_id, - impls: FxHashMap::default(), - }; - if let Some(module) = krate.root_module(db)? { - crate_impl_blocks.collect_recursive(db, module)?; + pub(crate) fn impls_in_crate_query( + db: &impl HirDatabase, + krate: Crate, + ) -> Cancelable> { + let crate_graph = db.crate_graph(); + let file_id = crate_graph.crate_root(krate.crate_id); + let source_root_id = db.file_source_root(file_id); + let mut crate_impl_blocks = CrateImplBlocks { + source_root_id, + impls: FxHashMap::default(), + }; + if let Some(module) = krate.root_module(db)? { + crate_impl_blocks.collect_recursive(db, module)?; + } + Ok(Arc::new(crate_impl_blocks)) } - Ok(Arc::new(crate_impl_blocks)) } fn def_crate(db: &impl HirDatabase, ty: &Ty) -> Cancelable> { -- cgit v1.2.3