Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/hir.rs')
-rw-r--r--crates/hir-def/src/hir.rs36
1 files changed, 24 insertions, 12 deletions
diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs
index 7781a8fe54..9e51d0eac9 100644
--- a/crates/hir-def/src/hir.rs
+++ b/crates/hir-def/src/hir.rs
@@ -21,7 +21,7 @@ use std::fmt;
use hir_expand::{MacroDefId, name::Name};
use intern::Symbol;
use la_arena::Idx;
-use rustc_apfloat::ieee::{Half as f16, Quad as f128};
+use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use syntax::ast;
use type_ref::TypeRefId;
@@ -94,19 +94,19 @@ impl FloatTypeWrapper {
Self(sym)
}
- pub fn to_f128(&self) -> f128 {
+ pub fn to_f128(&self) -> Quad {
self.0.as_str().parse().unwrap_or_default()
}
- pub fn to_f64(&self) -> f64 {
+ pub fn to_f64(&self) -> Double {
self.0.as_str().parse().unwrap_or_default()
}
- pub fn to_f32(&self) -> f32 {
+ pub fn to_f32(&self) -> Single {
self.0.as_str().parse().unwrap_or_default()
}
- pub fn to_f16(&self) -> f16 {
+ pub fn to_f16(&self) -> Half {
self.0.as_str().parse().unwrap_or_default()
}
}
@@ -214,11 +214,6 @@ pub enum Expr {
tail: Option<ExprId>,
label: Option<LabelId>,
},
- Async {
- id: Option<BlockId>,
- statements: Box<[Statement]>,
- tail: Option<ExprId>,
- },
Const(ExprId),
// FIXME: Fold this into Block with an unsafe flag?
Unsafe {
@@ -339,7 +334,6 @@ impl Expr {
| Expr::Block { .. }
| Expr::Unsafe { .. }
| Expr::Const(_)
- | Expr::Async { .. }
| Expr::If { .. }
| Expr::Literal(_)
| Expr::Loop { .. }
@@ -534,7 +528,25 @@ pub enum InlineAsmRegOrRegClass {
pub enum ClosureKind {
Closure,
Coroutine(Movability),
- Async,
+ AsyncBlock { source: CoroutineSource },
+ AsyncClosure,
+}
+
+/// In the case of a coroutine created as part of an async/gen construct,
+/// which kind of async/gen construct caused it to be created?
+///
+/// This helps error messages but is also used to drive coercions in
+/// type-checking (see #60424).
+#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
+pub enum CoroutineSource {
+ /// An explicit `async`/`gen` block written by the user.
+ Block,
+
+ /// An explicit `async`/`gen` closure written by the user.
+ Closure,
+
+ /// The `async`/`gen` block generated as the body of an async/gen function.
+ Fn,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]