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> {
21
21
/** An AST node with an associated control-flow graph. */
22
22
class CfgScope = Scope:: CfgScope ;
23
23
24
- CfgScope getCfgScope ( AstNode n ) { result = Scope :: scopeOfAst ( n ) }
24
+ CfgScope getCfgScope ( AstNode n ) { result = n . getEnclosingCallable ( ) }
25
25
26
26
class SuccessorType = Cfg:: SuccessorType ;
27
27
Original file line number Diff line number Diff line change @@ -24,28 +24,3 @@ class CfgScope extends Callable {
24
24
result = this .( ClosureExpr ) .getBody ( )
25
25
}
26
26
}
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 {
421
421
)
422
422
}
423
423
424
- private import codeql.rust.controlflow.internal.Scope
425
-
426
424
/** A variable access. */
427
425
class VariableAccess extends PathExprImpl:: PathExpr instanceof VariableAccessCand {
428
426
private string name ;
@@ -434,7 +432,7 @@ module Impl {
434
432
Variable getVariable ( ) { result = v }
435
433
436
434
/** Holds if this access is a capture. */
437
- predicate isCapture ( ) { scopeOfAst ( this ) != scopeOfAst ( v .getPat ( ) ) }
435
+ predicate isCapture ( ) { this . getEnclosingCallable ( ) != v .getPat ( ) . getEnclosingCallable ( ) }
438
436
439
437
override string toString ( ) { result = name }
440
438
You can’t perform that action at this time.
0 commit comments