ast: add gens for ty and impl, raw ptr types, make fn return value non-optional

This commit is contained in:
2025-07-18 05:25:35 -04:00
parent 6ba62ac1c4
commit 148ef34a01
19 changed files with 242 additions and 147 deletions

View File

@@ -147,8 +147,8 @@ impl WeightOf for Variant {
impl WeightOf for Impl {
fn weight_of(&self) -> usize {
let Self { target, body } = self;
target.weight_of() + body.weight_of()
let Self { gens, target, body } = self;
gens.weight_of() + target.weight_of() + body.weight_of()
}
}
@@ -184,8 +184,8 @@ impl WeightOf for UseTree {
impl WeightOf for Ty {
fn weight_of(&self) -> usize {
let Self { span, kind } = self;
span.weight_of() + kind.weight_of()
let Self { span, kind, gens } = self;
span.weight_of() + kind.weight_of() + gens.weight_of()
}
}
@@ -198,6 +198,7 @@ impl WeightOf for TyKind {
TyKind::Slice(v) => v.weight_of(),
TyKind::Tuple(v) => v.weight_of(),
TyKind::Ref(v) => v.weight_of(),
TyKind::Ptr(v) => v.weight_of(),
TyKind::Fn(v) => v.weight_of(),
}
}
@@ -231,6 +232,13 @@ impl WeightOf for TyRef {
}
}
impl WeightOf for TyPtr {
fn weight_of(&self) -> usize {
let Self { to } = self;
to.weight_of()
}
}
impl WeightOf for TyFn {
fn weight_of(&self) -> usize {
let Self { args, rety } = self;