cl-ast: Fix AddrOf misbehavior
This commit is contained in:
@@ -546,7 +546,6 @@ pub struct ArrayRep {
|
||||
/// An address-of expression: `&` `mut`? [`Expr`]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct AddrOf {
|
||||
pub count: usize,
|
||||
pub mutable: Mutability,
|
||||
pub expr: Box<ExprKind>,
|
||||
}
|
||||
|
||||
@@ -616,11 +616,8 @@ mod display {
|
||||
|
||||
impl Display for AddrOf {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let Self { count, mutable, expr } = self;
|
||||
for _ in 0..*count {
|
||||
f.write_char('&')?;
|
||||
}
|
||||
write!(f, "{mutable}{expr}")
|
||||
let Self { mutable, expr } = self;
|
||||
write!(f, "&{mutable}{expr}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -322,9 +322,8 @@ pub trait Fold {
|
||||
}
|
||||
}
|
||||
fn fold_addrof(&mut self, a: AddrOf) -> AddrOf {
|
||||
let AddrOf { count, mutable, expr } = a;
|
||||
let AddrOf { mutable, expr } = a;
|
||||
AddrOf {
|
||||
count,
|
||||
mutable: self.fold_mutability(mutable),
|
||||
expr: Box::new(self.fold_expr_kind(*expr)),
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ pub trait Visit<'a>: Sized {
|
||||
self.visit_expr_kind(repeat);
|
||||
}
|
||||
fn visit_addrof(&mut self, a: &'a AddrOf) {
|
||||
let AddrOf { count: _, mutable, expr } = a;
|
||||
let AddrOf { mutable, expr } = a;
|
||||
self.visit_mutability(mutable);
|
||||
self.visit_expr_kind(expr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user