mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Implement async blocks
This commit is contained in:
parent
0275b08d15
commit
251ef93ac3
11 changed files with 248 additions and 55 deletions
|
@ -17,8 +17,8 @@ use crate::{
|
|||
autoderef, method_resolution, op,
|
||||
traits::{FnTrait, InEnvironment},
|
||||
utils::{generics, variant_data, Generics},
|
||||
ApplicationTy, Binders, CallableDefId, InferTy, IntTy, Mutability, Obligation, Rawness, Substs,
|
||||
TraitRef, Ty, TypeCtor,
|
||||
ApplicationTy, Binders, CallableDefId, InferTy, IntTy, Mutability, Obligation, OpaqueTyId,
|
||||
Rawness, Substs, TraitRef, Ty, TypeCtor,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
@ -146,6 +146,13 @@ impl<'a> InferenceContext<'a> {
|
|||
// FIXME should be std::result::Result<{inner}, _>
|
||||
Ty::Unknown
|
||||
}
|
||||
Expr::Async { body } => {
|
||||
// Use the first type parameter as the output type of future.
|
||||
// existenail type AsyncBlockImplTrait<InnerType>: Future<Output = InnerType>
|
||||
let inner_ty = self.infer_expr(*body, &Expectation::none());
|
||||
let opaque_ty_id = OpaqueTyId::AsyncBlockTypeImplTrait(self.owner, *body);
|
||||
Ty::apply_one(TypeCtor::OpaqueType(opaque_ty_id), inner_ty)
|
||||
}
|
||||
Expr::Loop { body, label } => {
|
||||
self.breakables.push(BreakableContext {
|
||||
may_break: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue