-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1647 from dtolnay/classify
Create a module for expr classification functions
- Loading branch information
Showing
4 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::expr::Expr; | ||
|
||
pub(crate) fn requires_terminator(expr: &Expr) -> bool { | ||
// see https://github.com/rust-lang/rust/blob/9a19e7604/compiler/rustc_ast/src/util/classify.rs#L7-L26 | ||
match expr { | ||
Expr::If(_) | ||
| Expr::Match(_) | ||
| Expr::Block(_) | Expr::Unsafe(_) // both under ExprKind::Block in rustc | ||
| Expr::While(_) | ||
| Expr::Loop(_) | ||
| Expr::ForLoop(_) | ||
| Expr::TryBlock(_) | ||
| Expr::Const(_) => false, | ||
Expr::Array(_) | ||
| Expr::Assign(_) | ||
| Expr::Async(_) | ||
| Expr::Await(_) | ||
| Expr::Binary(_) | ||
| Expr::Break(_) | ||
| Expr::Call(_) | ||
| Expr::Cast(_) | ||
| Expr::Closure(_) | ||
| Expr::Continue(_) | ||
| Expr::Field(_) | ||
| Expr::Group(_) | ||
| Expr::Index(_) | ||
| Expr::Infer(_) | ||
| Expr::Let(_) | ||
| Expr::Lit(_) | ||
| Expr::Macro(_) | ||
| Expr::MethodCall(_) | ||
| Expr::Paren(_) | ||
| Expr::Path(_) | ||
| Expr::Range(_) | ||
| Expr::Reference(_) | ||
| Expr::Repeat(_) | ||
| Expr::Return(_) | ||
| Expr::Struct(_) | ||
| Expr::Try(_) | ||
| Expr::Tuple(_) | ||
| Expr::Unary(_) | ||
| Expr::Yield(_) | ||
| Expr::Verbatim(_) => true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters