cl-ast: allow TyRef to be mutable

yaml.rs: Print AddrOf and TyRef the same way
This commit is contained in:
2024-04-16 20:35:27 -05:00
parent 75adbd6473
commit 98868d3960
4 changed files with 12 additions and 8 deletions

View File

@@ -299,11 +299,11 @@ mod display {
}
impl Display for TyRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self { count: _, to } = self;
for _ in 0..self.count {
let &Self { count, mutable, ref to } = self;
for _ in 0..count {
f.write_char('&')?;
}
write!(f, "{to}")
write!(f, "{mutable}{to}")
}
}
impl Display for TyFn {
@@ -632,7 +632,7 @@ mod convert {
}
impl From for VariantKind {
u128 => VariantKind::CLike,
Vec<Ty> => VariantKind::Tuple,
Ty => VariantKind::Tuple,
// TODO: enum struct variants
}
impl From for TyKind {

View File

@@ -243,6 +243,7 @@ pub struct TyTuple {
/// A [Ty]pe-reference expression as (number of `&`, [Path])
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TyRef {
pub mutable: Mutability,
pub count: u16,
pub to: Path,
}