]> git.lizzy.rs Git - rust.git/commitdiff
remove Cancelable from fn_scopes
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jan 2019 16:04:49 +0000 (19:04 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jan 2019 16:04:49 +0000 (19:04 +0300)
crates/ra_hir/src/code_model_api.rs
crates/ra_hir/src/db.rs
crates/ra_hir/src/query_definitions.rs
crates/ra_hir/src/ty.rs
crates/ra_hir/src/ty/tests.rs
crates/ra_ide_api/src/completion/complete_scope.rs
crates/ra_ide_api/src/goto_definition.rs
crates/ra_ide_api/src/imp.rs

index 87175476b6f86ae0a70a718e7beec0ff3233f739..4d7925ac47bb0f4875fc56c4ad97b527c3aa327f 100644 (file)
@@ -305,13 +305,13 @@ pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Arc<BodySyntaxMappin
         db.body_syntax_mapping(self.def_id)
     }
 
-    pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> {
-        let scopes = db.fn_scopes(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);
-        Ok(ScopesWithSyntaxMapping {
+        ScopesWithSyntaxMapping {
             scopes,
             syntax_mapping,
-        })
+        }
     }
 
     pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> {
index c81b8f5f433500470b646b93f882d510c725724e..d20c03f4347da8c819be26bd989f4cf3dee4ca23 100644 (file)
@@ -32,7 +32,7 @@ fn expand_macro_invocation(invoc: MacroCallId) -> Option<Arc<MacroExpansion>> {
         use fn crate::macros::expand_macro_invocation;
     }
 
-    fn fn_scopes(def_id: DefId) -> Cancelable<Arc<FnScopes>> {
+    fn fn_scopes(def_id: DefId) -> Arc<FnScopes> {
         type FnScopesQuery;
         use fn query_definitions::fn_scopes;
     }
index 31086d1e1836f7e9a144e624a2577e84e3be24a3..8f33ec7073419571d1206f9c5e61c6ebe83e0b57 100644 (file)
     nameres::{InputModuleItems, ItemMap, Resolver},
 };
 
-pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<FnScopes>> {
+pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc<FnScopes> {
     let body = db.body_hir(def_id);
     let res = FnScopes::new(body);
-    Ok(Arc::new(res))
+    Arc::new(res)
 }
 
 pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
index 5196600845aaff20de7302490bd050f66f2d8603..54eece16519883fa197327f176f514f1e4cc7e89 100644 (file)
@@ -1206,7 +1206,7 @@ pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceRe
     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 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);
index b81d91e80e7b746f1dba594dfc037a865176f150..b44ac998769857fea97af8490d33086ce96f011e 100644 (file)
@@ -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).unwrap();
+        let body_syntax_mapping = func.body_syntax_mapping(&db);
         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) {
index f422bb9a70536c470235bc43324e8bbe51dd89b2..fdb64895e61172f283b2b9bfdc6728b87b4adc6f 100644 (file)
@@ -15,7 +15,7 @@ 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);
     }
 
index 46fd6883f22a060c6bc8ebf73b20d41d6c50305e..5d522181b35153e66e9943e0fd13891f87fff245 100644 (file)
@@ -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);
index 3ef11dfa17674cce44a3b6ad3f4f2fd60cdb429d..8b2cd6e27990bda1e06636c6ac35bf6feaee8878 100644 (file)
@@ -128,7 +128,7 @@ pub(crate) fn find_all_refs(
             .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 @@ fn find_binding<'a>(
                 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>(