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.rs32
1 files changed, 22 insertions, 10 deletions
diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs
index 9e51d0eac9..6eba859264 100644
--- a/crates/hir-def/src/hir.rs
+++ b/crates/hir-def/src/hir.rs
@@ -259,7 +259,7 @@ pub enum Expr {
expr: Option<ExprId>,
},
RecordLit {
- path: Option<Box<Path>>,
+ path: Path,
fields: Box<[RecordLitField]>,
spread: RecordSpread,
},
@@ -524,12 +524,19 @@ pub enum InlineAsmRegOrRegClass {
RegClass(Symbol),
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum CoroutineKind {
+ Async,
+ Gen,
+ AsyncGen,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ClosureKind {
Closure,
- Coroutine(Movability),
- AsyncBlock { source: CoroutineSource },
- AsyncClosure,
+ OldCoroutine(Movability),
+ Coroutine { kind: CoroutineKind, source: CoroutineSource },
+ CoroutineClosure(CoroutineKind),
}
/// In the case of a coroutine created as part of an async/gen construct,
@@ -557,7 +564,7 @@ pub enum CaptureBy {
Ref,
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Movability {
Static,
Movable,
@@ -666,6 +673,8 @@ pub struct RecordFieldPat {
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Pat {
Missing,
+ /// A rest pattern. Not valid outside special context.
+ Rest,
Wild,
Tuple {
args: Box<[PatId]>,
@@ -673,7 +682,7 @@ pub enum Pat {
},
Or(Box<[PatId]>),
Record {
- path: Option<Box<Path>>,
+ path: Path,
args: Box<[RecordFieldPat]>,
ellipsis: bool,
},
@@ -687,7 +696,6 @@ pub enum Pat {
slice: Option<PatId>,
suffix: Box<[PatId]>,
},
- /// This might refer to a variable if a single segment path (specifically, on destructuring assignment).
Path(Path),
Lit(ExprId),
Bind {
@@ -695,7 +703,7 @@ pub enum Pat {
subpat: Option<PatId>,
},
TupleStruct {
- path: Option<Box<Path>>,
+ path: Path,
args: Box<[PatId]>,
ellipsis: Option<u32>,
},
@@ -706,6 +714,9 @@ pub enum Pat {
Box {
inner: PatId,
},
+ Deref {
+ inner: PatId,
+ },
ConstBlock(ExprId),
/// An expression inside a pattern. That can only occur inside assignments.
///
@@ -722,6 +733,7 @@ impl Pat {
| Pat::ConstBlock(..)
| Pat::Wild
| Pat::Missing
+ | Pat::Rest
| Pat::Expr(_) => {}
Pat::Bind { subpat, .. } => {
subpat.iter().copied().for_each(f);
@@ -737,7 +749,7 @@ impl Pat {
Pat::Record { args, .. } => {
args.iter().map(|f| f.pat).for_each(f);
}
- Pat::Box { inner } => f(*inner),
+ Pat::Box { inner } | Pat::Deref { inner } => f(*inner),
}
}
}