Repository: rust-analyzer/rust-analyzer
Pull request #554 (2019-01-15 16:19:14)

Fail Travis on Prettier formatting issues


Patch:
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index 57d112f746..bcb705c249 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -19,7 +19,7 @@ impl Struct {
     }
 
     pub(crate) fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> {
-        Ok(db.struct_data(self.def_id).variant_data.clone())
+        Ok(db.struct_data(self.def_id)?.variant_data.clone())
     }
 }
 
@@ -37,13 +37,16 @@ impl StructData {
         StructData { name, variant_data }
     }
 
-    pub(crate) fn struct_data_query(db: &impl HirDatabase, def_id: DefId) -> Arc<StructData> {
+    pub(crate) fn struct_data_query(
+        db: &impl HirDatabase,
+        def_id: DefId,
+    ) -> Cancelable<Arc<StructData>> {
         let def_loc = def_id.loc(db);
         assert!(def_loc.kind == DefKind::Struct);
         let syntax = db.file_item(def_loc.source_item_id);
         let struct_def =
             ast::StructDef::cast(&syntax).expect("struct def should point to StructDef node");
-        Arc::new(StructData::new(struct_def))
+        Ok(Arc::new(StructData::new(struct_def)))
     }
 }
 
@@ -81,7 +84,10 @@ impl EnumData {
         EnumData { name, variants }
     }
 
-    pub(crate) fn enum_data_query(db: &impl HirDatabase, def_id: DefId) -> Arc<EnumData> {
+    pub(crate) fn enum_data_query(
+        db: &impl HirDatabase,
+        def_id: DefId,
+    ) -> Cancelable<Arc<EnumData>> {
         let def_loc = def_id.loc(db);
         assert!(def_loc.kind == DefKind::Enum);
         let syntax = db.file_item(def_loc.source_item_id);
@@ -101,7 +107,7 @@ impl EnumData {
         } else {
             Vec::new()
         };
-        Arc::new(EnumData::new(enum_def, variants))
+        Ok(Arc::new(EnumData::new(enum_def, variants)))
     }
 }
 
