diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-03-06 18:29:41 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-03-07 13:49:36 -0800 |
| commit | e62a54334445cd806bfc7bb9a7a41b63413fbedc (patch) | |
| tree | 1d3eb2c3b93edfb94e1624ed5f75334574d6b697 /compiler/rustc_ast/src | |
| parent | 1c77a1fa3ca574f2a40056f64d498db8efe0d8a8 (diff) | |
| download | rust-e62a54334445cd806bfc7bb9a7a41b63413fbedc.tar.gz rust-e62a54334445cd806bfc7bb9a7a41b63413fbedc.zip | |
Account for `if (let pat = expr) {}`
Partially address #82827.
Diffstat (limited to 'compiler/rustc_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index de44a2031ab..4691451b6a9 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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 { |
