1
Fork 0

Account for if (let pat = expr) {}

Partially address #82827.
This commit is contained in:
Esteban Küber 2021-03-06 18:29:41 -08:00
parent 1c77a1fa3c
commit e62a543344
8 changed files with 216 additions and 231 deletions

View file

@ -1139,6 +1139,14 @@ impl Expr {
}
}
pub fn peel_parens(&self) -> &Expr {
let mut expr = self;
while let ExprKind::Paren(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 {