MCPcopy Index your code
hub / github.com/RustPython/RustPython / expr_contains_await

Function expr_contains_await

crates/codegen/src/symboltable.rs:321–338  ·  view source on GitHub ↗

Check if an expression contains an `await` node (shallow, not into nested scopes).

(expr: &ast::Expr)

Source from the content-addressed store, hash-verified

319
320/// Check if an expression contains an `await` node (shallow, not into nested scopes).
321fn 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().

Callers 1

scan_comprehensionMethod · 0.85

Calls 2

AwaitFinderClass · 0.85
visit_exprMethod · 0.45

Tested by

no test coverage detected