Support flattening/inlining format_args through & and ().

E.g. format_args!("{}", &(format_args!("abc"))).
This commit is contained in:
Mara Bos 2023-01-13 18:00:56 +01:00
parent 85ef2f0cfe
commit caa6ba9e86
2 changed files with 21 additions and 6 deletions

View file

@ -1184,6 +1184,15 @@ impl Expr {
expr
}
pub fn peel_parens_and_refs(&self) -> &Expr {
let mut expr = self;
while let ExprKind::Paren(inner) | ExprKind::AddrOf(BorrowKind::Ref, _, inner) = &expr.kind
{
expr = inner;
}
expr
}
/// Attempts to reparse as `Ty` (for diagnostic purposes).
pub fn to_ty(&self) -> Option<P<Ty>> {
let kind = match &self.kind {