File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
rust/ql/lib/codeql/rust/elements/internal Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,17 @@ module Impl {
59
59
)
60
60
}
61
61
62
+ /** Gets the block that encloses this node, if any. */
63
+ cached
64
+ BlockExpr getEnclosingBlock ( ) {
65
+ exists ( AstNode p | p = this .getParentNode ( ) |
66
+ result = p
67
+ or
68
+ not p instanceof BlockExpr and
69
+ result = p .getEnclosingBlock ( )
70
+ )
71
+ }
72
+
62
73
/** Holds if this node is inside a macro expansion. */
63
74
predicate isInMacroExpansion ( ) { MacroCallImpl:: isInMacroExpansion ( _, this ) }
64
75
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ module Impl {
127
127
*/
128
128
Name getName ( ) { variableDecl ( definingNode , result , text ) }
129
129
130
+ /** Gets the block that encloses this variable, if any. */
131
+ cached
132
+ BlockExpr getEnclosingBlock ( ) { result = definingNode .getEnclosingBlock ( ) }
133
+
130
134
/** Gets the `self` parameter that declares this variable, if any. */
131
135
SelfParam getSelfParam ( ) { result .getName ( ) = this .getName ( ) }
132
136
You can’t perform that action at this time.
0 commit comments