Check if an expression contains an `await` node (shallow, not into nested scopes).
(expr: &ast::Expr)
| 319 | |
| 320 | /// Check if an expression contains an `await` node (shallow, not into nested scopes). |
| 321 | fn expr_contains_await(expr: &ast::Expr) -> bool { |
| 322 | use ast::visitor::Visitor; |
| 323 | struct AwaitFinder(bool); |
| 324 | impl ast::visitor::Visitor<'_> for AwaitFinder { |
| 325 | fn visit_expr(&mut self, expr: &ast::Expr) { |
| 326 | if !self.0 { |
| 327 | if matches!(expr, ast::Expr::Await(_)) { |
| 328 | self.0 = true; |
| 329 | } else { |
| 330 | ast::visitor::walk_expr(self, expr); |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | let mut finder = AwaitFinder(false); |
| 336 | finder.visit_expr(expr); |
| 337 | finder.0 |
| 338 | } |
| 339 | |
| 340 | /// PEP 709: Merge symbols from an inlined comprehension into the parent scope. |
| 341 | /// Matches symtable.c inline_comprehension(). |
no test coverage detected