remove Cancelable from type inference

This commit is contained in:
Aleksey Kladov 2019-01-15 20:54:18 +03:00
parent b871062e32
commit 8ba9c2d4ce
9 changed files with 88 additions and 119 deletions

View file

@ -9,7 +9,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
(Some(function), Some(receiver)) => (function, receiver),
_ => return Ok(()),
};
let infer_result = function.infer(ctx.db)?;
let infer_result = function.infer(ctx.db);
let syntax_mapping = function.body_syntax_mapping(ctx.db);
let expr = match syntax_mapping.node_expr(receiver) {
Some(expr) => expr,
@ -19,7 +19,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
if !ctx.is_call {
complete_fields(acc, ctx, receiver_ty.clone());
}
complete_methods(acc, ctx, receiver_ty)?;
complete_methods(acc, ctx, receiver_ty);
Ok(())
}
@ -55,11 +55,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
}
}
fn complete_methods(
acc: &mut Completions,
ctx: &CompletionContext,
receiver: Ty,
) -> Cancelable<()> {
fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
receiver.iterate_methods(ctx.db, |func| {
let sig = func.signature(ctx.db);
if sig.has_self_param() {
@ -68,9 +64,8 @@ fn complete_methods(
.kind(CompletionItemKind::Method)
.add_to(acc);
}
Ok(None::<()>)
})?;
Ok(())
None::<()>
});
}
#[cfg(test)]

View file

@ -63,7 +63,7 @@ pub(crate) fn reference_definition(
.parent()
.and_then(ast::MethodCallExpr::cast)
{
let infer_result = function.infer(db)?;
let infer_result = function.infer(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

View file

@ -73,7 +73,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable<Option
frange.file_id,
parent_fn
));
let infer = function.infer(db)?;
let infer = function.infer(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()))