@@ -127,7 +133,7 @@ impl EnumVariantData {
     pub(crate) fn enum_variant_data_query(
         db: &impl HirDatabase,
         def_id: DefId,
-    ) -> Arc<EnumVariantData> {
+    ) -> Cancelable<Arc<EnumVariantData>> {
         let def_loc = def_id.loc(db);
         assert!(def_loc.kind == DefKind::EnumVariant);
         let syntax = db.file_item(def_loc.source_item_id);
@@ -140,7 +146,10 @@ impl EnumVariantData {
             .expect("enum variant list should have enum ancestor");
         let enum_def_id = get_def_id(db, &def_loc, enum_node, DefKind::Enum);
 
-        Arc::new(EnumVariantData::new(variant_def, Enum::new(enum_def_id)))
+        Ok(Arc::new(EnumVariantData::new(
+            variant_def,
+            Enum::new(enum_def_id),
+        )))
     }
 }
 
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 4d7925ac47..5db53a34fc 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -33,10 +33,10 @@ impl Crate {
     pub fn crate_id(&self) -> CrateId {
         self.crate_id
     }
-    pub fn dependencies(&self, db: &impl HirDatabase) -> Vec<CrateDependency> {
-        self.dependencies_impl(db)
+    pub fn dependencies(&self, db: &impl HirDatabase) -> Cancelable<Vec<CrateDependency>> {
+        Ok(self.dependencies_impl(db))
     }
-    pub fn root_module(&self, db: &impl HirDatabase) -> Option<Module> {
+    pub fn root_module(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
         self.root_module_impl(db)
     }
 }
@@ -78,12 +78,12 @@ pub enum Problem {
 
 impl Module {
     /// Name of this module.
-    pub fn name(&self, db: &impl HirDatabase) -> Option<Name> {
+    pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
         self.name_impl(db)
     }
 
     /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
-    pub fn definition_source(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) {
+    pub fn definition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> {
         self.definition_source_impl(db)
     }
 
@@ -92,19 +92,19 @@ impl Module {
     pub fn declaration_source(
         &self,
         db: &impl HirDatabase,
-    ) -> Option<(FileId, TreeArc<ast::Module>)> {
+    ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
         self.declaration_source_impl(db)
     }
 
     /// Returns the crate this module is part of.
-    pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> {
+    pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
         self.krate_impl(db)
     }
 
     /// Topmost parent of this module. Every module has a `crate_root`, but some
     /// might be missing `krate`. This can happen if a module's file is not included
     /// in the module tree of any target in Cargo.toml.
-    pub fn crate_root(&self, db: &impl HirDatabase) -> Module {
+    pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable<Module> {
         self.crate_root_impl(db)
     }
 
@@ -114,23 +114,23 @@ impl Module {
     }
 
     /// Iterates over all child modules.
-    pub fn children(&self, db: &impl HirDatabase) -> impl Iterator<Item = Module> {
+    pub fn children(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> {
         self.children_impl(db)
     }
 
     /// Finds a parent module.
-    pub fn parent(&self, db: &impl HirDatabase) -> Option<Module> {
+    pub fn parent(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
         self.parent_impl(db)
     }
 
-    pub fn path_to_root(&self, db: &impl HirDatabase) -> Vec<Module> {
+    pub fn path_to_root(&self, db: &impl HirDatabase) -> Cancelable<Vec<Module>> {
         let mut res = vec![self.clone()];
         let mut curr = self.clone();
-        while let Some(next) = curr.parent(db) {
+        while let Some(next) = curr.parent(db)? {
             res.push(next.clone());
             curr = next
         }
-        res
+        Ok(res)
     }
 
     /// Returns a `ModuleScope`: a set of items, visible in this module.
@@ -175,12 +175,13 @@ impl Struct {
         self.def_id
     }
 
-    pub fn name(&self, db: &impl HirDatabase) -> Option<Name> {
-        db.struct_data(self.def_id).name.clone()
+    pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
+        Ok(db.struct_data(self.def_id)?.name.clone())
     }
 
-    pub fn fields(&self, db: &impl HirDatabase) -> Vec<StructField> {
-        db.struct_data(self.def_id)
+    pub fn fields(&self, db: &impl HirDatabase) -> Cancelable<Vec<StructField>> {
+        let res = db
+            .struct_data(self.def_id)?
             .variant_data
             .fields()
             .iter()
@@ -188,11 +189,15 @@ impl Struct {
                 struct_: self.clone(),
                 name: it.name.clone(),
             })
-            .collect()
+            .collect();
+        Ok(res)
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::StructDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(
+        &self,
+        db: &impl HirDatabase,
+    ) -> Cancelable<(HirFileId, TreeArc<ast::StructDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -210,16 +215,16 @@ impl Enum {
         self.def_id
     }
 
-    pub fn name(&self, db: &impl HirDatabase) -> Option<Name> {
-        db.enum_data(self.def_id).name.clone()
+    pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
+        Ok(db.enum_data(self.def_id)?.name.clone())
     }
 
-    pub fn variants(&self, db: &impl HirDatabase) -> Vec<(Name, EnumVariant)> {
-        db.enum_data(self.def_id).variants.clone()
+    pub fn variants(&self, db: &impl HirDatabase) -> Cancelable<Vec<(Name, EnumVariant)>> {
+        Ok(db.enum_data(self.def_id)?.variants.clone())
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::EnumDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::EnumDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -237,20 +242,23 @@ impl EnumVariant {
         self.def_id
     }
 
-    pub fn parent_enum(&self, db: &impl HirDatabase) -> Enum {
-        db.enum_variant_data(self.def_id).parent_enum.clone()
+    pub fn parent_enum(&self, db: &impl HirDatabase) -> Cancelable<Enum> {
+        Ok(db.enum_variant_data(self.def_id)?.parent_enum.clone())
     }
 
-    pub fn name(&self, db: &impl HirDatabase) -> Option<Name> {
-        db.enum_variant_data(self.def_id).name.clone()
+    pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
+        Ok(db.enum_variant_data(self.def_id)?.name.clone())
     }
 
-    pub fn variant_data(&self, db: &impl HirDatabase) -> Arc<VariantData> {
-        db.enum_variant_data(self.def_id).variant_data.clone()
+    pub fn variant_data(&self, db: &impl HirDatabase) -> Cancelable<Arc<VariantData>> {
+        Ok(db.enum_variant_data(self.def_id)?.variant_data.clone())
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::EnumVariant>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(
+        &self,
+        db: &impl HirDatabase,
+    ) -> Cancelable<(HirFileId, TreeArc<ast::EnumVariant>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -297,21 +305,21 @@ impl Function {
         self.def_id
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::FnDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::FnDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 
-    pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Arc<BodySyntaxMapping> {
+    pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Cancelable<Arc<BodySyntaxMapping>> {
         db.body_syntax_mapping(self.def_id)
     }
 
-    pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping {
-        let scopes = db.fn_scopes(self.def_id);
-        let syntax_mapping = db.body_syntax_mapping(self.def_id);
-        ScopesWithSyntaxMapping {
+    pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> {
+        let scopes = db.fn_scopes(self.def_id)?;
+        let syntax_mapping = db.body_syntax_mapping(self.def_id)?;
+        Ok(ScopesWithSyntaxMapping {
             scopes,
             syntax_mapping,
-        }
+        })
     }
 
     pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> {
@@ -333,8 +341,8 @@ impl Const {
         Const { def_id }
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::ConstDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::ConstDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -348,8 +356,11 @@ impl Static {
         Static { def_id }
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::StaticDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(
+        &self,
+        db: &impl HirDatabase,
+    ) -> Cancelable<(HirFileId, TreeArc<ast::StaticDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -363,8 +374,8 @@ impl Trait {
         Trait { def_id }
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::TraitDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TraitDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
 
@@ -378,7 +389,7 @@ impl Type {
         Type { def_id }
     }
 
-    pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::TypeDef>) {
-        def_id_to_ast(db, self.def_id)
+    pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::TypeDef>)> {
+        Ok(def_id_to_ast(db, self.def_id))
     }
 }
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index d34803e325..8d6b7fc19f 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -20,7 +20,7 @@ impl Function {
         Function { def_id }
     }
 
-    pub(crate) fn body(&self, db: &impl HirDatabase) -> Arc<Body> {
+    pub(crate) fn body(&self, db: &impl HirDatabase) -> Cancelable<Arc<Body>> {
         db.body_hir(self.def_id)
     }
 
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs
index 8c6e34873b..712c6c86a5 100644
--- a/crates/ra_hir/src/code_model_impl/krate.rs
+++ b/crates/ra_hir/src/code_model_impl/krate.rs
@@ -1,4 +1,4 @@
-use ra_db::CrateId;
+use ra_db::{CrateId, Cancelable};
 
 use crate::{
     HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId,
@@ -20,7 +20,7 @@ impl Crate {
             })
             .collect()
     }
-    pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> {
+    pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
         let crate_graph = db.crate_graph();
         let file_id = crate_graph.crate_root(self.crate_id);
         let source_root_id = db.file_source_root(file_id);
@@ -31,7 +31,7 @@ impl Crate {
             file_id,
             item_id: None,
         };
-        let module_id = module_tree.find_module_by_source(source)?;
+        let module_id = ctry!(module_tree.find_module_by_source(source));
 
         let def_loc = DefLoc {
             kind: DefKind::Module,
@@ -42,6 +42,6 @@ impl Crate {
         let def_id = def_loc.id(db);
 
         let module = Module::new(def_id);
-        Some(module)
+        Ok(Some(module))
     }
 }
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index 331b0500e5..67808d2827 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -30,14 +30,17 @@ impl Module {
         Module::new(def_id)
     }
 
-    pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Option<Name> {
+    pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
         let loc = self.def_id.loc(db);
         let module_tree = db.module_tree(loc.source_root_id);
-        let link = loc.module_id.parent_link(&module_tree)?;
-        Some(link.name(&module_tree).clone())
+        let link = ctry!(loc.module_id.parent_link(&module_tree));
+        Ok(Some(link.name(&module_tree).clone()))
     }
 
-    pub fn definition_source_impl(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) {
+    pub fn definition_source_impl(
+        &self,
+        db: &impl HirDatabase,
+    ) -> Cancelable<(FileId, ModuleSource)> {
         let loc = self.def_id.loc(db);
         let file_id = loc.source_item_id.file_id.as_original_file();
         let syntax_node = db.file_item(loc.source_item_id);
@@ -47,40 +50,40 @@ impl Module {
             let module = ast::Module::cast(&syntax_node).unwrap();
             ModuleSource::Module(module.to_owned())
         };
-        (file_id, module_source)
+        Ok((file_id, module_source))
     }
 
     pub fn declaration_source_impl(
         &self,
         db: &impl HirDatabase,
-    ) -> Option<(FileId, TreeArc<ast::Module>)> {
+    ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
         let loc = self.def_id.loc(db);
         let module_tree = db.module_tree(loc.source_root_id);
-        let link = loc.module_id.parent_link(&module_tree)?;
+        let link = ctry!(loc.module_id.parent_link(&module_tree));
         let file_id = link
             .owner(&module_tree)
             .source(&module_tree)
             .file_id
             .as_original_file();
         let src = link.source(&module_tree, db);
-        Some((file_id, src))
+        Ok(Some((file_id, src)))
     }
 
-    pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Option<Crate> {
-        let root = self.crate_root(db);
+    pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
+        let root = self.crate_root(db)?;
         let loc = root.def_id.loc(db);
         let file_id = loc.source_item_id.file_id.as_original_file();
 
         let crate_graph = db.crate_graph();
-        let crate_id = crate_graph.crate_id_for_crate_root(file_id)?;
-        Some(Crate::new(crate_id))
+        let crate_id = ctry!(crate_graph.crate_id_for_crate_root(file_id));
+        Ok(Some(Crate::new(crate_id)))
     }
 
-    pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module {
+    pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Cancelable<Module> {
         let loc = self.def_id.loc(db);
         let module_tree = db.module_tree(loc.source_root_id);
         let module_id = loc.module_id.crate_root(&module_tree);
-        Module::from_module_id(db, loc.source_root_id, module_id)
+        Ok(Module::from_module_id(db, loc.source_root_id, module_id))
     }
 
     /// Finds a child module with the specified name.
@@ -92,7 +95,7 @@ impl Module {
     }
 
     /// Iterates over all child modules.
-    pub fn children_impl(&self, db: &impl HirDatabase) -> impl Iterator<Item = Module> {
+    pub fn children_impl(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> {
         // FIXME this should be implementable without collecting into a vec, but
         // it's kind of hard since the iterator needs to keep a reference to the
         // module tree.
@@ -103,14 +106,18 @@ impl Module {
             .children(&module_tree)
             .map(|(_, module_id)| Module::from_module_id(db, loc.source_root_id, module_id))
             .collect::<Vec<_>>();
-        children.into_iter()
+        Ok(children.into_iter())
     }
 
-    pub fn parent_impl(&self, db: &impl HirDatabase) -> Option<Module> {
+    pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
         let loc = self.def_id.loc(db);
         let module_tree = db.module_tree(loc.source_root_id);
-        let parent_id = loc.module_id.parent(&module_tree)?;
-        Some(Module::from_module_id(db, loc.source_root_id, parent_id))
+        let parent_id = ctry!(loc.module_id.parent(&module_tree));
+        Ok(Some(Module::from_module_id(
+            db,
+            loc.source_root_id,
+            parent_id,
+        )))
     }
 
     /// Returns a `ModuleScope`: a set of items, visible in this module.
@@ -128,10 +135,10 @@ impl Module {
     ) -> Cancelable<PerNs<DefId>> {
         let mut curr_per_ns = PerNs::types(
             match path.kind {
-                PathKind::Crate => self.crate_root(db),
+                PathKind::Crate => self.crate_root(db)?,
                 PathKind::Self_ | PathKind::Plain => self.clone(),
                 PathKind::Super => {
-                    if let Some(p) = self.parent(db) {
+                    if let Some(p) = self.parent(db)? {
                         p
                     } else {
                         return Ok(PerNs::none());
@@ -148,13 +155,13 @@ impl Module {
             } else {
                 return Ok(PerNs::none());
             };
-            let module = match curr.resolve(db) {
+            let module = match curr.resolve(db)? {
                 Def::Module(it) => it,
                 Def::Enum(e) => {
                     if segments.len() == idx + 1 {
                         // enum variant
                         let matching_variant =
-                            e.variants(db).into_iter().find(|(n, _variant)| n == name);
+                            e.variants(db)?.into_iter().find(|(n, _variant)| n == name);
 
                         if let Some((_n, variant)) = matching_variant {
                             return Ok(PerNs::both(variant.def_id(), e.def_id()));
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index d20c03f434..3b2498d5a5 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -32,22 +32,22 @@ pub trait HirDatabase: SyntaxDatabase
         use fn crate::macros::expand_macro_invocation;
     }
 
-    fn fn_scopes(def_id: DefId) -> Arc<FnScopes> {
+    fn fn_scopes(def_id: DefId) -> Cancelable<Arc<FnScopes>> {
         type FnScopesQuery;
         use fn query_definitions::fn_scopes;
     }
 
-    fn struct_data(def_id: DefId) -> Arc<StructData> {
+    fn struct_data(def_id: DefId) -> Cancelable<Arc<StructData>> {
         type StructDataQuery;
         use fn crate::adt::StructData::struct_data_query;
     }
 
-    fn enum_data(def_id: DefId) -> Arc<EnumData> {
+    fn enum_data(def_id: DefId) -> Cancelable<Arc<EnumData>> {
         type EnumDataQuery;
         use fn crate::adt::EnumData::enum_data_query;
     }
 
-    fn enum_variant_data(def_id: DefId) -> Arc<EnumVariantData> {
+    fn enum_variant_data(def_id: DefId) -> Cancelable<Arc<EnumVariantData>> {
         type EnumVariantDataQuery;
         use fn crate::adt::EnumVariantData::enum_variant_data_query;
     }
@@ -107,12 +107,12 @@ pub trait HirDatabase: SyntaxDatabase
         use fn crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query;
     }
 
-    fn body_hir(def_id: DefId) -> Arc<crate::expr::Body> {
+    fn body_hir(def_id: DefId) -> Cancelable<Arc<crate::expr::Body>> {
         type BodyHirQuery;
         use fn crate::expr::body_hir;
     }
 
-    fn body_syntax_mapping(def_id: DefId) -> Arc<crate::expr::BodySyntaxMapping> {
+    fn body_syntax_mapping(def_id: DefId) -> Cancelable<Arc<crate::expr::BodySyntaxMapping>> {
         type BodySyntaxMappingQuery;
         use fn crate::expr::body_syntax_mapping;
     }
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 4e8dc0c546..5081466a2f 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -4,8 +4,10 @@ use std::sync::Arc;
 use rustc_hash::FxHashMap;
 
 use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
-use ra_db::LocalSyntaxPtr;
-use ra_syntax::ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor};
+use ra_db::{LocalSyntaxPtr, Cancelable};
+use ra_syntax::{
+    ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}
+};
 
 use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName};
 use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy};
@@ -356,8 +358,8 @@ impl Pat {
 
 // Queries
 
-pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Arc<Body> {
-    Arc::clone(&body_syntax_mapping(db, def_id).body)
+pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<Body>> {
+    Ok(Arc::clone(&body_syntax_mapping(db, def_id)?.body))
 }
 
 struct ExprCollector {
@@ -826,14 +828,17 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping {
     collector.into_body_syntax_mapping(params, body)
 }
 
-pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, def_id: DefId) -> Arc<BodySyntaxMapping> {
-    let def = def_id.resolve(db);
+pub(crate) fn body_syntax_mapping(
+    db: &impl HirDatabase,
+    def_id: DefId,
+) -> Cancelable<Arc<BodySyntaxMapping>> {
+    let def = def_id.resolve(db)?;
 
     let body_syntax_mapping = match def {
-        Def::Function(f) => collect_fn_body_syntax(&f.source(db).1),
+        Def::Function(f) => collect_fn_body_syntax(&f.source(db)?.1),
         // TODO: consts, etc.
         _ => panic!("Trying to get body for item type without body"),
     };
 
-    Arc::new(body_syntax_mapping)
+    Ok(Arc::new(body_syntax_mapping))
 }
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 3cbf8070f9..d7cc9b4ca3 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -159,9 +159,9 @@ impl DefId {
         db.as_ref().id2loc(self)
     }
 
-    pub fn resolve(self, db: &impl HirDatabase) -> Def {
+    pub fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> {
         let loc = self.loc(db);
-        match loc.kind {
+        let res = match loc.kind {
             DefKind::Module => {
                 let module = Module::from_module_id(db, loc.source_root_id, loc.module_id);
                 Def::Module(module)
@@ -195,7 +195,8 @@ impl DefId {
 
             DefKind::StructCtor => Def::Item,
             DefKind::Item => Def::Item,
-        }
+        };
+        Ok(res)
     }
 
     pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc<SyntaxNode>) {
@@ -216,7 +217,7 @@ impl DefId {
 
     /// Returns the containing crate.
     pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
-        Ok(self.module(db)?.krate(db))
+        Ok(self.module(db)?.krate(db)?)
     }
 
     /// Returns the containing impl block, if this is an impl item.
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index ce9087b49b..c9a9fb99ff 100644
--- a/crates/ra_hir/src/impl_block.rs
+++ b/crates/ra_hir/src/impl_block.rs
@@ -167,7 +167,7 @@ impl ModuleImplBlocks {
     }
 
     fn collect(&mut self, db: &impl HirDatabase, module: Module) -> Cancelable<()> {
-        let (file_id, module_source) = module.definition_source(db);
+        let (file_id, module_source) = module.definition_source(db)?;
         let node = match &module_source {
             ModuleSource::SourceFile(node) => node.syntax(),
             ModuleSource::Module(node) => node
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index e51cbe7866..edb3b1e641 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -353,8 +353,8 @@ where
             if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file())
             {
                 let krate = Crate::new(crate_id);
-                for dep in krate.dependencies(self.db) {
-                    if let Some(module) = dep.krate.root_module(self.db) {
+                for dep in krate.dependencies(self.db)? {
+                    if let Some(module) = dep.krate.root_module(self.db)? {
                         let def_id = module.def_id;
                         self.add_module_item(
                             &mut module_items,
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs
index 8f33ec7073..7ff942f6a6 100644
--- a/crates/ra_hir/src/query_definitions.rs
+++ b/crates/ra_hir/src/query_definitions.rs
@@ -18,10 +18,10 @@ use crate::{
     nameres::{InputModuleItems, ItemMap, Resolver},
 };
 
-pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc<FnScopes> {
-    let body = db.body_hir(def_id);
+pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<FnScopes>> {
+    let body = db.body_hir(def_id)?;
     let res = FnScopes::new(body);
-    Arc::new(res)
+    Ok(Arc::new(res))
 }
 
 pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 54eece1651..03787bd89f 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -463,25 +463,25 @@ fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> {
 fn type_for_struct(db: &impl HirDatabase, s: Struct) -> Cancelable<Ty> {
     Ok(Ty::Adt {
         def_id: s.def_id(),
-        name: s.name(db).unwrap_or_else(Name::missing),
+        name: s.name(db)?.unwrap_or_else(Name::missing),
     })
 }
 
 pub(crate) fn type_for_enum(db: &impl HirDatabase, s: Enum) -> Cancelable<Ty> {
     Ok(Ty::Adt {
         def_id: s.def_id(),
-        name: s.name(db).unwrap_or_else(Name::missing),
+        name: s.name(db)?.unwrap_or_else(Name::missing),
     })
 }
 
 pub(crate) fn type_for_enum_variant(db: &impl HirDatabase, ev: EnumVariant) -> Cancelable<Ty> {
-    let enum_parent = ev.parent_enum(db);
+    let enum_parent = ev.parent_enum(db)?;
 
     type_for_enum(db, enum_parent)
 }
 
 pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Ty> {
-    let def = def_id.resolve(db);
+    let def = def_id.resolve(db)?;
     match def {
         Def::Module(..) => {
             log::debug!("trying to get type for module {:?}", def_id);
@@ -507,10 +507,10 @@ pub(super) fn type_for_field(
     def_id: DefId,
     field: Name,
 ) -> Cancelable<Option<Ty>> {
-    let def = def_id.resolve(db);
+    let def = def_id.resolve(db)?;
     let variant_data = match def {
         Def::Struct(s) => s.variant_data(db)?,
-        Def::EnumVariant(ev) => ev.variant_data(db),
+        Def::EnumVariant(ev) => ev.variant_data(db)?,
         // TODO: unions
         _ => panic!(
             "trying to get type for field in non-struct/variant {:?}",
@@ -877,7 +877,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
         } else {
             return Ok((Ty::Unknown, None));
         };
-        Ok(match def_id.resolve(self.db) {
+        Ok(match def_id.resolve(self.db)? {
             Def::Struct(s) => {
                 let ty = type_for_struct(self.db, s)?;
                 (ty, Some(def_id))
@@ -1205,8 +1205,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
 pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
     db.check_canceled();
     let function = Function::new(def_id); // TODO: consts also need inference
-    let body = function.body(db);
-    let scopes = db.fn_scopes(def_id);
+    let body = function.body(db)?;
+    let scopes = db.fn_scopes(def_id)?;
     let module = function.module(db)?;
     let impl_block = function.impl_block(db)?;
     let mut ctx = InferenceContext::new(db, body, scopes, module, impl_block);
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index c7fbcfd06d..7c38393883 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -75,7 +75,7 @@ impl CrateImplBlocks {
             }
         }
 
-        for child in module.children(db) {
+        for child in module.children(db)? {
             self.collect_recursive(db, child)?;
         }
 
@@ -93,7 +93,7 @@ impl CrateImplBlocks {
             source_root_id,
             impls: FxHashMap::default(),
         };
-        if let Some(module) = krate.root_module(db) {
+        if let Some(module) = krate.root_module(db)? {
             crate_impl_blocks.collect_recursive(db, module)?;
         }
         Ok(Arc::new(crate_impl_blocks))
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index cb86ba9a34..37985b3981 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -10,7 +10,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
         _ => return Ok(()),
     };
     let infer_result = function.infer(ctx.db)?;
-    let syntax_mapping = function.body_syntax_mapping(ctx.db);
+    let syntax_mapping = function.body_syntax_mapping(ctx.db)?;
     let expr = match syntax_mapping.node_expr(receiver) {
         Some(expr) => expr,
         None => return Ok(()),
@@ -27,9 +27,9 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
     for receiver in receiver.autoderef(ctx.db) {
         match receiver {
             Ty::Adt { def_id, .. } => {
-                match def_id.resolve(ctx.db) {
+                match def_id.resolve(ctx.db)? {
                     Def::Struct(s) => {
-                        for field in s.fields(ctx.db) {
+                        for field in s.fields(ctx.db)? {
                             CompletionItem::new(
                                 CompletionKind::Reference,
                                 field.name().to_string(),
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 207a509b33..a25ad3f139 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -12,7 +12,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
         Some(it) => it,
         None => return Ok(()),
     };
-    match def_id.resolve(ctx.db) {
+    match def_id.resolve(ctx.db)? {
         hir::Def::Module(module) => {
             let module_scope = module.scope(ctx.db)?;
             for (name, res) in module_scope.entries() {
@@ -22,7 +22,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
             }
         }
         hir::Def::Enum(e) => {
-            e.variants(ctx.db)
+            e.variants(ctx.db)?
                 .into_iter()
                 .for_each(|(variant_name, _variant)| {
                     CompletionItem::new(CompletionKind::Reference, variant_name.to_string())
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index fdb64895e6..770a0fdf27 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -15,12 +15,12 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
         None => return Ok(()),
     };
     if let Some(function) = &ctx.function {
-        let scopes = function.scopes(ctx.db);
+        let scopes = function.scopes(ctx.db)?;
         complete_fn(acc, &scopes, ctx.offset);
     }
 
     let module_scope = module.scope(ctx.db)?;
-    let (file_id, _) = module.definition_source(ctx.db);
+    let (file_id, _) = module.definition_source(ctx.db)?;
     module_scope
         .entries()
         .filter(|(_name, res)| {
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 11d00f78cd..b75d65de3e 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -144,7 +144,7 @@ impl Builder {
         ctx: &CompletionContext,
         resolution: &hir::Resolution,
     ) -> Builder {
-        let resolved = resolution.def_id.map(|d| d.resolve(ctx.db));
+        let resolved = resolution.def_id.and_then(|d| d.resolve(ctx.db).ok());
         let kind = match resolved {
             PerNs {
                 types: Some(hir::Def::Module(..)),
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 5d522181b3..591f36ccec 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -50,7 +50,7 @@ pub(crate) fn reference_definition(
     if let Some(function) =
         hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())
     {
-        let scope = function.scopes(db);
+        let scope = function.scopes(db)?;
         // First try to resolve the symbol locally
         if let Some(entry) = scope.resolve_local_name(name_ref) {
             let nav = NavigationTarget::from_scope_entry(file_id, &entry);
@@ -64,13 +64,13 @@ pub(crate) fn reference_definition(
             .and_then(ast::MethodCallExpr::cast)
         {
             let infer_result = function.infer(db)?;
-            let syntax_mapping = function.body_syntax_mapping(db);
+            let syntax_mapping = function.body_syntax_mapping(db)?;
             let expr = ast::Expr::cast(method_call.syntax()).unwrap();
             if let Some(def_id) = syntax_mapping
                 .node_expr(expr)
                 .and_then(|it| infer_result.method_resolution(it))
             {
-                if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)) {
+                if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)?)? {
                     return Ok(Exact(target));
                 }
             };
@@ -87,7 +87,7 @@ pub(crate) fn reference_definition(
         {
             let resolved = module.resolve_path(db, &path)?;
             if let Some(def_id) = resolved.take_types().or(resolved.take_values()) {
-                if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)) {
+                if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)?)? {
                     return Ok(Exact(target));
                 }
             }
@@ -112,7 +112,7 @@ fn name_definition(
             if let Some(child_module) =
                 hir::source_binder::module_from_declaration(db, file_id, module)
             {
-                let nav = NavigationTarget::from_module(db, child_module);
+                let nav = NavigationTarget::from_module(db, child_module)?;
                 return Ok(Some(vec![nav]));
             }
         }
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 0e9c484217..26f3ced700 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -74,7 +74,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable<Option
         parent_fn
     ));
     let infer = function.infer(db)?;
-    let syntax_mapping = function.body_syntax_mapping(db);
+    let syntax_mapping = function.body_syntax_mapping(db)?;
     if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) {
         Ok(Some(infer[expr].to_string()))
     } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) {
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs
index 8b2cd6e279..76cb312ddd 100644
--- a/crates/ra_ide_api/src/imp.rs
+++ b/crates/ra_ide_api/src/imp.rs
@@ -99,16 +99,16 @@ impl db::RootDatabase {
 
 impl db::RootDatabase {
     /// Returns `Vec` for the same reason as `parent_module`
-    pub(crate) fn crate_for(&self, file_id: FileId) -> Vec<CrateId> {
+    pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
         let module = match source_binder::module_from_file_id(self, file_id) {
             Some(it) => it,
-            None => return Vec::new(),
+            None => return Ok(Vec::new()),
         };
-        let krate = match module.krate(self) {
+        let krate = match module.krate(self)? {
             Some(it) => it,
-            None => return Vec::new(),
+            None => return Ok(Vec::new()),
         };
-        vec![krate.crate_id()]
+        Ok(vec![krate.crate_id()])
     }
     pub(crate) fn find_all_refs(
         &self,
@@ -128,7 +128,7 @@ impl db::RootDatabase {
             .collect::<Vec<_>>();
         ret.extend(
             descr
-                .scopes(self)
+                .scopes(self)?
                 .find_all_refs(binding)
                 .into_iter()
                 .map(|ref_desc| (position.file_id, ref_desc.range)),
@@ -156,7 +156,7 @@ impl db::RootDatabase {
                 position.file_id,
                 name_ref.syntax(),
             ));
-            let scope = descr.scopes(db);
+            let scope = descr.scopes(db)?;
             let resolved = ctry!(scope.resolve_local_name(name_ref));
             let resolved = resolved.ptr().resolve(source_file);
             let binding = ctry!(find_node_at_offset::<ast::BindPat>(
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 0f690fc849..e0b8410d1f 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -419,7 +419,7 @@ impl Analysis {
 
     /// Returns crates this file belongs too.
     pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
-        self.with_db(|db| db.crate_for(file_id))
+        self.with_db(|db| db.crate_for(file_id))?
     }
 
     /// Returns the root file of the given crate.
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs
index 21c15c0c00..230d0f67aa 100644
--- a/crates/ra_ide_api/src/navigation_target.rs
+++ b/crates/ra_ide_api/src/navigation_target.rs
@@ -1,4 +1,4 @@
-use ra_db::FileId;
+use ra_db::{FileId, Cancelable};
 use ra_syntax::{
     SyntaxNode, AstNode, SmolStr, TextRange, ast,
     SyntaxKind::{self, NAME},
@@ -69,72 +69,84 @@ impl NavigationTarget {
         }
     }
 
-    pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
-        let (file_id, source) = module.definition_source(db);
+    pub(crate) fn from_module(
+        db: &RootDatabase,
+        module: hir::Module,
+    ) -> Cancelable<NavigationTarget> {
+        let (file_id, source) = module.definition_source(db)?;
         let name = module
-            .name(db)
+            .name(db)?
             .map(|it| it.to_string().into())
             .unwrap_or_default();
-        match source {
+        let res = match source {
             ModuleSource::SourceFile(node) => {
                 NavigationTarget::from_syntax(file_id, name, None, node.syntax())
             }
             ModuleSource::Module(node) => {
                 NavigationTarget::from_syntax(file_id, name, None, node.syntax())
             }
-        }
+        };
+        Ok(res)
     }
 
-    pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
+    pub(crate) fn from_module_to_decl(
+        db: &RootDatabase,
+        module: hir::Module,
+    ) -> Cancelable<NavigationTarget> {
         let name = module
-            .name(db)
+            .name(db)?
             .map(|it| it.to_string().into())
             .unwrap_or_default();
-        if let Some((file_id, source)) = module.declaration_source(db) {
-            return NavigationTarget::from_syntax(file_id, name, None, source.syntax());
+        if let Some((file_id, source)) = module.declaration_source(db)? {
+            return Ok(NavigationTarget::from_syntax(
+                file_id,
+                name,
+                None,
+                source.syntax(),
+            ));
         }
         NavigationTarget::from_module(db, module)
     }
 
     // TODO once Def::Item is gone, this should be able to always return a NavigationTarget
-    pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Option<NavigationTarget> {
+    pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> {
         let res = match def {
             Def::Struct(s) => {
-                let (file_id, node) = s.source(db);
+                let (file_id, node) = s.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Enum(e) => {
-                let (file_id, node) = e.source(db);
+                let (file_id, node) = e.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::EnumVariant(ev) => {
-                let (file_id, node) = ev.source(db);
+                let (file_id, node) = ev.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Function(f) => {
-                let (file_id, node) = f.source(db);
+                let (file_id, node) = f.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Trait(f) => {
-                let (file_id, node) = f.source(db);
+                let (file_id, node) = f.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Type(f) => {
-                let (file_id, node) = f.source(db);
+                let (file_id, node) = f.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Static(f) => {
-                let (file_id, node) = f.source(db);
+                let (file_id, node) = f.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
             Def::Const(f) => {
-                let (file_id, node) = f.source(db);
+                let (file_id, node) = f.source(db)?;
                 NavigationTarget::from_named(file_id.original_file(db), &*node)
             }
-            Def::Module(m) => NavigationTarget::from_module(db, m),
-            Def::Item => return None,
+            Def::Module(m) => NavigationTarget::from_module(db, m)?,
+            Def::Item => return Ok(None),
         };
-        Some(res)
+        Ok(Some(res))
     }
 
     #[cfg(test)]
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs
index 379b3f3a4f..4513047395 100644
--- a/crates/ra_ide_api/src/parent_module.rs
+++ b/crates/ra_ide_api/src/parent_module.rs
@@ -12,7 +12,7 @@ pub(crate) fn parent_module(
         None => return Ok(Vec::new()),
         Some(it) => it,
     };
-    let nav = NavigationTarget::from_module_to_decl(db, module);
+    let nav = NavigationTarget::from_module_to_decl(db, module)?;
     Ok(vec![nav])
 }
 
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index a3207fdd25..9fa0f79a60 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -80,9 +80,11 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Opt
     // FIXME: thread cancellation instead of `.ok`ing
     let path = module
         .path_to_root(db)
+        .ok()?
         .into_iter()
         .rev()
-        .filter_map(|it| it.name(db))
+        .filter_map(|it| it.name(db).ok())
+        .filter_map(|it| it)
         .join("::");
     Some(Runnable {
         range,
diff --git a/editors/code/package.json b/editors/code/package.json
index 026ef6842e..9433bd3d2c 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -24,7 +24,7 @@
         "fix": "prettier **/*.{json,ts} --write && tslint --project . --fix",
         "lint": "tslint --project .",
         "prettier": "prettier **/*.{json,ts}",
-        "travis": "npm run compile && npm run lint && npm run prettier --list-different"
+        "travis": "npm run compile && npm run lint && npm run prettier -- --list-different"
     },
     "prettier": {
         "tabWidth": 4,
diff --git a/editors/code/src/commands/apply_source_change.ts b/editors/code/src/commands/apply_source_change.ts
index 389061e3cd..dcd074b8bc 100644
--- a/editors/code/src/commands/apply_source_change.ts
+++ b/editors/code/src/commands/apply_source_change.ts
@@ -46,6 +46,9 @@ export async function handle(change: SourceChange) {
             return;
         }
         editor.selection = new vscode.Selection(position, position);
-        editor.revealRange(new vscode.Range(position, position), vscode.TextEditorRevealType.Default);
+        editor.revealRange(
+            new vscode.Range(position, position),
+            vscode.TextEditorRevealType.Default
+        );
     }
 }


Test patch:
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index b44ac99876..b81d91e80e 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -322,7 +322,7 @@ fn infer(content: &str) -> String {
     {
         let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap();
         let inference_result = func.infer(&db).unwrap();
-        let body_syntax_mapping = func.body_syntax_mapping(&db);
+        let body_syntax_mapping = func.body_syntax_mapping(&db).unwrap();
         let mut types = Vec::new();
         for (pat, ty) in inference_result.type_of_pat.iter() {
             let syntax_ptr = match body_syntax_mapping.pat_syntax(pat) {