remove Cancelable from fn_scopes

This commit is contained in:
Aleksey Kladov 2019-01-15 19:04:49 +03:00
parent 040a622c52
commit 18e9a710cd
8 changed files with 13 additions and 13 deletions

View file

@ -305,13 +305,13 @@ impl Function {
db.body_syntax_mapping(self.def_id) db.body_syntax_mapping(self.def_id)
} }
pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> { pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping {
let scopes = db.fn_scopes(self.def_id)?; let scopes = db.fn_scopes(self.def_id);
let syntax_mapping = db.body_syntax_mapping(self.def_id); let syntax_mapping = db.body_syntax_mapping(self.def_id);
Ok(ScopesWithSyntaxMapping { ScopesWithSyntaxMapping {
scopes, scopes,
syntax_mapping, syntax_mapping,
}) }
} }
pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> { pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> {

View file

@ -32,7 +32,7 @@ pub trait HirDatabase: SyntaxDatabase
use fn crate::macros::expand_macro_invocation; 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; type FnScopesQuery;
use fn query_definitions::fn_scopes; use fn query_definitions::fn_scopes;
} }

View file

@ -18,10 +18,10 @@ use crate::{
nameres::{InputModuleItems, ItemMap, Resolver}, 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 body = db.body_hir(def_id);
let res = FnScopes::new(body); 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> { pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {

View file

@ -1206,7 +1206,7 @@ pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceRe
db.check_canceled(); db.check_canceled();
let function = Function::new(def_id); // TODO: consts also need inference let function = Function::new(def_id); // TODO: consts also need inference
let body = function.body(db); 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 module = function.module(db)?;
let impl_block = function.impl_block(db)?; let impl_block = function.impl_block(db)?;
let mut ctx = InferenceContext::new(db, body, scopes, module, impl_block); let mut ctx = InferenceContext::new(db, body, scopes, module, impl_block);

View file

@ -322,7 +322,7 @@ fn infer(content: &str) -> String {
{ {
let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap();
let inference_result = func.infer(&db).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(); let mut types = Vec::new();
for (pat, ty) in inference_result.type_of_pat.iter() { for (pat, ty) in inference_result.type_of_pat.iter() {
let syntax_ptr = match body_syntax_mapping.pat_syntax(pat) { let syntax_ptr = match body_syntax_mapping.pat_syntax(pat) {

View file

@ -15,7 +15,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
None => return Ok(()), None => return Ok(()),
}; };
if let Some(function) = &ctx.function { if let Some(function) = &ctx.function {
let scopes = function.scopes(ctx.db)?; let scopes = function.scopes(ctx.db);
complete_fn(acc, &scopes, ctx.offset); complete_fn(acc, &scopes, ctx.offset);
} }

View file

@ -50,7 +50,7 @@ pub(crate) fn reference_definition(
if let Some(function) = if let Some(function) =
hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax()) 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 // First try to resolve the symbol locally
if let Some(entry) = scope.resolve_local_name(name_ref) { if let Some(entry) = scope.resolve_local_name(name_ref) {
let nav = NavigationTarget::from_scope_entry(file_id, &entry); let nav = NavigationTarget::from_scope_entry(file_id, &entry);

View file

@ -128,7 +128,7 @@ impl db::RootDatabase {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
ret.extend( ret.extend(
descr descr
.scopes(self)? .scopes(self)
.find_all_refs(binding) .find_all_refs(binding)
.into_iter() .into_iter()
.map(|ref_desc| (position.file_id, ref_desc.range)), .map(|ref_desc| (position.file_id, ref_desc.range)),
@ -156,7 +156,7 @@ impl db::RootDatabase {
position.file_id, position.file_id,
name_ref.syntax(), name_ref.syntax(),
)); ));
let scope = descr.scopes(db)?; let scope = descr.scopes(db);
let resolved = ctry!(scope.resolve_local_name(name_ref)); let resolved = ctry!(scope.resolve_local_name(name_ref));
let resolved = resolved.ptr().resolve(source_file); let resolved = resolved.ptr().resolve(source_file);
let binding = ctry!(find_node_at_offset::<ast::BindPat>( let binding = ctry!(find_node_at_offset::<ast::BindPat>(