Implement offset_of in hir-def and hir-ty

This commit is contained in:
Lukas Wirth 2023-09-05 12:13:24 +02:00
parent 9b8eb807a3
commit 15048304e3
17 changed files with 120 additions and 193 deletions

View file

@ -281,6 +281,13 @@ pub enum Expr {
Array(Array),
Literal(Literal),
Underscore,
OffsetOf(OffsetOf),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OffsetOf {
pub container: Interned<TypeRef>,
pub fields: Box<[Name]>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -341,7 +348,7 @@ impl Expr {
pub fn walk_child_exprs(&self, mut f: impl FnMut(ExprId)) {
match self {
Expr::Missing => {}
Expr::Path(_) => {}
Expr::Path(_) | Expr::OffsetOf(_) => {}
Expr::If { condition, then_branch, else_branch } => {
f(*condition);
f(*then_branch);