MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / possible_moves

Function possible_moves

atomic-audit/src/substantive/rust.rs:517–542  ·  view source on GitHub ↗
(
    statement: Node<'_>,
    guards: &BTreeMap<String, usize>,
    source: &str,
)

Source from the content-addressed store, hash-verified

515}
516
517fn possible_moves(
518 statement: Node<'_>,
519 guards: &BTreeMap<String, usize>,
520 source: &str,
521) -> BTreeSet<String> {
522 let mut moved = BTreeSet::new();
523 let mut stack = vec![statement];
524 while let Some(node) = stack.pop() {
525 if node.kind() == "identifier" && guards.contains_key(tokens::text(node, source)) {
526 if let Some(parent) = node.parent() {
527 let binding = parent.kind() == "let_declaration"
528 && parent
529 .child_by_field_name("pattern")
530 .is_some_and(|pattern| pattern.id() == node.id());
531 let borrowed = parent.kind() == "reference_expression"
532 || (parent.kind() == "unary_expression"
533 && tokens::text(parent, source).trim_start().starts_with('*'));
534 if !binding && !borrowed {
535 moved.insert(tokens::text(node, source).into());
536 }
537 }
538 }
539 stack.extend(code_children(node));
540 }
541 moved
542}

Callers 1

guard_across_awaitFunction · 0.85

Calls 8

code_childrenFunction · 0.85
contains_keyMethod · 0.80
parentMethod · 0.80
extendMethod · 0.80
textFunction · 0.50
kindMethod · 0.45
idMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected