File tree Expand file tree Collapse file tree 4 files changed +34
-31
lines changed Expand file tree Collapse file tree 4 files changed +34
-31
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ private module CfgInput implements InputSig<Location> {
2121 /** An AST node with an associated control-flow graph. */
2222 class CfgScope = Scope:: CfgScope ;
2323
24- CfgScope getCfgScope ( AstNode n ) { result = Scope :: scopeOfAst ( n ) }
24+ CfgScope getCfgScope ( AstNode n ) { result = n . getEnclosingCallable ( ) }
2525
2626 class SuccessorType = Cfg:: SuccessorType ;
2727
Original file line number Diff line number Diff line change @@ -24,28 +24,3 @@ class CfgScope extends Callable {
2424 result = this .( ClosureExpr ) .getBody ( )
2525 }
2626}
27-
28- /**
29- * Gets the immediate parent of a non-`AstNode` element `e`.
30- *
31- * We restrict `e` to be a non-`AstNode` to skip past non-`AstNode` in
32- * the transitive closure computation in `getParentOfAst`. This is
33- * necessary because the parent of an `AstNode` is not necessarily an `AstNode`.
34- */
35- private Element getParentOfAstStep ( Element e ) {
36- not e instanceof AstNode and
37- result = getImmediateParent ( e )
38- }
39-
40- /** Gets the nearest enclosing parent of `ast` that is an `AstNode`. */
41- private AstNode getParentOfAst ( AstNode ast ) {
42- result = getParentOfAstStep * ( getImmediateParent ( ast ) )
43- }
44-
45- /** Gets the enclosing scope of a node */
46- cached
47- AstNode scopeOfAst ( AstNode n ) {
48- exists ( AstNode p | p = getParentOfAst ( n ) |
49- if p instanceof CfgScope then p = result else result = scopeOfAst ( p )
50- )
51- }
Original file line number Diff line number Diff line change @@ -421,8 +421,6 @@ module Impl {
421421 )
422422 }
423423
424- private import codeql.rust.controlflow.internal.Scope
425-
426424 /** A variable access. */
427425 class VariableAccess extends PathExprImpl:: PathExpr instanceof VariableAccessCand {
428426 private string name ;
@@ -434,7 +432,7 @@ module Impl {
434432 Variable getVariable ( ) { result = v }
435433
436434 /** Holds if this access is a capture. */
437- predicate isCapture ( ) { scopeOfAst ( this ) != scopeOfAst ( v .getPat ( ) ) }
435+ predicate isCapture ( ) { this . getEnclosingCallable ( ) != v .getPat ( ) . getEnclosingCallable ( ) }
438436
439437 override string toString ( ) { result = name }
440438
You can’t perform that action at this time.
0 commit comments