Rollup merge of #82854 - estebank:issue-82827, r=oli-obk

Account for `if (let pat = expr) {}`

Fix #82827.
This commit is contained in:
Mara Bos 2021-03-08 20:09:02 +01:00 committed by GitHub
commit 6a55aa1246
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 266 additions and 233 deletions

View file

@ -1129,6 +1129,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 {