-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
scrutinee.rs
44 lines (40 loc) · 1.04 KB
/
scrutinee.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use sway_types::{Ident, Span};
use crate::{
decl_engine::{DeclRefEnum, DeclRefStruct},
language::{ty::*, *},
type_system::*,
};
#[derive(Debug, Clone)]
pub struct TyScrutinee {
pub variant: TyScrutineeVariant,
pub type_id: TypeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum TyScrutineeVariant {
CatchAll,
Literal(Literal),
Variable(Ident),
Constant(Ident, Literal, TyConstantDecl),
StructScrutinee {
struct_ref: DeclRefStruct,
fields: Vec<TyStructScrutineeField>,
instantiation_call_path: CallPath,
},
EnumScrutinee {
enum_ref: DeclRefEnum,
variant: Box<TyEnumVariant>,
/// Should contain a TyDecl to either an enum or a type alias.
call_path_decl: ty::TyDecl,
value: Box<TyScrutinee>,
instantiation_call_path: CallPath,
},
Tuple(Vec<TyScrutinee>),
}
#[derive(Debug, Clone)]
pub struct TyStructScrutineeField {
pub field: Ident,
pub scrutinee: Option<TyScrutinee>,
pub span: Span,
pub field_def_name: Ident,
}