diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index d6b6eac35e84..7335c95f7b8c 100644 --- a/rust/extractor/src/generated/.generated.list +++ b/rust/extractor/src/generated/.generated.list @@ -1,2 +1,2 @@ mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 -top.rs 60b0821a7535361e4f0dd280d654c4d8167fca919bda082b17f91ff9878788a5 60b0821a7535361e4f0dd280d654c4d8167fca919bda082b17f91ff9878788a5 +top.rs cdfb9890318d847e6db320abd8b9e9939524ecc47bcdc8491b9c8253bd3178c2 cdfb9890318d847e6db320abd8b9e9939524ecc47bcdc8491b9c8253bd3178c2 diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index 8fa8cac061d0..13a0adecbca4 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -1648,60 +1648,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct Path { - pub id: trap::TrapId, - pub qualifier: Option>, - pub part: Option>, -} - -impl trap::TrapEntry for Path { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("paths", vec![id.into()]); - if let Some(v) = self.qualifier { - out.add_tuple("path_qualifiers", vec![id.into(), v.into()]); - } - if let Some(v) = self.part { - out.add_tuple("path_parts", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for Path { - fn class_name() -> &'static str { "Path" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Path is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Path is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Path is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct PathSegment { pub id: trap::TrapId, @@ -2116,6 +2062,51 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Resolvable { + _unused: () +} + +impl Resolvable { + pub fn emit_resolved_path(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("resolvable_resolved_paths", vec![id.into(), value.into()]); + } + pub fn emit_resolved_crate_origin(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("resolvable_resolved_crate_origins", vec![id.into(), value.into()]); + } +} + +impl trap::TrapClass for Resolvable { + fn class_name() -> &'static str { "Resolvable" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct RetType { pub id: trap::TrapId, @@ -6240,6 +6231,69 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Path { + pub id: trap::TrapId, + pub qualifier: Option>, + pub part: Option>, +} + +impl trap::TrapEntry for Path { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("paths", vec![id.into()]); + if let Some(v) = self.qualifier { + out.add_tuple("path_qualifiers", vec![id.into(), v.into()]); + } + if let Some(v) = self.part { + out.add_tuple("path_parts", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for Path { + fn class_name() -> &'static str { "Path" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Path is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Path is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Path is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Path is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct PathExprBase { _unused: () @@ -9136,6 +9190,15 @@ impl From> for trap::Label { } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct Module { pub id: trap::TrapId, diff --git a/rust/extractor/src/translate/base.rs b/rust/extractor/src/translate/base.rs index 10240632ff51..99b13a2544e5 100644 --- a/rust/extractor/src/translate/base.rs +++ b/rust/extractor/src/translate/base.rs @@ -4,11 +4,12 @@ use crate::generated::{self}; use crate::trap::{DiagnosticSeverity, TrapFile, TrapId}; use crate::trap::{Label, TrapClass}; use codeql_extractor::trap::{self}; +use itertools::Either; use log::Level; use ra_ap_base_db::salsa::InternKey; use ra_ap_base_db::CrateOrigin; use ra_ap_hir::db::ExpandDatabase; -use ra_ap_hir::{Adt, ItemContainer, Module, Semantics, Type}; +use ra_ap_hir::{Adt, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type}; use ra_ap_hir_def::type_ref::Mutability; use ra_ap_hir_def::ModuleId; use ra_ap_hir_expand::ExpandTo; @@ -46,6 +47,12 @@ macro_rules! emit_detached { $self.extract_canonical_origin(&$node, $label.into()); }; // TODO canonical origin of other items + (Path, $self:ident, $node:ident, $label:ident) => { + $self.extract_canonical_destination(&$node, $label); + }; + (MethodCallExpr, $self:ident, $node:ident, $label:ident) => { + $self.extract_method_canonical_destination(&$node, $label); + }; ($($_:tt)*) => {}; } @@ -276,13 +283,13 @@ impl<'a> Translator<'a> { } else { let range = self.text_range_for_node(mcall); self.emit_parse_error(mcall, &SyntaxError::new( - format!( - "macro expansion failed: the macro '{}' expands to {:?} but a {:?} was expected", - mcall.path().map(|p| p.to_string()).unwrap_or_default(), - kind, expand_to - ), - range.unwrap_or_else(|| TextRange::empty(TextSize::from(0))), - )); + format!( + "macro expansion failed: the macro '{}' expands to {:?} but a {:?} was expected", + mcall.path().map(|p| p.to_string()).unwrap_or_default(), + kind, expand_to + ), + range.unwrap_or_else(|| TextRange::empty(TextSize::from(0))), + )); } } else { let range = self.text_range_for_node(mcall); @@ -380,10 +387,34 @@ impl<'a> Translator<'a> { Some(format!("{prefix}::{name}")) } + fn canonical_path_from_module_def(&self, item: ModuleDef) -> Option { + match item { + ModuleDef::Module(it) => self.canonical_path_from_hir(it), + ModuleDef::Function(it) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Enum(it)) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Struct(it)) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Union(it)) => self.canonical_path_from_hir(it), + ModuleDef::Trait(it) => self.canonical_path_from_hir(it), + ModuleDef::Static(_) => None, + ModuleDef::TraitAlias(_) => None, + ModuleDef::TypeAlias(_) => None, + ModuleDef::BuiltinType(_) => None, + ModuleDef::Macro(_) => None, + ModuleDef::Variant(_) => None, + ModuleDef::Const(_) => None, + } + } + fn origin_from_hir(&self, item: impl AddressableHir) -> String { // if we have a Hir entity, it means we have semantics let sema = self.semantics.as_ref().unwrap(); - match item.module(sema).krate().origin(sema.db) { + self.origin_from_crate(item.module(sema).krate()) + } + + fn origin_from_crate(&self, item: Crate) -> String { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + match item.origin(sema.db) { CrateOrigin::Rustc { name } => format!("rustc:{}", name), CrateOrigin::Local { repo, name } => format!( "repo:{}:{}", @@ -397,6 +428,24 @@ impl<'a> Translator<'a> { } } + fn origin_from_module_def(&self, item: ModuleDef) -> Option { + match item { + ModuleDef::Module(it) => Some(self.origin_from_hir(it)), + ModuleDef::Function(it) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Enum(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Struct(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Union(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Trait(it) => Some(self.origin_from_hir(it)), + ModuleDef::Static(_) => None, + ModuleDef::TraitAlias(_) => None, + ModuleDef::TypeAlias(_) => None, + ModuleDef::BuiltinType(_) => None, + ModuleDef::Macro(_) => None, + ModuleDef::Variant(_) => None, + ModuleDef::Const(_) => None, + } + } + pub(crate) fn extract_canonical_origin( &mut self, item: &T, @@ -412,4 +461,50 @@ impl<'a> Translator<'a> { Some(()) })(); } + + pub(crate) fn extract_canonical_destination( + &mut self, + item: &ast::Path, + label: Label, + ) { + (|| { + let sema = self.semantics.as_ref()?; + let resolution = sema.resolve_path(item)?; + let PathResolution::Def(def) = resolution else { + return None; + }; + let origin = self.origin_from_module_def(def)?; + let path = self.canonical_path_from_module_def(def)?; + generated::Resolvable::emit_resolved_crate_origin( + label.into(), + origin, + &mut self.trap.writer, + ); + generated::Resolvable::emit_resolved_path(label.into(), path, &mut self.trap.writer); + Some(()) + })(); + } + + pub(crate) fn extract_method_canonical_destination( + &mut self, + item: &ast::MethodCallExpr, + label: Label, + ) { + (|| { + let sema = self.semantics.as_ref()?; + let resolved = sema.resolve_method_call_fallback(item)?; + let Either::Left(function) = resolved else { + return None; + }; + let origin = self.origin_from_hir(function); + let path = self.canonical_path_from_hir(function)?; + generated::Resolvable::emit_resolved_crate_origin( + label.into(), + origin, + &mut self.trap.writer, + ); + generated::Resolvable::emit_resolved_path(label.into(), path, &mut self.trap.writer); + Some(()) + })(); + } } diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index c42ae033fc96..3e7c702b65c2 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -82,7 +82,7 @@ lib/codeql/rust/elements/MatchArmList.qll e6c48fd7419d88e996b82eb45e4aa2686dfd07 lib/codeql/rust/elements/MatchExpr.qll e9ef1664f020823b6f4bb72d906a9dc0c1ee6432d4a9a13f7dbdbab2b2b1ee4d 38d71e5c487abcb5682293c573343be66e499a6e131bb630604c120d34b7777b lib/codeql/rust/elements/MatchGuard.qll 20754ab2009a7d40b50feece496ff7f38650586d79190ed2a372308594693694 471f8f118317efcf112f4ddfd60125ca2a9d9b3b08e6ee331c430961de7885ff lib/codeql/rust/elements/Meta.qll 9fa3216c86fa55ed5c0c4671708110a6ffc7c0f5d6cda8dda31aaff17f87534d c44ee2754dd71776ffd0a8a7d6c1ae8737c47e998e6bdb8efab5283625807cf4 -lib/codeql/rust/elements/MethodCallExpr.qll 91b411e0fb1a0547dcad8726db460dccc61bed972741598d5cb3740593fe75a7 538d23b6db115bb699389d29a1829bb0449c08424a1fff80377828eb7ceb2563 +lib/codeql/rust/elements/MethodCallExpr.qll 318a46ba61e3e4f0d6ce0e8fa9f79ccbbf2d0f3d0638e6813e1bcb44d624715a 35e03ed4beddd75834fcfc4371bd65eaf099053aa23f7f1d1e6bea2e5825aa6e lib/codeql/rust/elements/Missing.qll 70e6ac9790314752849c9888443c98223ccfc93a193998b7ce350b2c6ebe8ea4 e2f0623511acaa76b091f748d417714137a8b94f1f2bdbbd177f1c682c786dad lib/codeql/rust/elements/Module.qll 0bc85019177709256f8078d9de2a36f62f848d476225bff7bba1e35f249875c7 3fbb70e0c417a644dd0cada2c364c6e6876cfa16f37960e219c87e49c966c94e lib/codeql/rust/elements/Name.qll 3d7ed16c232912e30e5a075f5087ad344a8f76dcc27bc8f71a80c133802b89d7 036dc3ba0c20eb0907ef6dcc532214aa5de8e0de0fa819eca1fce0355b3741a3 @@ -96,7 +96,7 @@ lib/codeql/rust/elements/ParenExpr.qll b635f0e5d300cd9cf3651cfcefd58316c21727295 lib/codeql/rust/elements/ParenPat.qll 40d033de6c85ad042223e0da80479adebab35494396ab652da85d3497e435c5a 8f2febe5d5cefcb076d201ae9607d403b9cfe8169d2f4b71d13868e0af43dc25 lib/codeql/rust/elements/ParenType.qll e1f5695b143c97b98ccdb460a5cf872461cfc13b83a4f005f26c288dc0afae10 1164f8efae7f255925411bddb33939fab0bf1c07955a16fef173b3f4675d09ae lib/codeql/rust/elements/Pat.qll 56211c5cb4709e7c12a2bfd2da5e413a451672d99e23a8386c08ad0b999fd45c b1b1893a13a75c4f0390f7e2a14ee98a46f067cfdc991a8d43adc82497d20aff -lib/codeql/rust/elements/Path.qll 0655adfe84b08c286022a0307511a781bc1bfc943c12bc50600ebffb9d00e4b0 48e55afee9d019b7c62bfb02110c626c570ecbf683258cf23786807966f0b6fc +lib/codeql/rust/elements/Path.qll a0078e6d57dfd5a3b7fb2be4587f55f8e9c65ee042815a8a5b8dbd5273b4076a 0e2d4f8cbd54bd60aa4929b5fd50fe214346b6c0451f73e45143445d15420108 lib/codeql/rust/elements/PathExpr.qll 906df1d80c662b79f1b0b0428c39754b7f8dbcb2234919dd45dd8206a099dd36 1d6015afab6378c926c5838c9a5772cfcfeedf474e2eeca3e46085300ff8d4e1 lib/codeql/rust/elements/PathExprBase.qll bb41092ec690ae926e3233c215dcaf1fd8e161b8a6955151949f492e02dba13a b2257072f8062d31c29c63ee1311b07e0d2eb37075f582cfc76bb542ef773198 lib/codeql/rust/elements/PathPat.qll 6897e69bcb24b56d39ede796cf5767988dcd5741e02333fa8495dd7c814f771a 2a011fb92f17e4b4ff713e6d29f591054dfede22a9aaa006e67fca2c23ab76bf @@ -118,6 +118,7 @@ lib/codeql/rust/elements/RefExpr.qll 91a0d3a86002289dc01ffbe8daca13e34e92e522fbb lib/codeql/rust/elements/RefPat.qll fe076bdccb454111b38f360837d180274ba8a003b4cffe910b5197cd74188089 2604c8bb2b0b47091d5fc4aa276de46fe3561e346bd98f291c3783cef402ba06 lib/codeql/rust/elements/RefType.qll 5dc6012188d5baf36cd7bf0ebc127e28e98862a3f91ea4df2f9b9c962f3a395d ddb06ebe7fb92ad7bbe86cf182270e8494b74edf91b8c841aaf7ba932e5092ac lib/codeql/rust/elements/Rename.qll 55fa06145f2160304caac0a5ce4cf6a496e41adfd66f44b3c0a1d23229ed8ce0 80262f0abf61749cdf0d5701637db359960f5404ad1dbfdd90f5048d2e7c315d +lib/codeql/rust/elements/Resolvable.qll 213c0c157541002ddd61cc76cdc11386819aa59dff0a81780474cccb6b7fb211 cdcf807587f887493888341a1b6f9bed202b80b37cacc77041a256b05ff4d3d1 lib/codeql/rust/elements/RestPat.qll a898a2c396f974a52424efbc8168174416ac6ed30f90d57c81646d2c08455794 db635ead3fa236e45bbd9955c714ff0abb1e57e1ce80d99dc5bb13438475adbf lib/codeql/rust/elements/RetType.qll 36ea39240a56c504d94d5487ea9679563eef3dfe0e23bf42d992d1ab2b883518 2fe5b6f62a634c6aa30a1ecd620f3446c167669cf1285c8ef8dd5e5a6ef5fc71 lib/codeql/rust/elements/ReturnExpr.qll b87187cff55bc33c8c18558c9b88617179183d1341b322c1cab35ba07167bbdb 892f3a9df2187e745c869e67f33c228ee42754bc9e4f8f4c1718472eb8f8c80f @@ -302,15 +303,12 @@ lib/codeql/rust/elements/internal/MatchGuardImpl.qll 77453be572769507e6515e622e6 lib/codeql/rust/elements/internal/MetaConstructor.qll 49ab9aafdcab7785fc5fc9fb8f7c5bb0ae76cf85d0d259c4b3ac4b0eccbbeb56 bc11aef22661077e398b6ca75e3701fd8d0ac94a0e96dc556a6f6de4089d8b8c lib/codeql/rust/elements/internal/MetaImpl.qll c0768335e8b290d33474fac7d12b994c659c3020dcc488314e6b732000837584 ae56040758f407238008a952a29cf336b3e87115b0ab4bfde15b0d0f90d13b88 lib/codeql/rust/elements/internal/MethodCallExprConstructor.qll a1b3c4587f0ae60d206980b1d9e6881d998f29d2b592a73421d6a44124c70c20 8d4eaa3eb54653fac17f7d95e9cc833fe1398d27c02b2388cd9af8724a560ded -lib/codeql/rust/elements/internal/MethodCallExprImpl.qll 85bb150fa738c4206913cf8de15d3b0525e47c1a2cf5de77ac1978194f4b6333 a565680745b8c1374c17c6a0a9b1b4c8058b4f44ea934e36a919d2eb454b289d lib/codeql/rust/elements/internal/MissingConstructor.qll aab0b7f2846f14a5914661a18c7c9eae71b9bde2162a3c5e5e8a8ecafa20e854 8f30b00b5b7918a7500786cc749b61695158b5b3cc8e9f2277b6b6bf0f7850a0 lib/codeql/rust/elements/internal/MissingImpl.qll e81caa383797dfe837cf101fb78d23ab150b32fef7b47ffcc5489bfcd942ac3e 9f3212d45d77e5888e435e7babd55c1e6b42c3c16f5b1f71170ac41f93ee8d0b lib/codeql/rust/elements/internal/ModuleConstructor.qll 31cc83c9d8f25ac07375d19e568f05c068e1f5aa205ff3d9ac31c2510e6f8468 8a70f3f1c18ff87f17e6baf2f05ccaed55c70469288192fc39ef0bb5531b8c0e lib/codeql/rust/elements/internal/ModuleImpl.qll bbff32cadbad54bdb613df8c1ac6da8cd2a80d0576361b843f1529e6c63b1938 7342473026561b8e4923625a083ba52c31d3b6797f9061accd1a712598244410 lib/codeql/rust/elements/internal/NameConstructor.qll a760134c6d4fc785746e1a5dc042a6bf25b8adaa3947a6897c31e50fd91dd5fd 1359f903d57112bcc1f62a609febb288301bfa810e569aa12e1045fd48b5b5c9 -lib/codeql/rust/elements/internal/NameImpl.qll 1cf9c1aa3bfa6c41b9faf737bfb7e756285aea151c487fbc2be852c47b12e55f a8ccffeb36a55bd224aa98745bfdff86c7bb2bd64bf0ace93088b0bc2376a138 lib/codeql/rust/elements/internal/NameRefConstructor.qll 5ff6eacc614fd41f98b54cbb4960a07a1471cf4ea291758d33e54a48fd5d1bc4 c538d65414a24dfdbeb49cfd997588227559ba038f0b55d14bb5d89ed1a016f2 -lib/codeql/rust/elements/internal/NameRefImpl.qll 6700cc8817e53bee89307a278486cd68d68140ef3f5b18a5ab8035d5a1a9c13a d8f0ce1cab406836c645ab51216af00e6e7922e390efe5252b1ed0697f6e1acc lib/codeql/rust/elements/internal/NeverTypeConstructor.qll 6a86bff9d885eddf39a159698710def40d693ccfd0888aefd090a283cb59ae95 9c51d6569f267dde5597067a8470d19d7714304399de4f730e7b85ca21feee20 lib/codeql/rust/elements/internal/NeverTypeImpl.qll 8c7464cb76f9d081dab318d743817d87ecd69672f382d27323ade94c82e8e0f6 55351661214854bbf7faed6c7d17d598459d4e88eaba130a9b3a9f43f6665c37 lib/codeql/rust/elements/internal/OffsetOfExprConstructor.qll 616e146562adb3ac0fba4d6f55dd6ce60518ed377c0856f1f09ba49593e7bfab 80518ce90fc6d08011d6f5fc2a543958067739e1b0a6a5f2ed90fc9b1db078f0 @@ -331,11 +329,9 @@ lib/codeql/rust/elements/internal/PathConstructor.qll 5c6354c28faf9f28f3efee8e19 lib/codeql/rust/elements/internal/PathExprBaseImpl.qll e8b09447ee41b4123f7d94c6b366b2602d8022c9644f1088c670c7794307ab2e 96b9b328771aaf19ba18d0591e85fcc915c0f930b2479b433de3bfdd2ea25249 lib/codeql/rust/elements/internal/PathExprConstructor.qll cf6e0a338a8ed2d1042bdee4c2c49be5827e8c572d8c56e828db265d39e59ae3 36a3d1b7c5cc2cf527616be787b32071b9e2a6613a4f6b3f82e2a3b0e02a516f lib/codeql/rust/elements/internal/PathExprImpl.qll 01ad25aa940bf949056db86220362f0f5a1b03a772af6a2f6aff8854170c5e49 a0f5ff6b04e2f9f22bda78bb2a7352d890899ba16cb7f6a267af902a3650c5ed -lib/codeql/rust/elements/internal/PathImpl.qll 67ccef5792c0d17d800b910cbda3651aaa5c0ba8daa64e1fea23a1518b562193 6a54b958f7206c43565889a273a64b95aa4b915044a986ffffe7cfb4b8f9c3a9 lib/codeql/rust/elements/internal/PathPatConstructor.qll 966c4ea22218ef71e000d7ce8dd5b570c39ad96b9239a3aa8a38292e2a9f36d2 8a1f348e9257ffc6e6bedcd70389b8e7ec2a3ed6e7b3733744ddfab284826e57 lib/codeql/rust/elements/internal/PathPatImpl.qll 6ab5b5959cfd94e74f60422cbdbd764a5f51ff541db428938c36ba3a512d1d6b 47585157460e8384047de307b0b05deaab758d0f07fd0183d874f7bb9d8bda4b lib/codeql/rust/elements/internal/PathSegmentConstructor.qll 2d9639e42035dc7e73b7d6ddb8a977beadc6b4492dee4292b2f85b4409344441 c337fc3b9ef56366428772563e3f25f711474d16e860d3e89c1395a95d9e83e7 -lib/codeql/rust/elements/internal/PathSegmentImpl.qll f8679dc63f0d71d412c3e1ce7666b050e276229a32ebd79769d90e7201fe27c4 d0a73488338a46fbaf626a00360b385d431da86d8fbc8e313414e1e571e5e7a3 lib/codeql/rust/elements/internal/PathTypeConstructor.qll 8949742c7ab7fcfa3a3f6469e87355a6888931ab9ac7a6a07d2bd51e3fdf8283 fb1a402e94e9a1f33b7757338d7e95b107933339615a4fe86de33e41206dd94a lib/codeql/rust/elements/internal/PathTypeImpl.qll 0e3b85df054d1194505796e457ee31a8dac2a2a77284c077cbf1a3bfc179294e c198d4fdf8d1d55f1cf57685a9ad2adf88cc2d6d4f84bafa1e9f039192761399 lib/codeql/rust/elements/internal/PrefixExprConstructor.qll 90c50b0df2d4b4cbf5e2b7d67a9d243a1af9bfff660b7a70d8b9c7859c28bca7 1a1b5ea1f06ed8d41a658c872e8e1915c241a7c799c691df81b9a7b55d8f2f1e @@ -369,6 +365,7 @@ lib/codeql/rust/elements/internal/RefTypeConstructor.qll e1952aa69586b440f878400 lib/codeql/rust/elements/internal/RefTypeImpl.qll f72b760a8a26be21170435da2cb2981638513617fd82742f45f38bc437d9f2c4 f32df49f0b6df85ca5fc4393ccd341ac4304b4947a282ccea48468a26837ef3d lib/codeql/rust/elements/internal/RenameConstructor.qll 65fa2e938978d154701e6cac05b56320b176ee014ef5c20a7b66f3e94fd5c4a7 dfc0ff4606b8e1c14003cc93a0811f4d62ec993b07ff3c1aa0776746577ed103 lib/codeql/rust/elements/internal/RenameImpl.qll 4f5943fbda4ec772203e651ed4b7dd1fb072219ddc0cb208c0a0951af5e72bd6 b9854cdcf02e70ee372330a4e0bfdb03012bc81af79dd12af2a567fd7fc4672b +lib/codeql/rust/elements/internal/ResolvableImpl.qll 7599625454fe81c3490a122943363a2a2522a7877b78a80649e93155a418fedd 442072c3d70bdaababd7de8bc6c9382f4a50bab41d13759dcd1a5bee9ea32e49 lib/codeql/rust/elements/internal/RestPatConstructor.qll 45430925ddf08fba70ede44c7f413ddb41b3113c149b7efc276e0c2bf72507b4 25c678898d72446e7a975bb8b7f2fde51e55b59dbd42f2cca997c833b1a995f1 lib/codeql/rust/elements/internal/RestPatImpl.qll 1b83464367e5fdc28b0b3946ae74c67c64d30b286c39268b4118337539250e51 83a03308cba4cb3344d48f0a0730b1d3e41a73f16f729d39dc2bae6d3f57f232 lib/codeql/rust/elements/internal/RetTypeConstructor.qll a96d803c6e4b40be49cfed0853a3e04ae917c47351e5c880fcab06eddf1af9cc d06a0a191cb14c270c0441ffc3d289263808170dcbe05e01847a35ac9d61dfb3 @@ -539,7 +536,7 @@ lib/codeql/rust/elements/internal/generated/MatchArmList.qll 13362680c037fe83fef lib/codeql/rust/elements/internal/generated/MatchExpr.qll 689d65f690fe05bc262d0a5bfe69bb4f8a142db387c5765fcc4958a9b49989f8 2979cd2017d0538870d17b2b7592c75cc05b706bd36c9de3e5dc38fa3a957e5b lib/codeql/rust/elements/internal/generated/MatchGuard.qll 521a507883963106780f1782084c581fbcf1179863c7c15438c4db79e30e78dd 6226feffaaa8d828a42ece0c693e616cd375672eb987c3b7ff1ca15fa23c116a lib/codeql/rust/elements/internal/generated/Meta.qll 38fca2c9958b4179de311546fe0850319010aca9cd17c97d57e12b521c5d0947 740f99c9d41044ceebfcc9d29baaa22f59c11a40f45502a34aa587d423c018f8 -lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 0966b268c9d71a8007044d608935e0c07d2144eaafef4812ef259d68b00a06f4 b3a5ab7ec79a6cfa55f671288b8c7c946883fd2edc0b3fac68221ab742cf8604 +lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 17bffcc826851a8be32a1900b8fdf777f9bab6aed9f8268d566173c4974c1cf9 134a2860bdf16daafdb3e574c52a69d2598210653db89c2fa062ca25e8f8a649 lib/codeql/rust/elements/internal/generated/Missing.qll 16735d91df04a4e1ae52fae25db5f59a044e540755734bbab46b5fbb0fe6b0bd 28ca4e49fb7e6b4734be2f2f69e7c224c570344cc160ef80c5a5cd413e750dad lib/codeql/rust/elements/internal/generated/Module.qll ebae5d8963c9fd569c0fbad1d7770abd3fd2479437f236cbce0505ba9f9af52c fa3c382115fed18a26f1a755d8749a201b9489f82c09448a88fb8e9e1435fe5f lib/codeql/rust/elements/internal/generated/Name.qll 12aad57744b7d1b04454159536409244c47319aedd580acb58ee93ef9d7f837d 63fc67ccc085db22f82576a53489f15216a7c29d5b941b14a965eab481534e2e @@ -552,9 +549,9 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60 lib/codeql/rust/elements/internal/generated/ParenPat.qll ce24b8f8ecbf0f204af200317405724063887257460c80cf250c39b2fdf37185 e7c87d37e1a0ca7ea03840017e1aa9ddb7f927f1f3b6396c0305b46aeee33db6 lib/codeql/rust/elements/internal/generated/ParenType.qll 9cc954d73f8330dcac7b475f97748b63af5c8766dee9d2f2872c0a7e4c903537 c07534c8a9c683c4a9b11d490095647e420de0a0bfc23273eaf6f31b00244273 -lib/codeql/rust/elements/internal/generated/ParentChild.qll b47dca44e6b74947419128e95d51e994ef28e59b02e81110b6a54eb5d2d46f30 f317538e9919e39dfbf3825a96231f8023568f2d4c61d814c4cebaaf8335f94c +lib/codeql/rust/elements/internal/generated/ParentChild.qll b4d25c43ed44715053255c3c2f8aeb8d21826adc365f24026b2123a4f25cba86 1bc4bb0380a1a8b69055ffeac203b11b2a1b94e5ad88d1b32ff659e8feb26016 lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 -lib/codeql/rust/elements/internal/generated/Path.qll 299abce24762a5ab023f3cf1ab9718b83047e171aed42a8092e7a155914b1657 db1a23d18640c548f08c9f94823838b5e019ac85877c7b15df2d1493d1846572 +lib/codeql/rust/elements/internal/generated/Path.qll f2b1be2f8f44001a6533533c978c4a9a8b7d64838d6f39eef5f0c0e7890611b8 d724a00a38f42429ffa8fb3bffbb5ec69e16a32ceeeb1d1f026fc7adf87424a8 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 lib/codeql/rust/elements/internal/generated/PathExprBase.qll d8218e201b8557fa6d9ca2c30b764e5ad9a04a2e4fb695cc7219bbd7636a6ac2 4ef178426d7095a156f4f8c459b4d16f63abc64336cb50a6cf883a5f7ee09113 lib/codeql/rust/elements/internal/generated/PathPat.qll 98c9938d6a359fd717829b196eb09701d2c798e18c1f43fa7b2a9145afdf6c19 caba2e629cae08682baac90a76ae9a48cda2d7d6f9c23d506fa0ff3f292978a4 @@ -565,7 +562,7 @@ lib/codeql/rust/elements/internal/generated/PtrType.qll 40099c5a4041314b66932dfd lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll efd93730de217cf50dcba5875595263a5eadf9f7e4e1272401342a094d158614 229b251b3d118932e31e78ac4dfb75f48b766f240f20d436062785606d44467b -lib/codeql/rust/elements/internal/generated/Raw.qll 33a346db246b169742c9f3c00b70a631f1305c2273b9abbeee9ef0dbc7b711c8 8eab21f53c60c1df042c6850b5d3474ad6330a3a71166e8e96a2738c7720800c +lib/codeql/rust/elements/internal/generated/Raw.qll 5f83209cda8319c5c6c932631b60c6f2163d2d9cf7be63f63523e2206c01d004 3581039746e86365f37644e86ac2c89d67e2123aa1b039d9e0afdffc7156c96d lib/codeql/rust/elements/internal/generated/RecordExpr.qll eb6cb662e463f9260efae1a6ce874fa781172063b916ef1963f861e9942d308d 1a21cbccc8f3799ff13281e822818ebfb21d81591720a427cac3625512cb9d40 lib/codeql/rust/elements/internal/generated/RecordExprField.qll 7e9f8663d3b74ebbc9603b10c9912f082febba6bd73d344b100bbd3edf837802 fbe6b578e7fd5d5a6f21bbb8c388957ab7210a6a249ec71510a50fb35b319ea1 lib/codeql/rust/elements/internal/generated/RecordExprFieldList.qll 179a97211fe7aa6265085d4d54115cdbc0e1cd7c9b2135591e8f36d6432f13d3 dd44bbbc1e83a1ed3a587afb729d7debf7aeb7b63245de181726af13090e50c0 @@ -578,6 +575,7 @@ lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d lib/codeql/rust/elements/internal/generated/RefPat.qll 5c4d908f851d89f42cf765007c46ac4199200f9b997f368d5b0e2a435efa82cd 42fd637bc98b5a9275386f1c5fb3ae8c4681987289a89b060991416a25131306 lib/codeql/rust/elements/internal/generated/RefType.qll 3603a3e000acc25c5e675bd4bc4a5551b8f63851591e1e9247709e48d1769dc5 91bea4a1d5ef0779d575567253cd007157d3982524e63a7c49c5cae85cb42e5f lib/codeql/rust/elements/internal/generated/Rename.qll d23f999dab4863f9412e142756f956d79867a3579bd077c56993bdde0a5ac2f1 9256c487d3614bf3d22faa294314f490cf312ab526b8de0882e3a4a371434931 +lib/codeql/rust/elements/internal/generated/Resolvable.qll c038fa24b121ee3e7f6060bce639e7483ea1a14bb552e459b6c67663732dfd6c 4025f2ef318793913e6cfc5d8984e538f402bc062865dcb5496563bec64a2ea9 lib/codeql/rust/elements/internal/generated/RestPat.qll b3a4206e68cf67a0310a466721e7c4b3ab855e65490d589d3d856ad333b3d5e8 30b471bec377784f61d73ef93e74fc0dcec7f512ac4b8791d1ca65f2bcea14b8 lib/codeql/rust/elements/internal/generated/RetType.qll a26860cd526b339b9527c089d126c5486e678dd080e88c60ea2fe641e7d661fd a83c1ce32fd043945ad455b892a60c2a9b6a62d7a5aadf121c4b4056d1dfb094 lib/codeql/rust/elements/internal/generated/ReturnExpr.qll c9c05400d326cd8e0da11c3bfa524daa08b2579ecaee80e468076e5dd7911d56 e7694926727220f46a7617b6ca336767450e359c6fa3782e82b1e21d85d37268 @@ -590,7 +588,7 @@ lib/codeql/rust/elements/internal/generated/Static.qll 5fbd6879858cf356d4bdaa6da lib/codeql/rust/elements/internal/generated/Stmt.qll 8473ff532dd5cc9d7decaddcd174b94d610f6ca0aec8e473cc051dad9f3db917 6ef7d2b5237c2dbdcacbf7d8b39109d4dc100229f2b28b5c9e3e4fbf673ba72b lib/codeql/rust/elements/internal/generated/StmtList.qll a667193e32341e17400867c6e359878c4e645ef9f5f4d97676afc0283a33a026 a320ed678ee359302e2fc1b70a9476705cd616fcfa44a499d32f0c7715627f73 lib/codeql/rust/elements/internal/generated/Struct.qll 4d57f0db12dc7ad3e31e750a24172ef1505406b4dab16386af0674bd18bf8f4b 1a73c83df926b996f629316f74c61ea775be04532ab61b56af904223354f033e -lib/codeql/rust/elements/internal/generated/Synth.qll 68126fecadf402b76a30b6e916b1d1c15db1b06c48a401267bf59ac06aaa5ec3 545f3fa49591cf9a11b9bf6d9c860726db31dffe43be8c96ac3f2cac8d47c010 +lib/codeql/rust/elements/internal/generated/Synth.qll 1ba88215c3f0640558a644534b954e4b93acb15a0f51a1e4887230f451718aa9 747eb3bec1c7245e59ea2b500604f5b4e614e4f061473d1a22fa398ee48ba080 lib/codeql/rust/elements/internal/generated/SynthConstructors.qll e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 8577c2b097c1be2f0f7daa5acfcf146f78674a424d99563e08a84dd3e6d91b46 d2f30764e84dbfc0a6a5d3d8a5f935cd432413688cb32da9c94e420fbc10665c @@ -625,7 +623,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll fec8a9211b82a80601bf73 lib/codeql/rust/elements/internal/generated/WildcardPat.qll d74b70b57a0a66bfae017a329352a5b27a6b9e73dd5521d627f680e810c6c59e 4b913b548ba27ff3c82fcd32cf996ff329cb57d176d3bebd0fcef394486ea499 lib/codeql/rust/elements/internal/generated/YeetExpr.qll cac328200872a35337b4bcb15c851afb4743f82c080f9738d295571eb01d7392 94af734eea08129b587fed849b643e7572800e8330c0b57d727d41abda47930b lib/codeql/rust/elements/internal/generated/YieldExpr.qll 37e5f0c1e373a22bbc53d8b7f2c0e1f476e5be5080b8437c5e964f4e83fad79a 4a9a68643401637bf48e5c2b2f74a6bf0ddcb4ff76f6bffb61d436b685621e85 -lib/codeql/rust/elements.qll 6dc44d60d8180da23e7df8815adafa506936c7704723df0592bd1c6c60280abe 6dc44d60d8180da23e7df8815adafa506936c7704723df0592bd1c6c60280abe +lib/codeql/rust/elements.qll 173d5ffbcc2874757033caab37559e84dbcbfed319730f8e41a4e9e10b146835 173d5ffbcc2874757033caab37559e84dbcbfed319730f8e41a4e9e10b146835 test/extractor-tests/generated/Abi/Abi.ql 7f6e7dc4af86eca3ebdc79b10373988cd0871bd78b51997d3cffd969105e5fdd 2f936b6ca005c6157c755121584410c03e4a3949c23bee302fbe05ee10ce118f test/extractor-tests/generated/Abi/Abi_getAbiString.ql a496762fcec5a0887b87023bbf93e9b650f02e20113e25c44d6e4281ae8f5335 14109c7ce11ba25e3cd6e7f1b3fcb4cb00622f2a4eac91bfe43145c5f366bc52 test/extractor-tests/generated/ArgList/ArgList.ql e412927756e72165d0e7c5c9bd3fca89d08197bbf760db8fb7683c64bb2229bc 043dba8506946fbb87753e22c387987d7eded6ddb963aa067f9e60ef9024d684 @@ -888,12 +886,14 @@ test/extractor-tests/generated/Meta/Meta.ql 16f163f00ba2bbaa0a8c6f3f6710c860a8f6 test/extractor-tests/generated/Meta/Meta_getExpr.ql ec9ec61f5be7d65c32775fb5c068daea04f9db7d875293ed99cc1b2481db041f 77a0c52f1cb6ddc8fdb294d637f9eda1b7301ffa3067f0fca6272d894f57d3ee test/extractor-tests/generated/Meta/Meta_getPath.ql aa9d4145a4e613c51b6e4637d57e3b7d0f66e0bb88f4ce959d598870814c06bb 2087e00686d502c0e2e89c88eae0fb354463576a9ae4101320981d3fd79b9078 test/extractor-tests/generated/Meta/Meta_getTokenTree.ql 1051c27ffd0d9a20436d684fde529b9ff55abe30d50e1d575b0318951e75bd34 983975672d928fb907676628384c949731da9807bf0c781bb7ec749d25733d2d -test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 05b938f3fdc53ca16a6403e79d04d44ba2a7ea3d1f643fc3aa82a04593d459b9 099fa93ce75278505b38e8025fcc6961308bb88866ce3e17748a3f958f01262b +test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 0149a2d174c72a530b39a5878e204cb6db7632935a5ceaf20e2b2363b67dfdf6 8284d9133c21136f89a04105c280efe736a782035235c6abc081f3d9a2616447 test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getArgList.ql 180e0b1715f5cd2be0de01bff3d3a45594b495b8250748d40ff7108d6c85923d bdadcdbecca5891287a47b6dd6b2fda62e07457718aef39212503ab63bc17783 test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getAttr.ql 2ce876a04a159efce83b863dffc47fbb714b95daea2b91fa6fbb623d28eed9ec 7bca1cd0e8fbceec0e640afb6800e1780eff5b5b402e71b9b169c0ba26966f96 test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getGenericArgList.ql 655db9a0501b1ef20d604cc4cd9d708371781291443e8dec97b70ec2914601d2 2fc7df0eca22dcef2f9f5c86d37ee43452d372a4c0f9f4da0194828c82ba93e0 test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getNameRef.ql 9a4829a174388e818f0c63ee6b8bdf1b68beaab48f51734ec6cc14635d24001c f57c9cdaf5235aad604f60b53ce92e73946d03a085f95ed051a26683967be4ba test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getReceiver.ql 77407ac956c897ff7234132de1a825f1af5cfd0b6c1fd3a30f64fe08813d56db d80719e02d19c45bd6534c89ec7255652655f5680199854a0a6552b7c7793249 +test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.ql c22504665900715e8a32dd47627111e8cef4ed2646f74a8886dead15fbc85bb5 d92462cf3cb40dcd383bcaffc67d9a43e840494df9d7491339cbd09a0a73427b +test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.ql 9e7bbb7ed60db49b45c3bdf8e01ec58de751889fc394f59ac33f9d6e98200aa1 c055d877e2ff0edc78cce6dd79c78b2881e7940889729cbb5c12e7029ddeb5a3 test/extractor-tests/generated/Module/Module.ql 4bc4d74921a5af94b124a5010cdf6908cdc9ecf26124e354155fba781009071f acca26579b087ce1fc674703c4d95d8d353075d3021c464d2f3fc06891716774 test/extractor-tests/generated/Module/Module_getAttr.ql b97ae3f5175a358bf02c47ec154f7c2a0bd7ca54d0561517008d59344736d5cd f199116633c183826afa9ab8e409c3bf118d8e626647dbc617ae0d40d42e5d25 test/extractor-tests/generated/Module/Module_getCrateOrigin.ql ff479546bf8fe8ef3da60c9c95b7e8e523c415be61839b2fff5f44c146c4e7df b14d3c0577bd6d6e3b6e5f4b93448cdccde424e21327a2e0213715b16c064a52 @@ -926,9 +926,11 @@ test/extractor-tests/generated/ParenPat/ParenPat.ql 565182ccd81a9b420911b488c083 test/extractor-tests/generated/ParenPat/ParenPat_getPat.ql 96f3db0ec4e71fd8706192a16729203448ccc7b0a12ba0abeb0c20757b64fba1 0c66ba801869dc6d48dc0b2bca146757b868e8a88ad9429ba340837750f3a902 test/extractor-tests/generated/ParenType/ParenType.ql 81c8ad667397ce36157941abd9b879e9305a440018853af4528eb737ae4d2935 3ef3b86203b0143be2d7f7f4833f55fd6c226cb9205e3c1940b6c2a1371622f3 test/extractor-tests/generated/ParenType/ParenType_getTy.ql 41dd6605e7b348618156712b559e2f1b6aac02d6c727e8cbf8653530794ec969 30ac6611c730e76cfb75f98efcf817783a50cec0cf3b3197459d7642f74dde85 -test/extractor-tests/generated/Path/Path.ql 2bdcd99b3b5ffc83ac47d8cc27a4561d616bcf06844f0c452c699cd10ee640ca 5a7d7ffb8b0c04d6a8cbb2a953761df8561b796c4372bef1bd55c359b2f19911 +test/extractor-tests/generated/Path/Path.ql f17c1c4d23c0d5e9776cee84444f6ee7445de88afbc1f26c34b96e13ab618158 89499cb0f63b3634d6b5e2b8c4a13bd4401ce82e54af0ab46e41a34b0288eeb9 test/extractor-tests/generated/Path/Path_getPart.ql 8aa45a0b58203ef1177166efbe1c2851faf4b4c9a453c83137f0c9298badcdbf b82d490d9b3a8237487cd5da8b3b6fc4aa477977b332a5c6539b3cd4e6d5b45b test/extractor-tests/generated/Path/Path_getQualifier.ql 9af95e22cdf3a65da6a41d93136aef4523db5ce81d38f6ed4bc613f1c68784d0 3102d9241a417a92c97a53ac56a7a8683463f1adc7a593cda1382c0d25b3f261 +test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.ql 7c0ff524595514630de4178028260d4832bfc4f57bfddec9f8e72a6c6dbf241c 55e617380476c183ef9259199d2cfd551b07466e94bc452c4723754d0c82691b +test/extractor-tests/generated/Path/Path_getResolvedPath.ql 20c8977781dfe687d5db03290612179cf1360eb47b86ea62d25d1eef62a681e7 c35b76e7d63c05dc80867285bb913042cbe90b45d4d4306df9eac2cba5e8db70 test/extractor-tests/generated/PathExpr/PathExpr.ql b9696cd7ad9f3874e4bc4b1b9c77f42f06ab6c61b77fb641458da63667087b9b db84a7a8dd05e30ff80733af01f08d43ff031bb4b3e3af06332a73ba7e7bbc43 test/extractor-tests/generated/PathExpr/PathExpr_getAttr.ql 2ccac48cd91d86670c1d2742de20344135d424e6f0e3dafcc059555046f92d92 9b7b5f5f9e3674fad9b3a5bcd3cabc0dff32a95640da0fce6f4d0eb931f1757d test/extractor-tests/generated/PathExpr/PathExpr_getPath.ql e7894071313a74166bdd31d7cd974037fcd5a7f0e92d5eec42833266196eb858 46a06e8a1207e7a0fa175cd4b61068e5fd6c43b5575b88986409f0ac2be64c51 diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 2d19334cbc73..3cc5424a8f9a 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -120,6 +120,7 @@ /lib/codeql/rust/elements/RefPat.qll linguist-generated /lib/codeql/rust/elements/RefType.qll linguist-generated /lib/codeql/rust/elements/Rename.qll linguist-generated +/lib/codeql/rust/elements/Resolvable.qll linguist-generated /lib/codeql/rust/elements/RestPat.qll linguist-generated /lib/codeql/rust/elements/RetType.qll linguist-generated /lib/codeql/rust/elements/ReturnExpr.qll linguist-generated @@ -304,15 +305,12 @@ /lib/codeql/rust/elements/internal/MetaConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/MetaImpl.qll linguist-generated /lib/codeql/rust/elements/internal/MethodCallExprConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll linguist-generated /lib/codeql/rust/elements/internal/MissingConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/MissingImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ModuleConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ModuleImpl.qll linguist-generated /lib/codeql/rust/elements/internal/NameConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/NameImpl.qll linguist-generated /lib/codeql/rust/elements/internal/NameRefConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/NameRefImpl.qll linguist-generated /lib/codeql/rust/elements/internal/NeverTypeConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/NeverTypeImpl.qll linguist-generated /lib/codeql/rust/elements/internal/OffsetOfExprConstructor.qll linguist-generated @@ -333,11 +331,9 @@ /lib/codeql/rust/elements/internal/PathExprBaseImpl.qll linguist-generated /lib/codeql/rust/elements/internal/PathExprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/PathExprImpl.qll linguist-generated -/lib/codeql/rust/elements/internal/PathImpl.qll linguist-generated /lib/codeql/rust/elements/internal/PathPatConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/PathPatImpl.qll linguist-generated /lib/codeql/rust/elements/internal/PathSegmentConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/PathSegmentImpl.qll linguist-generated /lib/codeql/rust/elements/internal/PathTypeConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/PathTypeImpl.qll linguist-generated /lib/codeql/rust/elements/internal/PrefixExprConstructor.qll linguist-generated @@ -371,6 +367,7 @@ /lib/codeql/rust/elements/internal/RefTypeImpl.qll linguist-generated /lib/codeql/rust/elements/internal/RenameConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/RenameImpl.qll linguist-generated +/lib/codeql/rust/elements/internal/ResolvableImpl.qll linguist-generated /lib/codeql/rust/elements/internal/RestPatConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/RestPatImpl.qll linguist-generated /lib/codeql/rust/elements/internal/RetTypeConstructor.qll linguist-generated @@ -580,6 +577,7 @@ /lib/codeql/rust/elements/internal/generated/RefPat.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RefType.qll linguist-generated /lib/codeql/rust/elements/internal/generated/Rename.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/Resolvable.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RestPat.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RetType.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ReturnExpr.qll linguist-generated @@ -896,6 +894,8 @@ /test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getGenericArgList.ql linguist-generated /test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getNameRef.ql linguist-generated /test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getReceiver.ql linguist-generated +/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.ql linguist-generated +/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.ql linguist-generated /test/extractor-tests/generated/Module/Module.ql linguist-generated /test/extractor-tests/generated/Module/Module_getAttr.ql linguist-generated /test/extractor-tests/generated/Module/Module_getCrateOrigin.ql linguist-generated @@ -931,6 +931,8 @@ /test/extractor-tests/generated/Path/Path.ql linguist-generated /test/extractor-tests/generated/Path/Path_getPart.ql linguist-generated /test/extractor-tests/generated/Path/Path_getQualifier.ql linguist-generated +/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.ql linguist-generated +/test/extractor-tests/generated/Path/Path_getResolvedPath.ql linguist-generated /test/extractor-tests/generated/PathExpr/PathExpr.ql linguist-generated /test/extractor-tests/generated/PathExpr/PathExpr_getAttr.ql linguist-generated /test/extractor-tests/generated/PathExpr/PathExpr_getPath.ql linguist-generated diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index 10411df5a797..b516d8a9d185 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -123,6 +123,7 @@ import codeql.rust.elements.RefExpr import codeql.rust.elements.RefPat import codeql.rust.elements.RefType import codeql.rust.elements.Rename +import codeql.rust.elements.Resolvable import codeql.rust.elements.RestPat import codeql.rust.elements.RetType import codeql.rust.elements.ReturnExpr diff --git a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll index fca8b0861345..c3d62106100e 100644 --- a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll @@ -8,6 +8,7 @@ import codeql.rust.elements.CallExprBase import codeql.rust.elements.Expr import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef +import codeql.rust.elements.Resolvable /** * A method call expression. For example: diff --git a/rust/ql/lib/codeql/rust/elements/Path.qll b/rust/ql/lib/codeql/rust/elements/Path.qll index df6b4a880dff..530c40397c31 100644 --- a/rust/ql/lib/codeql/rust/elements/Path.qll +++ b/rust/ql/lib/codeql/rust/elements/Path.qll @@ -4,8 +4,8 @@ */ private import internal.PathImpl -import codeql.rust.elements.AstNode import codeql.rust.elements.PathSegment +import codeql.rust.elements.Resolvable /** * A path. For example: diff --git a/rust/ql/lib/codeql/rust/elements/Resolvable.qll b/rust/ql/lib/codeql/rust/elements/Resolvable.qll new file mode 100644 index 000000000000..e3e7b7725015 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Resolvable.qll @@ -0,0 +1,12 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `Resolvable`. + */ + +private import internal.ResolvableImpl +import codeql.rust.elements.AstNode + +/** + * Either a `Path`, or a `MethodCallExpr`. + */ +final class Resolvable = Impl::Resolvable; diff --git a/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll index 729c2fff0ed8..a599feded626 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `MethodCallExpr`. * @@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.MethodCallExpr * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A method call expression. For example: * ```rust @@ -19,5 +19,7 @@ module Impl { * x.foo::(42); * ``` */ - class MethodCallExpr extends Generated::MethodCallExpr { } + class MethodCallExpr extends Generated::MethodCallExpr { + override string toString() { result = "... ." + this.getNameRef().toString() + "(...)" } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/NameImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/NameImpl.qll index 672f29e24559..43642a03886f 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/NameImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/NameImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `Name`. * @@ -12,11 +11,14 @@ private import codeql.rust.elements.internal.generated.Name * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A Name. For example: * ```rust * todo!() * ``` */ - class Name extends Generated::Name { } + class Name extends Generated::Name { + override string toString() { result = this.getText() } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/NameRefImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/NameRefImpl.qll index 708e6d3e03f8..9f5f3eac48eb 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/NameRefImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/NameRefImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `NameRef`. * @@ -12,11 +11,14 @@ private import codeql.rust.elements.internal.generated.NameRef * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A NameRef. For example: * ```rust * todo!() * ``` */ - class NameRef extends Generated::NameRef { } + class NameRef extends Generated::NameRef { + override string toString() { result = this.getText() } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/PathImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/PathImpl.qll index 9e3d4127cb7e..b53c86559f0c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/PathImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/PathImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `Path`. * @@ -12,11 +11,18 @@ private import codeql.rust.elements.internal.generated.Path * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A path. For example: * ```rust * foo::bar; * ``` */ - class Path extends Generated::Path { } + class Path extends Generated::Path { + override string toString() { + if this.hasQualifier() + then result = this.getQualifier().toString() + "::" + this.getPart().toString() + else result = this.getPart().toString() + } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll index cc3f669dd5d7..300a6c7d4a0c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `PathSegment`. * @@ -12,11 +11,19 @@ private import codeql.rust.elements.internal.generated.PathSegment * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A PathSegment. For example: * ```rust * todo!() * ``` */ - class PathSegment extends Generated::PathSegment { } + class PathSegment extends Generated::PathSegment { + override string toString() { + // TODO: this does not cover everything + if this.hasGenericArgList() + then result = this.getNameRef().toString() + "::<...>" + else result = this.getNameRef().toString() + } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll new file mode 100644 index 000000000000..c6f1f2e7a693 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll @@ -0,0 +1,19 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Resolvable`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Resolvable + +/** + * INTERNAL: This module contains the customizable definition of `Resolvable` and should not + * be referenced directly. + */ +module Impl { + /** + * Either a `Path`, or a `MethodCallExpr`. + */ + class Resolvable extends Generated::Resolvable { } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll index 4aeb89e8e85b..dc1b32bea6c8 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll @@ -10,6 +10,7 @@ import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl import codeql.rust.elements.Expr import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef +import codeql.rust.elements.internal.ResolvableImpl::Impl as ResolvableImpl /** * INTERNAL: This module contains the fully generated definition of `MethodCallExpr` and should not @@ -25,7 +26,9 @@ module Generated { * INTERNAL: Do not reference the `Generated::MethodCallExpr` class directly. * Use the subclass `MethodCallExpr`, where the following predicates are available. */ - class MethodCallExpr extends Synth::TMethodCallExpr, CallExprBaseImpl::CallExprBase { + class MethodCallExpr extends Synth::TMethodCallExpr, CallExprBaseImpl::CallExprBase, + ResolvableImpl::Resolvable + { override string getAPrimaryQlClass() { result = "MethodCallExpr" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 6264dc674205..470207683ae5 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -652,25 +652,6 @@ private module Impl { ) } - private Element getImmediateChildOfPath(Path e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nQualifier, int nPart | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nQualifier = n + 1 and - nPart = nQualifier + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - index = n and result = e.getQualifier() and partialPredicateCall = "Qualifier()" - or - index = nQualifier and result = e.getPart() and partialPredicateCall = "Part()" - ) - ) - } - private Element getImmediateChildOfPathSegment( PathSegment e, int index, string partialPredicateCall ) { @@ -854,6 +835,19 @@ private module Impl { ) } + private Element getImmediateChildOfResolvable(Resolvable e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + private Element getImmediateChildOfRetType(RetType e, int index, string partialPredicateCall) { exists(int b, int bAstNode, int n, int nTy | b = 0 and @@ -2242,6 +2236,26 @@ private module Impl { ) } + private Element getImmediateChildOfPath(Path e, int index, string partialPredicateCall) { + exists(int b, int bResolvable, int n, int nQualifier, int nPart | + b = 0 and + bResolvable = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfResolvable(e, i, _)) | i) and + n = bResolvable and + nQualifier = n + 1 and + nPart = nQualifier + 1 and + ( + none() + or + result = getImmediateChildOfResolvable(e, index - b, partialPredicateCall) + or + index = n and result = e.getQualifier() and partialPredicateCall = "Qualifier()" + or + index = nQualifier and result = e.getPart() and partialPredicateCall = "Part()" + ) + ) + } + private Element getImmediateChildOfPathExprBase( PathExprBase e, int index, string partialPredicateCall ) { @@ -3167,11 +3181,17 @@ private module Impl { private Element getImmediateChildOfMethodCallExpr( MethodCallExpr e, int index, string partialPredicateCall ) { - exists(int b, int bCallExprBase, int n, int nGenericArgList, int nNameRef, int nReceiver | + exists( + int b, int bCallExprBase, int bResolvable, int n, int nGenericArgList, int nNameRef, + int nReceiver + | b = 0 and bCallExprBase = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallExprBase(e, i, _)) | i) and - n = bCallExprBase and + bResolvable = + bCallExprBase + 1 + + max(int i | i = -1 or exists(getImmediateChildOfResolvable(e, i, _)) | i) and + n = bResolvable and nGenericArgList = n + 1 and nNameRef = nGenericArgList + 1 and nReceiver = nNameRef + 1 and @@ -3180,6 +3200,8 @@ private module Impl { or result = getImmediateChildOfCallExprBase(e, index - b, partialPredicateCall) or + result = getImmediateChildOfResolvable(e, index - bCallExprBase, partialPredicateCall) + or index = n and result = e.getGenericArgList() and partialPredicateCall = "GenericArgList()" or index = nGenericArgList and result = e.getNameRef() and partialPredicateCall = "NameRef()" @@ -3573,8 +3595,6 @@ private module Impl { or result = getImmediateChildOfParamList(e, index, partialAccessor) or - result = getImmediateChildOfPath(e, index, partialAccessor) - or result = getImmediateChildOfPathSegment(e, index, partialAccessor) or result = getImmediateChildOfRecordExprField(e, index, partialAccessor) @@ -3713,6 +3733,8 @@ private module Impl { or result = getImmediateChildOfParenType(e, index, partialAccessor) or + result = getImmediateChildOfPath(e, index, partialAccessor) + or result = getImmediateChildOfPathPat(e, index, partialAccessor) or result = getImmediateChildOfPathType(e, index, partialAccessor) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Path.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Path.qll index 2bc8e3dfd6a1..58f7d891d263 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Path.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Path.qll @@ -6,9 +6,9 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl import codeql.rust.elements.Path import codeql.rust.elements.PathSegment +import codeql.rust.elements.internal.ResolvableImpl::Impl as ResolvableImpl /** * INTERNAL: This module contains the fully generated definition of `Path` and should not @@ -23,7 +23,7 @@ module Generated { * INTERNAL: Do not reference the `Generated::Path` class directly. * Use the subclass `Path`, where the following predicates are available. */ - class Path extends Synth::TPath, AstNodeImpl::AstNode { + class Path extends Synth::TPath, ResolvableImpl::Resolvable { override string getAPrimaryQlClass() { result = "Path" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index 29be5f96117b..25af8ddac644 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -576,27 +576,6 @@ module Raw { */ class Pat extends @pat, AstNode { } - /** - * INTERNAL: Do not use. - * A path. For example: - * ```rust - * foo::bar; - * ``` - */ - class Path extends @path, AstNode { - override string toString() { result = "Path" } - - /** - * Gets the qualifier of this path, if it exists. - */ - Path getQualifier() { path_qualifiers(this, result) } - - /** - * Gets the part of this path, if it exists. - */ - PathSegment getPart() { path_parts(this, result) } - } - /** * INTERNAL: Do not use. * A PathSegment. For example: @@ -789,6 +768,22 @@ module Raw { Name getName() { rename_names(this, result) } } + /** + * INTERNAL: Do not use. + * Either a `Path`, or a `MethodCallExpr`. + */ + class Resolvable extends @resolvable, AstNode { + /** + * Gets the resolved path of this resolvable, if it exists. + */ + string getResolvedPath() { resolvable_resolved_paths(this, result) } + + /** + * Gets the resolved crate origin of this resolvable, if it exists. + */ + string getResolvedCrateOrigin() { resolvable_resolved_crate_origins(this, result) } + } + /** * INTERNAL: Do not use. * A RetType. For example: @@ -2471,6 +2466,27 @@ module Raw { TypeRef getTy() { paren_type_ties(this, result) } } + /** + * INTERNAL: Do not use. + * A path. For example: + * ```rust + * foo::bar; + * ``` + */ + class Path extends @path, Resolvable { + override string toString() { result = "Path" } + + /** + * Gets the qualifier of this path, if it exists. + */ + Path getQualifier() { path_qualifiers(this, result) } + + /** + * Gets the part of this path, if it exists. + */ + PathSegment getPart() { path_parts(this, result) } + } + /** * INTERNAL: Do not use. * A path expression or a variable access in a formatting template. See `PathExpr` and `FormatTemplateVariableAccess` for further details. @@ -3548,7 +3564,7 @@ module Raw { * x.foo::(42); * ``` */ - class MethodCallExpr extends @method_call_expr, CallExprBase { + class MethodCallExpr extends @method_call_expr, CallExprBase, Resolvable { override string toString() { result = "MethodCallExpr" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll new file mode 100644 index 000000000000..018c451e5849 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll @@ -0,0 +1,52 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `Resolvable`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.elements.internal.generated.Synth +private import codeql.rust.elements.internal.generated.Raw +import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl + +/** + * INTERNAL: This module contains the fully generated definition of `Resolvable` and should not + * be referenced directly. + */ +module Generated { + /** + * Either a `Path`, or a `MethodCallExpr`. + * INTERNAL: Do not reference the `Generated::Resolvable` class directly. + * Use the subclass `Resolvable`, where the following predicates are available. + */ + class Resolvable extends Synth::TResolvable, AstNodeImpl::AstNode { + /** + * Gets the resolved path of this resolvable, if it exists. + * + * INTERNAL: Do not use. + */ + string getResolvedPath() { + result = Synth::convertResolvableToRaw(this).(Raw::Resolvable).getResolvedPath() + } + + /** + * Holds if `getResolvedPath()` exists. + * INTERNAL: Do not use. + */ + final predicate hasResolvedPath() { exists(this.getResolvedPath()) } + + /** + * Gets the resolved crate origin of this resolvable, if it exists. + * + * INTERNAL: Do not use. + */ + string getResolvedCrateOrigin() { + result = Synth::convertResolvableToRaw(this).(Raw::Resolvable).getResolvedCrateOrigin() + } + + /** + * Holds if `getResolvedCrateOrigin()` exists. + * INTERNAL: Do not use. + */ + final predicate hasResolvedCrateOrigin() { exists(this.getResolvedCrateOrigin()) } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll index 05b3fd5ece7b..927ba1f238d8 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -624,12 +624,12 @@ module Synth { TExpr or TExternItem or TExternItemList or TFieldList or TFormatArgsArg or TGenericArg or TGenericArgList or TGenericParam or TGenericParamList or TItemList or TLabel or TLetElse or TLifetime or TMacroItems or TMacroStmts or TMatchArm or TMatchArmList or TMatchGuard or - TMeta or TName or TNameRef or TParam or TParamList or TPat or TPath or TPathSegment or + TMeta or TName or TNameRef or TParam or TParamList or TPat or TPathSegment or TRecordExprField or TRecordExprFieldList or TRecordField or TRecordPatField or - TRecordPatFieldList or TRename or TRetType or TReturnTypeSyntax or TSelfParam or - TSourceFile or TStmt or TStmtList or TToken or TTokenTree or TTupleField or TTypeBound or - TTypeBoundList or TTypeRef or TUseTree or TUseTreeList or TVariant or TVariantList or - TVisibility or TWhereClause or TWherePred; + TRecordPatFieldList or TRename or TResolvable or TRetType or TReturnTypeSyntax or + TSelfParam or TSourceFile or TStmt or TStmtList or TToken or TTokenTree or TTupleField or + TTypeBound or TTypeBoundList or TTypeRef or TUseTree or TUseTreeList or TVariant or + TVariantList or TVisibility or TWhereClause or TWherePred; /** * INTERNAL: Do not use. @@ -698,6 +698,11 @@ module Synth { */ class TPathExprBase = TFormatTemplateVariableAccess or TPathExpr; + /** + * INTERNAL: Do not use. + */ + class TResolvable = TMethodCallExpr or TPath; + /** * INTERNAL: Do not use. */ @@ -1690,8 +1695,6 @@ module Synth { or result = convertPatFromRaw(e) or - result = convertPathFromRaw(e) - or result = convertPathSegmentFromRaw(e) or result = convertRecordExprFieldFromRaw(e) @@ -1706,6 +1709,8 @@ module Synth { or result = convertRenameFromRaw(e) or + result = convertResolvableFromRaw(e) + or result = convertRetTypeFromRaw(e) or result = convertReturnTypeSyntaxFromRaw(e) @@ -2001,6 +2006,16 @@ module Synth { result = convertPathExprFromRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TResolvable`, if possible. + */ + TResolvable convertResolvableFromRaw(Raw::Element e) { + result = convertMethodCallExprFromRaw(e) + or + result = convertPathFromRaw(e) + } + /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TStmt`, if possible. @@ -3030,8 +3045,6 @@ module Synth { or result = convertPatToRaw(e) or - result = convertPathToRaw(e) - or result = convertPathSegmentToRaw(e) or result = convertRecordExprFieldToRaw(e) @@ -3046,6 +3059,8 @@ module Synth { or result = convertRenameToRaw(e) or + result = convertResolvableToRaw(e) + or result = convertRetTypeToRaw(e) or result = convertReturnTypeSyntaxToRaw(e) @@ -3341,6 +3356,16 @@ module Synth { result = convertPathExprToRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a synthesized `TResolvable` to a raw DB element, if possible. + */ + Raw::Element convertResolvableToRaw(TResolvable e) { + result = convertMethodCallExprToRaw(e) + or + result = convertPathToRaw(e) + } + /** * INTERNAL: Do not use. * Converts a synthesized `TStmt` to a raw DB element, if possible. diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index d5d61e69a94a..666a1e2b0e16 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -165,7 +165,6 @@ locatable_locations( | @param | @param_list | @pat -| @path | @path_segment | @record_expr_field | @record_expr_field_list @@ -173,6 +172,7 @@ locatable_locations( | @record_pat_field | @record_pat_field_list | @rename +| @resolvable | @ret_type | @return_type_syntax | @self_param @@ -644,22 +644,6 @@ param_list_self_params( | @wildcard_pat ; -paths( - unique int id: @path -); - -#keyset[id] -path_qualifiers( - int id: @path ref, - int qualifier: @path ref -); - -#keyset[id] -path_parts( - int id: @path ref, - int part: @path_segment ref -); - path_segments( unique int id: @path_segment ); @@ -832,6 +816,23 @@ rename_names( int name: @name ref ); +@resolvable = + @method_call_expr +| @path +; + +#keyset[id] +resolvable_resolved_paths( + int id: @resolvable ref, + string resolved_path: string ref +); + +#keyset[id] +resolvable_resolved_crate_origins( + int id: @resolvable ref, + string resolved_crate_origin: string ref +); + ret_types( unique int id: @ret_type ); @@ -2125,6 +2126,22 @@ paren_type_ties( int ty: @type_ref ref ); +paths( + unique int id: @path +); + +#keyset[id] +path_qualifiers( + int id: @path ref, + int qualifier: @path ref +); + +#keyset[id] +path_parts( + int id: @path ref, + int part: @path_segment ref +); + @path_expr_base = @path_expr ; diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_path.expected b/rust/ql/test/extractor-tests/canonical_path/canonical_path.expected deleted file mode 100644 index abfa4a99802a..000000000000 --- a/rust/ql/test/extractor-tests/canonical_path/canonical_path.expected +++ /dev/null @@ -1,28 +0,0 @@ -| canonical_paths.rs:1:1:23:1 | Module | crate::canonical_paths::a | -| canonical_paths.rs:2:5:2:22 | Struct | crate::canonical_paths::a::Struct | -| canonical_paths.rs:4:5:6:5 | Trait | crate::canonical_paths::a::Trait | -| canonical_paths.rs:5:9:5:20 | f | crate::canonical_paths::a::Trait::f | -| canonical_paths.rs:8:5:10:5 | Impl | None | -| canonical_paths.rs:9:9:9:22 | f | ::f | -| canonical_paths.rs:12:5:14:5 | Impl | None | -| canonical_paths.rs:13:9:13:22 | g | ::g | -| canonical_paths.rs:16:5:18:5 | Trait | crate::canonical_paths::a::TraitWithBlanketImpl | -| canonical_paths.rs:17:9:17:20 | h | crate::canonical_paths::a::TraitWithBlanketImpl::h | -| canonical_paths.rs:20:5:22:5 | Impl | None | -| canonical_paths.rs:21:9:21:22 | h | <_ as crate::canonical_paths::a::TraitWithBlanketImpl>::h | -| canonical_paths.rs:25:1:53:1 | Module | crate::canonical_paths::without | -| canonical_paths.rs:26:5:48:5 | canonicals | crate::canonical_paths::without::canonicals | -| canonical_paths.rs:27:9:27:27 | Struct | {0}::OtherStruct | -| canonical_paths.rs:29:9:31:9 | Trait | {0}::OtherTrait | -| canonical_paths.rs:30:13:30:24 | g | {0}::OtherTrait::g | -| canonical_paths.rs:33:9:35:9 | Impl | None | -| canonical_paths.rs:34:13:34:26 | g | <{0}::OtherStruct as {0}::OtherTrait>::g | -| canonical_paths.rs:37:9:39:9 | Impl | None | -| canonical_paths.rs:38:13:38:26 | g | ::g | -| canonical_paths.rs:41:9:43:9 | Impl | None | -| canonical_paths.rs:42:13:42:26 | f | <{0}::OtherStruct as crate::canonical_paths::a::Trait>::f | -| canonical_paths.rs:45:9:47:9 | nested | {0}::nested | -| canonical_paths.rs:46:13:46:31 | Struct | {1}::OtherStruct | -| canonical_paths.rs:50:5:52:5 | other | crate::canonical_paths::without::other | -| canonical_paths.rs:51:9:51:27 | Struct | {2}::OtherStruct | -| lib.rs:1:1:1:20 | Module | crate::canonical_paths | diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_path.ql b/rust/ql/test/extractor-tests/canonical_path/canonical_path.ql deleted file mode 100644 index 5548ba977737..000000000000 --- a/rust/ql/test/extractor-tests/canonical_path/canonical_path.ql +++ /dev/null @@ -1,12 +0,0 @@ -import rust -import TestUtils - -from Item i, string path -where - toBeTested(i) and - ( - path = i.getExtendedCanonicalPath() - or - not i.hasExtendedCanonicalPath() and path = "None" - ) -select i, path diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected new file mode 100644 index 000000000000..622652e091f7 --- /dev/null +++ b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected @@ -0,0 +1,70 @@ +canonicalPaths +| canonical_paths.rs:1:1:34:1 | Module | repo::test | crate::canonical_paths::a | +| canonical_paths.rs:2:5:3:22 | Struct | repo::test | crate::canonical_paths::a::Struct | +| canonical_paths.rs:5:5:7:5 | Trait | repo::test | crate::canonical_paths::a::Trait | +| canonical_paths.rs:6:9:6:20 | f | repo::test | crate::canonical_paths::a::Trait::f | +| canonical_paths.rs:9:5:11:5 | Impl | None | None | +| canonical_paths.rs:10:9:10:22 | f | repo::test | ::f | +| canonical_paths.rs:13:5:15:5 | Impl | None | None | +| canonical_paths.rs:14:9:14:22 | g | repo::test | ::g | +| canonical_paths.rs:17:5:19:5 | Trait | repo::test | crate::canonical_paths::a::TraitWithBlanketImpl | +| canonical_paths.rs:18:9:18:20 | h | repo::test | crate::canonical_paths::a::TraitWithBlanketImpl::h | +| canonical_paths.rs:21:5:23:5 | Impl | None | None | +| canonical_paths.rs:22:9:22:22 | h | repo::test | <_ as crate::canonical_paths::a::TraitWithBlanketImpl>::h | +| canonical_paths.rs:25:5:25:16 | free | repo::test | crate::canonical_paths::a::free | +| canonical_paths.rs:27:5:33:5 | usage | repo::test | crate::canonical_paths::a::usage | +| canonical_paths.rs:36:1:73:1 | Module | repo::test | crate::canonical_paths::without | +| canonical_paths.rs:37:5:37:24 | Use | None | None | +| canonical_paths.rs:39:5:68:5 | canonicals | repo::test | crate::canonical_paths::without::canonicals | +| canonical_paths.rs:40:9:40:27 | Struct | repo::test | {34}::OtherStruct | +| canonical_paths.rs:42:9:44:9 | Trait | repo::test | {34}::OtherTrait | +| canonical_paths.rs:43:13:43:24 | g | repo::test | {34}::OtherTrait::g | +| canonical_paths.rs:46:9:48:9 | Impl | None | None | +| canonical_paths.rs:47:13:47:26 | g | repo::test | <{34}::OtherStruct as {34}::OtherTrait>::g | +| canonical_paths.rs:50:9:52:9 | Impl | None | None | +| canonical_paths.rs:51:13:51:26 | g | repo::test | ::g | +| canonical_paths.rs:54:9:56:9 | Impl | None | None | +| canonical_paths.rs:55:13:55:26 | f | repo::test | <{34}::OtherStruct as crate::canonical_paths::a::Trait>::f | +| canonical_paths.rs:58:9:60:9 | nested | repo::test | {34}::nested | +| canonical_paths.rs:59:13:59:31 | Struct | repo::test | {35}::OtherStruct | +| canonical_paths.rs:62:9:67:9 | usage | repo::test | {34}::usage | +| canonical_paths.rs:70:5:72:5 | other | repo::test | crate::canonical_paths::without::other | +| canonical_paths.rs:71:9:71:27 | Struct | repo::test | {36}::OtherStruct | +| lib.rs:1:1:1:20 | Module | repo::test | crate::canonical_paths | +resolvedPaths +| canonical_paths.rs:2:7:2:12 | derive | None | None | +| canonical_paths.rs:9:10:9:14 | Trait | repo::test | crate::canonical_paths::a::Trait | +| canonical_paths.rs:9:20:9:25 | Struct | repo::test | crate::canonical_paths::a::Struct | +| canonical_paths.rs:13:10:13:15 | Struct | repo::test | crate::canonical_paths::a::Struct | +| canonical_paths.rs:21:13:21:14 | Eq | lang:core | crate::cmp::Eq | +| canonical_paths.rs:21:17:21:36 | TraitWithBlanketImpl | repo::test | crate::canonical_paths::a::TraitWithBlanketImpl | +| canonical_paths.rs:21:42:21:42 | T | None | None | +| canonical_paths.rs:28:17:28:22 | Struct | repo::test | crate::canonical_paths::a::Struct | +| canonical_paths.rs:29:9:29:9 | s | None | None | +| canonical_paths.rs:29:9:29:13 | ... .f(...) | repo::test | ::f | +| canonical_paths.rs:30:9:30:9 | s | None | None | +| canonical_paths.rs:30:9:30:13 | ... .g(...) | repo::test | ::g | +| canonical_paths.rs:31:9:31:9 | s | None | None | +| canonical_paths.rs:31:9:31:13 | ... .h(...) | repo::test | <_ as crate::canonical_paths::a::TraitWithBlanketImpl>::h | +| canonical_paths.rs:32:9:32:12 | free | repo::test | crate::canonical_paths::a::free | +| canonical_paths.rs:37:9:37:13 | super | repo::test | crate::canonical_paths | +| canonical_paths.rs:37:9:37:16 | super::a | repo::test | crate::canonical_paths::a | +| canonical_paths.rs:37:9:37:23 | super::a::Trait | repo::test | crate::canonical_paths::a::Trait | +| canonical_paths.rs:46:14:46:23 | OtherTrait | repo::test | {34}::OtherTrait | +| canonical_paths.rs:46:29:46:39 | OtherStruct | repo::test | {34}::OtherStruct | +| canonical_paths.rs:50:14:50:23 | OtherTrait | repo::test | {34}::OtherTrait | +| canonical_paths.rs:50:29:50:33 | crate | None | None | +| canonical_paths.rs:50:29:50:50 | crate::canonical_paths | repo::test | crate::canonical_paths | +| canonical_paths.rs:50:29:50:53 | crate::canonical_paths::a | repo::test | crate::canonical_paths::a | +| canonical_paths.rs:50:29:50:61 | crate::canonical_paths::a::Struct | repo::test | crate::canonical_paths::a::Struct | +| canonical_paths.rs:54:14:54:18 | crate | None | None | +| canonical_paths.rs:54:14:54:35 | crate::canonical_paths | repo::test | crate::canonical_paths | +| canonical_paths.rs:54:14:54:38 | crate::canonical_paths::a | repo::test | crate::canonical_paths::a | +| canonical_paths.rs:54:14:54:45 | crate::canonical_paths::a::Trait | repo::test | crate::canonical_paths::a::Trait | +| canonical_paths.rs:54:51:54:61 | OtherStruct | repo::test | {34}::OtherStruct | +| canonical_paths.rs:63:21:63:31 | OtherStruct | repo::test | {34}::OtherStruct | +| canonical_paths.rs:64:13:64:13 | s | None | None | +| canonical_paths.rs:64:13:64:17 | ... .f(...) | repo::test | <{34}::OtherStruct as crate::canonical_paths::a::Trait>::f | +| canonical_paths.rs:65:13:65:13 | s | None | None | +| canonical_paths.rs:65:13:65:17 | ... .g(...) | repo::test | <{34}::OtherStruct as {34}::OtherTrait>::g | +| canonical_paths.rs:66:13:66:18 | nested | repo::test | {34}::nested | diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.ql b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.ql new file mode 100644 index 000000000000..7488d699087c --- /dev/null +++ b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.ql @@ -0,0 +1,30 @@ +import rust +import TestUtils + +query predicate canonicalPaths(Item i, string origin, string path) { + toBeTested(i) and + ( + origin = i.getCrateOrigin() + or + not i.hasCrateOrigin() and origin = "None" + ) and + ( + path = i.getExtendedCanonicalPath() + or + not i.hasExtendedCanonicalPath() and path = "None" + ) +} + +query predicate resolvedPaths(Resolvable e, string origin, string path) { + toBeTested(e) and + ( + origin = e.getResolvedCrateOrigin() + or + not e.hasResolvedCrateOrigin() and origin = "None" + ) and + ( + path = e.getResolvedPath() + or + not e.hasResolvedPath() and path = "None" + ) +} diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs index 39a5d8672b3b..7444903dc01f 100644 --- a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs +++ b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs @@ -1,4 +1,5 @@ mod a { + #[derive(Eq, PartialEq)] pub struct Struct; pub trait Trait { @@ -20,9 +21,21 @@ mod a { impl TraitWithBlanketImpl for T { fn h(&self) {} } + + fn free() {} + + fn usage() { + let s = Struct {}; + s.f(); + s.g(); + s.h(); + free(); + } } mod without { + use super::a::Trait; + fn canonicals() { struct OtherStruct; @@ -45,6 +58,13 @@ mod without { fn nested() { struct OtherStruct; } + + fn usage() { + let s = OtherStruct {}; + s.f(); + s.g(); + nested(); + } } fn other() { diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected index 453da55dbbca..33ab9edbb293 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected @@ -1,2 +1,2 @@ -| gen_method_call_expr.rs:5:5:5:13 | MethodCallExpr | hasArgList: | yes | getNumberOfAttrs: | 0 | hasGenericArgList: | no | hasNameRef: | yes | hasReceiver: | yes | -| gen_method_call_expr.rs:6:5:6:25 | MethodCallExpr | hasArgList: | yes | getNumberOfAttrs: | 0 | hasGenericArgList: | yes | hasNameRef: | yes | hasReceiver: | yes | +| gen_method_call_expr.rs:5:5:5:13 | MethodCallExpr | hasArgList: | yes | getNumberOfAttrs: | 0 | hasGenericArgList: | no | hasNameRef: | yes | hasReceiver: | yes | hasResolvedPath: | no | hasResolvedCrateOrigin: | no | +| gen_method_call_expr.rs:6:5:6:25 | MethodCallExpr | hasArgList: | yes | getNumberOfAttrs: | 0 | hasGenericArgList: | yes | hasNameRef: | yes | hasReceiver: | yes | hasResolvedPath: | no | hasResolvedCrateOrigin: | no | diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql index 90176a31d896..989540265a00 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql @@ -3,15 +3,22 @@ import codeql.rust.elements import TestUtils from - MethodCallExpr x, string hasArgList, int getNumberOfAttrs, string hasGenericArgList, - string hasNameRef, string hasReceiver + MethodCallExpr x, string hasArgList, int getNumberOfAttrs, string hasResolvedPath, + string hasResolvedCrateOrigin, string hasGenericArgList, string hasNameRef, string hasReceiver where toBeTested(x) and not x.isUnknown() and (if x.hasArgList() then hasArgList = "yes" else hasArgList = "no") and getNumberOfAttrs = x.getNumberOfAttrs() and + (if x.hasResolvedPath() then hasResolvedPath = "yes" else hasResolvedPath = "no") and + ( + if x.hasResolvedCrateOrigin() + then hasResolvedCrateOrigin = "yes" + else hasResolvedCrateOrigin = "no" + ) and (if x.hasGenericArgList() then hasGenericArgList = "yes" else hasGenericArgList = "no") and (if x.hasNameRef() then hasNameRef = "yes" else hasNameRef = "no") and if x.hasReceiver() then hasReceiver = "yes" else hasReceiver = "no" -select x, "hasArgList:", hasArgList, "getNumberOfAttrs:", getNumberOfAttrs, "hasGenericArgList:", +select x, "hasArgList:", hasArgList, "getNumberOfAttrs:", getNumberOfAttrs, "hasResolvedPath:", + hasResolvedPath, "hasResolvedCrateOrigin:", hasResolvedCrateOrigin, "hasGenericArgList:", hasGenericArgList, "hasNameRef:", hasNameRef, "hasReceiver:", hasReceiver diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.expected b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.ql b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.ql new file mode 100644 index 000000000000..dfb292181331 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedCrateOrigin.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from MethodCallExpr x +where toBeTested(x) and not x.isUnknown() +select x, x.getResolvedCrateOrigin() diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.expected b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.ql b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.ql new file mode 100644 index 000000000000..df94686cbf68 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getResolvedPath.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from MethodCallExpr x +where toBeTested(x) and not x.isUnknown() +select x, x.getResolvedPath() diff --git a/rust/ql/test/extractor-tests/generated/Path/Path.expected b/rust/ql/test/extractor-tests/generated/Path/Path.expected index 9c26bcd9c365..aac69a7f4667 100644 --- a/rust/ql/test/extractor-tests/generated/Path/Path.expected +++ b/rust/ql/test/extractor-tests/generated/Path/Path.expected @@ -1,2 +1,2 @@ -| gen_path.rs:5:5:5:7 | Path | hasQualifier: | no | hasPart: | yes | -| gen_path.rs:5:5:5:12 | Path | hasQualifier: | yes | hasPart: | yes | +| gen_path.rs:5:5:5:7 | Path | hasQualifier: | no | hasPart: | yes | hasResolvedPath: | no | hasResolvedCrateOrigin: | no | +| gen_path.rs:5:5:5:12 | Path | hasQualifier: | yes | hasPart: | yes | hasResolvedPath: | no | hasResolvedCrateOrigin: | no | diff --git a/rust/ql/test/extractor-tests/generated/Path/Path.ql b/rust/ql/test/extractor-tests/generated/Path/Path.ql index c5e1ba9d78a2..d84c2d869874 100644 --- a/rust/ql/test/extractor-tests/generated/Path/Path.ql +++ b/rust/ql/test/extractor-tests/generated/Path/Path.ql @@ -2,10 +2,18 @@ import codeql.rust.elements import TestUtils -from Path x, string hasQualifier, string hasPart +from + Path x, string hasResolvedPath, string hasResolvedCrateOrigin, string hasQualifier, string hasPart where toBeTested(x) and not x.isUnknown() and + (if x.hasResolvedPath() then hasResolvedPath = "yes" else hasResolvedPath = "no") and + ( + if x.hasResolvedCrateOrigin() + then hasResolvedCrateOrigin = "yes" + else hasResolvedCrateOrigin = "no" + ) and (if x.hasQualifier() then hasQualifier = "yes" else hasQualifier = "no") and if x.hasPart() then hasPart = "yes" else hasPart = "no" -select x, "hasQualifier:", hasQualifier, "hasPart:", hasPart +select x, "hasResolvedPath:", hasResolvedPath, "hasResolvedCrateOrigin:", hasResolvedCrateOrigin, + "hasQualifier:", hasQualifier, "hasPart:", hasPart diff --git a/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.expected b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.ql b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.ql new file mode 100644 index 000000000000..c998981364fa --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedCrateOrigin.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from Path x +where toBeTested(x) and not x.isUnknown() +select x, x.getResolvedCrateOrigin() diff --git a/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedPath.expected b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedPath.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedPath.ql b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedPath.ql new file mode 100644 index 000000000000..c89693098365 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Path/Path_getResolvedPath.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from Path x +where toBeTested(x) and not x.isUnknown() +select x, x.getResolvedPath() diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index f8f5f182ad6f..d8e9835b16a6 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -63,8 +63,7 @@ class _: ``` """ - -@annotate(Path) +@annotate(Path, replace_bases={AstNode: Resolvable}) class _: """ A path. For example: @@ -221,7 +220,7 @@ class _: attrs: drop -@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}) +@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}, add_bases=(Resolvable,)) class _: """ A method call expression. For example: diff --git a/rust/schema/prelude.py b/rust/schema/prelude.py index 4f001ed2b5b8..60de626e59cb 100644 --- a/rust/schema/prelude.py +++ b/rust/schema/prelude.py @@ -71,3 +71,11 @@ class Callable(AstNode): """ param_list: optional["ParamList"] | child attrs: list["Attr"] | child + + +class Resolvable(AstNode): + """ + Either a `Path`, or a `MethodCallExpr`. + """ + resolved_path: optional[string] | rust.detach | ql.internal + resolved_crate_origin: optional[string] | rust.detach | ql.internal