@@ -49,20 +49,6 @@ private import codeql.rust.internal.CachedStages
4949private import codeql.rust.frameworks.stdlib.Builtins as Builtins
5050private import codeql.util.Option
5151
52- /** Gets the path of a `Meta` node, regardless of its concrete subtype. */
53- pragma [ nomagic]
54- private Path getMetaPath ( Meta m ) {
55- result = m .( PathMeta ) .getPath ( )
56- or
57- result = m .( KeyValueMeta ) .getPath ( )
58- or
59- result = m .( TokenTreeMeta ) .getPath ( )
60- }
61-
62- /** Gets the expression of a `Meta` node, regardless of its concrete subtype. */
63- pragma [ nomagic]
64- private Expr getMetaExpr ( Meta m ) { result = m .( KeyValueMeta ) .getExpr ( ) }
65-
6652private newtype TNamespace =
6753 TTypeNamespace ( ) or
6854 TValueNamespace ( ) or
@@ -277,7 +263,7 @@ abstract class ItemNode extends Locatable {
277263 pragma [ nomagic]
278264 final Attr getAttr ( string name ) {
279265 result = this .getAnAttr ( ) and
280- getMetaPath ( result .getMeta ( ) ) .( PathExt ) .isUnqualified ( name )
266+ result .getMeta ( ) . getMetaPath ( ) .( PathExt ) .isUnqualified ( name )
281267 }
282268
283269 final predicate hasAttr ( string name ) { exists ( this .getAttr ( name ) ) }
@@ -1394,7 +1380,7 @@ private predicate fileModuleInlineLate(SourceFile f, string name, Folder folder)
13941380 */
13951381private Meta getPathAttrMeta ( Module m ) {
13961382 result = m .getAnAttr ( ) .getMeta ( ) and
1397- getMetaPath ( result ) .getText ( ) = "path"
1383+ result . getMetaPath ( ) .getText ( ) = "path"
13981384}
13991385
14001386/**
@@ -1455,10 +1441,10 @@ private predicate modImportNestedLookup(Module m, ModuleItemNode ancestor, Folde
14551441}
14561442
14571443private predicate pathAttrImport ( Folder f , Module m , string relativePath ) {
1458- exists ( Meta meta |
1444+ exists ( KeyValueMeta meta |
14591445 f = m .getFile ( ) .getParentContainer ( ) and
14601446 meta = getPathAttrMeta ( m ) and
1461- relativePath = getMetaExpr ( meta ) .( LiteralExpr ) .getTextValue ( ) .regexpCapture ( "\"(.+)\"" , 1 )
1447+ relativePath = meta . getExpr ( ) .( LiteralExpr ) .getTextValue ( ) .regexpCapture ( "\"(.+)\"" , 1 )
14621448 )
14631449}
14641450
@@ -1839,7 +1825,7 @@ private module DollarCrateResolution {
18391825 or
18401826 exists ( ItemNode type |
18411827 expansion = type .( TypeItem ) .getDeriveMacroExpansion ( _) and
1842- macroDefPath = getMetaPath ( type .getAttr ( "derive" ) .getMeta ( ) )
1828+ macroDefPath = type .getAttr ( "derive" ) .getMeta ( ) . getMetaPath ( )
18431829 )
18441830 }
18451831
@@ -1998,7 +1984,7 @@ private predicate pathUsesNamespace(PathExt p, Namespace n) {
19981984 (
19991985 p = any ( MacroCall mc ) .getPath ( )
20001986 or
2001- p = getMetaPath ( any ( Meta m ) )
1987+ p = any ( Meta m ) . getMetaPath ( )
20021988 )
20031989}
20041990
0 commit comments