diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index 3ff79b9b0411..d750024b186c 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 4504ceb7e13020d5b19a4b938395fa2d5d804a962743985efe8563903448ae0c 4504ceb7e13020d5b19a4b938395fa2d5d804a962743985efe8563903448ae0c +top.rs bc12e91ac724df9ca0c5d438067762d7e540bc20bde01c053af048b2a8391e2e bc12e91ac724df9ca0c5d438067762d7e540bc20bde01c053af048b2a8391e2e diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index a3e1d7aac803..bf148981679c 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -200,6 +200,51 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Addressable { + _unused: () +} + +impl Addressable { + pub fn emit_extended_canonical_path(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("addressable_extended_canonical_paths", vec![id.into(), value.into()]); + } + pub fn emit_crate_origin(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("addressable_crate_origins", vec![id.into(), value.into()]); + } +} + +impl trap::TrapClass for Addressable { + fn class_name() -> &'static str { "Addressable" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Addressable 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 Addressable 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 Addressable is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct ArgList { pub id: trap::TrapId, @@ -2729,72 +2774,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct Variant { - pub id: trap::TrapId, - pub attrs: Vec>, - pub expr: Option>, - pub field_list: Option>, - pub name: Option>, - pub visibility: Option>, -} - -impl trap::TrapEntry for Variant { - 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("variants", vec![id.into()]); - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("variant_attrs", vec![id.into(), i.into(), v.into()]); - } - if let Some(v) = self.expr { - out.add_tuple("variant_exprs", vec![id.into(), v.into()]); - } - if let Some(v) = self.field_list { - out.add_tuple("variant_field_lists", vec![id.into(), v.into()]); - } - if let Some(v) = self.name { - out.add_tuple("variant_names", vec![id.into(), v.into()]); - } - if let Some(v) = self.visibility { - out.add_tuple("variant_visibilities", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for Variant { - fn class_name() -> &'static str { "Variant" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Variant 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 Variant 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 Variant is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct VariantList { pub id: trap::TrapId, @@ -4865,19 +4844,19 @@ pub struct Item { _unused: () } -impl Item { - pub fn emit_extended_canonical_path(id: trap::Label, value: String, out: &mut trap::Writer) { - out.add_tuple("item_extended_canonical_paths", vec![id.into(), value.into()]); - } - pub fn emit_crate_origin(id: trap::Label, value: String, out: &mut trap::Writer) { - out.add_tuple("item_crate_origins", vec![id.into(), value.into()]); - } -} - impl trap::TrapClass for Item { fn class_name() -> &'static str { "Item" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Item is a subclass of Addressable + 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 Item is a subclass of AstNode @@ -7780,6 +7759,81 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Variant { + pub id: trap::TrapId, + pub attrs: Vec>, + pub expr: Option>, + pub field_list: Option>, + pub name: Option>, + pub visibility: Option>, +} + +impl trap::TrapEntry for Variant { + 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("variants", vec![id.into()]); + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("variant_attrs", vec![id.into(), i.into(), v.into()]); + } + if let Some(v) = self.expr { + out.add_tuple("variant_exprs", vec![id.into(), v.into()]); + } + if let Some(v) = self.field_list { + out.add_tuple("variant_field_lists", vec![id.into(), v.into()]); + } + if let Some(v) = self.name { + out.add_tuple("variant_names", vec![id.into(), v.into()]); + } + if let Some(v) = self.visibility { + out.add_tuple("variant_visibilities", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for Variant { + fn class_name() -> &'static str { "Variant" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Variant is a subclass of Addressable + 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 Variant 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 Variant 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 Variant is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct WildcardPat { pub id: trap::TrapId, @@ -8184,6 +8238,15 @@ impl trap::TrapClass for Const { fn class_name() -> &'static str { "Const" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Const is a subclass of Addressable + 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 Const is a subclass of AssocItem @@ -8281,6 +8344,15 @@ impl trap::TrapClass for Enum { fn class_name() -> &'static str { "Enum" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Enum is a subclass of Addressable + 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 Enum is a subclass of AstNode @@ -8361,6 +8433,15 @@ impl trap::TrapClass for ExternBlock { fn class_name() -> &'static str { "ExternBlock" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ExternBlock is a subclass of Addressable + 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 ExternBlock is a subclass of AstNode @@ -8441,6 +8522,15 @@ impl trap::TrapClass for ExternCrate { fn class_name() -> &'static str { "ExternCrate" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ExternCrate is a subclass of Addressable + 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 ExternCrate is a subclass of AstNode @@ -8561,6 +8651,15 @@ impl trap::TrapClass for Function { fn class_name() -> &'static str { "Function" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Function is a subclass of Addressable + 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 Function is a subclass of AssocItem @@ -8692,6 +8791,15 @@ impl trap::TrapClass for Impl { fn class_name() -> &'static str { "Impl" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Impl is a subclass of Addressable + 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 Impl is a subclass of AstNode @@ -8828,6 +8936,15 @@ impl trap::TrapClass for MacroCall { fn class_name() -> &'static str { "MacroCall" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MacroCall is a subclass of Addressable + 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 MacroCall is a subclass of AssocItem @@ -8930,6 +9047,15 @@ impl trap::TrapClass for MacroDef { fn class_name() -> &'static str { "MacroDef" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MacroDef is a subclass of Addressable + 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 MacroDef is a subclass of AstNode @@ -9010,6 +9136,15 @@ impl trap::TrapClass for MacroRules { fn class_name() -> &'static str { "MacroRules" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MacroRules is a subclass of Addressable + 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 MacroRules is a subclass of AstNode @@ -9183,6 +9318,15 @@ impl trap::TrapClass for Module { fn class_name() -> &'static str { "Module" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Module is a subclass of Addressable + 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 Module is a subclass of AstNode @@ -9347,6 +9491,15 @@ impl trap::TrapClass for Static { fn class_name() -> &'static str { "Static" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Static is a subclass of Addressable + 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 Static is a subclass of AstNode @@ -9444,6 +9597,15 @@ impl trap::TrapClass for Struct { fn class_name() -> &'static str { "Struct" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Struct is a subclass of Addressable + 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 Struct is a subclass of AstNode @@ -9544,6 +9706,15 @@ impl trap::TrapClass for Trait { fn class_name() -> &'static str { "Trait" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Trait is a subclass of Addressable + 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 Trait is a subclass of AstNode @@ -9632,6 +9803,15 @@ impl trap::TrapClass for TraitAlias { fn class_name() -> &'static str { "TraitAlias" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TraitAlias is a subclass of Addressable + 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 TraitAlias is a subclass of AstNode @@ -9728,6 +9908,15 @@ impl trap::TrapClass for TypeAlias { fn class_name() -> &'static str { "TypeAlias" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TypeAlias is a subclass of Addressable + 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 TypeAlias is a subclass of AssocItem @@ -9834,6 +10023,15 @@ impl trap::TrapClass for Union { fn class_name() -> &'static str { "Union" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Union is a subclass of Addressable + 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 Union is a subclass of AstNode @@ -9910,6 +10108,15 @@ impl trap::TrapClass for Use { fn class_name() -> &'static str { "Use" } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Use is a subclass of Addressable + 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 Use is a subclass of AstNode diff --git a/rust/extractor/src/translate/base.rs b/rust/extractor/src/translate/base.rs index c7e00edb3314..003c86919b67 100644 --- a/rust/extractor/src/translate/base.rs +++ b/rust/extractor/src/translate/base.rs @@ -10,7 +10,9 @@ 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, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type}; +use ra_ap_hir::{ + Adt, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type, Variant, +}; use ra_ap_hir_def::type_ref::Mutability; use ra_ap_hir_def::ModuleId; use ra_ap_hir_expand::ExpandTo; @@ -47,6 +49,9 @@ macro_rules! emit_detached { (Module, $self:ident, $node:ident, $label:ident) => { $self.extract_canonical_origin(&$node, $label.into()); }; + (Variant, $self:ident, $node:ident, $label:ident) => { + $self.extract_canonical_origin_of_enum_variant(&$node, $label); + }; // TODO canonical origin of other items (Path, $self:ident, $node:ident, $label:ident) => { $self.extract_canonical_destination(&$node, $label); @@ -396,16 +401,24 @@ impl<'a> Translator<'a> { 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::Variant(it) => self.canonical_path_from_enum_variant(it), ModuleDef::Static(_) => None, ModuleDef::TraitAlias(_) => None, ModuleDef::TypeAlias(_) => None, ModuleDef::BuiltinType(_) => None, ModuleDef::Macro(_) => None, - ModuleDef::Variant(_) => None, ModuleDef::Const(_) => None, } } + fn canonical_path_from_enum_variant(&self, item: Variant) -> Option { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + let prefix = self.canonical_path_from_hir(item.parent_enum(sema.db))?; + let name = item.name(sema.db); + Some(format!("{prefix}::{}", name.as_str())) + } + 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(); @@ -437,28 +450,58 @@ impl<'a> Translator<'a> { 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::Variant(it) => Some(self.origin_from_enum_variant(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_enum_variant(&self, item: Variant) -> String { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + self.origin_from_hir(item.parent_enum(sema.db)) + } + pub(crate) fn extract_canonical_origin( &mut self, item: &T, - label: Label, + label: Label, ) { (|| { let sema = self.semantics.as_ref()?; let def = T::Hir::try_from_source(item, sema)?; let path = self.canonical_path_from_hir(def)?; let origin = self.origin_from_hir(def); - generated::Item::emit_crate_origin(label, origin, &mut self.trap.writer); - generated::Item::emit_extended_canonical_path(label, path, &mut self.trap.writer); + generated::Addressable::emit_crate_origin(label, origin, &mut self.trap.writer); + generated::Addressable::emit_extended_canonical_path( + label, + path, + &mut self.trap.writer, + ); + Some(()) + })(); + } + + pub(crate) fn extract_canonical_origin_of_enum_variant( + &mut self, + item: &ast::Variant, + label: Label, + ) { + (|| { + let sema = self.semantics.as_ref()?; + let def = sema.to_enum_variant_def(item)?; + let path = self.canonical_path_from_enum_variant(def)?; + let origin = self.origin_from_enum_variant(def); + generated::Addressable::emit_crate_origin(label.into(), origin, &mut self.trap.writer); + generated::Addressable::emit_extended_canonical_path( + label.into(), + path, + &mut self.trap.writer, + ); Some(()) })(); } diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 36416013959d..c325f414c29c 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,5 +1,6 @@ lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 5e6ce2581b312d74ac8ffde44941b77f643025a7ff2c47799b3834596a513fa4 24dc5d28eb4754f968cf850294ac32057a2a97cf5156a3e90e0924c28e50e810 lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 +lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 lib/codeql/rust/elements/ArrayExpr.qll a3e6e122632f4011644ec31b37f88b32fe3f2b7e388e7e878a6883309937049f 12ccb5873d95c433da5606fd371d182ef2f71b78d0c53c2d6dec10fa45852bdc lib/codeql/rust/elements/ArrayType.qll affd43d308200d60d08e8924cdbb2a17a827ebaa62a296e07bb9ce97451e3c4c 80589a7f79bf2ac293a027faf2589b3027a6c4a286533f2ffccad259a306a8cb @@ -57,7 +58,7 @@ lib/codeql/rust/elements/Impl.qll 9593c47af4fa08afb19c52aab7d0bac6740fed7ec60201 lib/codeql/rust/elements/ImplTraitType.qll f7241044f6666a509cfbc01bf6df3db5360e67dd0f9baba4a323566701359203 350636d0b1c7a77e006170cbfa9108c259dd5831b0f242da76c10be3ecc32870 lib/codeql/rust/elements/IndexExpr.qll 0e2e9f018d06ae72be0fc4ddbc019a9aacd8a06f42b4c4431760bd149e7f2290 2bcfd557abd53a48e48de7915c4f2089107c62dfb3e732a904848248dfd3727b lib/codeql/rust/elements/InferType.qll c71184ae6aa181be94e299882503350e057493e17f1133a1e96162a0e5cbd1ef f0f19b611708df45a6ff811f8066c8042a8e1ac9b7bd94910514547ea430d3d5 -lib/codeql/rust/elements/Item.qll 5c9148ff0eaeb4404c2d8156e7df0ef5753fd44ead972da05a49659ddaa25480 78446f788617e40525d4d4b489848e75f2143a90e18d40974c3bff7b1e7c825c +lib/codeql/rust/elements/Item.qll 59353bf99dea5b464f45ed0dc5cef2db8208e92985d81dcd0b5ea09b638d10e4 2b0b87a4b1a1d9b512a67279d1dec2089d22d1df121585f7a9ca9661d689f74f lib/codeql/rust/elements/ItemList.qll c33e46a9ee45ccb194a0fe5b30a6ad3bcecb0f51486c94e0191a943710a17a7d 5a69c4e7712b4529681c4406d23dc1b6b9e5b3c03552688c55addab271912ed5 lib/codeql/rust/elements/Label.qll a31d41db351af7f99a55b26cdbbc7f13b4e96b660a74e2f1cc90c17ee8df8d73 689f87cb056c8a2aefe1a0bfc2486a32feb44eb3175803c61961a6aeee53d66e lib/codeql/rust/elements/LabelableExpr.qll 598be487cd051b004ab95cbbc3029100069dc9955851c492029d80f230e56f0d 92c49b3cfdaba07982f950e18a8d62dae4e96f5d9ae0d7d2f4292628361f0ddc @@ -159,7 +160,7 @@ lib/codeql/rust/elements/Union.qll 92ffb1abc03889b9b71dae9491d4595e443c80b472474 lib/codeql/rust/elements/Use.qll e27d30ece0456a73732dfd867dfc5abdf48a50de56e7dafcab444b688610af72 7efe59c04dd2f10b4a25b8a17beb51362be0a93d73e5a9e1251cf133cf1227c3 lib/codeql/rust/elements/UseTree.qll 16b6e42146dc4c2e9d8cc6bc143933d675d1a4c9a56b309f390f4bf5df99b25d 9f8dd7d621dd15f6f1ccec676b08da02773673cbb3a3570781c16167c6e08ef4 lib/codeql/rust/elements/UseTreeList.qll 768c4ec25e8807bba65619f566b22fa5c0946c36e96c88cfdee04c2875b44554 6433c8d9acd4e346cadd5fef01d79dd35bb6245115bdceb5322c0511106030b0 -lib/codeql/rust/elements/Variant.qll b0770c3ce0a82dcb2e238024b1db4ee2b76271f5a3d94f03bdaee71a25218da1 af242bd8651b653d931bf4cd3c234bdb58c8516eb4576edc03a929232946c38e +lib/codeql/rust/elements/Variant.qll 328323ef59faf01dcf71e7d728fd10a60465a1bd24e1d3578289cdf6554e5b63 ba49c635790395d9df4398c3c0fec700c3c7761fcc6581623a45d381d23ac34d lib/codeql/rust/elements/VariantList.qll 07adfe5750b2d5b50c8629f36feba24edd84f75698a80339d4cee20f4e95829d 7d322e60c84ea45f8c8b509226da7ae3c0125bcda42a98a94e3e6a9855cab79e lib/codeql/rust/elements/Visibility.qll d2cf0727efaf8df6b3808cb4a6b2e26d18e42db766d92e97ad3ef046d91cb9e5 8947a1e2d48b532c6455ddf143fa5b1dff28c40da1f1c6a72769fc9db7ecbaf6 lib/codeql/rust/elements/WhereClause.qll da51212766700e40713fff968078a0172a4f73eebc5425d8e0d60b03c2fe59fa 0ec036aea729b8f4af0eb8118911dce715e2eb4640ae7b5e40a007a48da03899 @@ -170,6 +171,7 @@ lib/codeql/rust/elements/YeetExpr.qll 4172bf70de31cab17639da6eed4a12a7afcefd7aa9 lib/codeql/rust/elements/YieldExpr.qll de2dc096a077f6c57bba9d1c2b2dcdbecce501333753b866d77c3ffbe06aa516 1f3e8949689c09ed356ff4777394fe39f2ed2b1e6c381fd391790da4f5d5c76a lib/codeql/rust/elements/internal/AbiConstructor.qll 4484538db49d7c1d31c139f0f21879fceb48d00416e24499a1d4b1337b4141ac 460818e397f2a1a8f2e5466d9551698b0e569d4640fcb87de6c4268a519b3da1 lib/codeql/rust/elements/internal/AbiImpl.qll 01439712ecadc9dc8da6f74d2e19cee13c77f8e1e25699055da675b2c88cb02d dcc9395ef8abd1af3805f3e7fcbc2d7ce30affbce654b6f5e559924768db403c +lib/codeql/rust/elements/internal/AddressableImpl.qll e01a6104980960f5708d5a0ada774ba21db9a344e33deeaf3d3239c627268c77 b8bfc711b267df305ac9fe5f6a994f051ddeca7fc95dacd76d1bae2d4fa7adde lib/codeql/rust/elements/internal/ArgListConstructor.qll a73685c8792ae23a2d628e7357658efb3f6e34006ff6e9661863ef116ec0b015 0bee572a046e8dfc031b1216d729843991519d94ae66280f5e795d20aea07a22 lib/codeql/rust/elements/internal/ArgListImpl.qll 19664651c06b46530f0ae5745ccb3233afc97b9152e053761d641de6e9c62d38 40af167e571f5c255f264b3be7cc7f5ff42ec109661ca03dcee94e92f8facfc6 lib/codeql/rust/elements/internal/ArrayExprConstructor.qll f4ac4efefe5fe4fe1e666f35b1ee92d2243d977b3f3308151c89f61582203c09 4167ae58ec869f7dbd8467093c4a53afd7c1efcf1cc865efa62b4eb484bd7ff8 @@ -413,6 +415,7 @@ lib/codeql/rust/elements/internal/YeetExprImpl.qll e8924147c3ebe0c32d04c5b33edfd lib/codeql/rust/elements/internal/YieldExprConstructor.qll 8cbfa6405acb151ee31ccc7c89336948a597d783e8890e5c3e53853850871712 966f685eb6b9063bc359213323d3ff760b536158ecd17608e7618a3e9adf475f lib/codeql/rust/elements/internal/YieldExprImpl.qll af184649a348ddd0be16dee9daae307240bf123ace09243950342e9d71ededd9 17df90f67dd51623e8a5715b344ccd8740c8fc415af092469f801b99caacb70d lib/codeql/rust/elements/internal/generated/Abi.qll 87e1ea6b2a8ebf60e1c69176632740e4e27fc56c3f173939b098ba376562b5fa 94b2121e71c4ec94d53a79f972c05a8484ef0d80ed638f53031e7cf4dc5343d5 +lib/codeql/rust/elements/internal/generated/Addressable.qll 96a8b45166dd035b8d2c6d36b8b67019f2d4d0b4ccff6d492677c0c87197613e d8f1ce29feafc8ff7179399fc7eac5db031a7e1a8bc6b2cd75cfce1da3132e9b lib/codeql/rust/elements/internal/generated/ArgList.qll 1b75b2d7dcf524eb468a0268af6293e9d17832d6bedf3feec49a535824339b57 2bcaf464454bdfdda45fbd24d063f0f1df0eb69f684197b37105adc8f72cd1ea lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 2ca97b602a707fe2c566002d8709792bb166ae52fdb7da28d7c4b8e0d66dd4bc 1cae1ef017171ec9a1ca28b4f2993b1ee26d22b51b3b04816d9b4e89fdff1fb3 lib/codeql/rust/elements/internal/generated/ArrayType.qll 225ac477f67865d72b2a2e17420f5e52c25452a3c14f7ff367f873a859f97783 0030e3bf296dd5b69ea912fc85dc7120b060780033083127257cdca792dc3f4b @@ -470,7 +473,7 @@ lib/codeql/rust/elements/internal/generated/Impl.qll e33ef5d3e49e64beca0ca9d5c0b lib/codeql/rust/elements/internal/generated/ImplTraitType.qll 3c29684f5ef386b883b79dc9758441d97f090e065be177ffc8240aaf0f3d1e7b 03ea42c2a95cf917ec73d88b7b4ca5e53e10d7b046074f59100c0ec6c2c1ed6d lib/codeql/rust/elements/internal/generated/IndexExpr.qll cf951fc40f6690e966b4dc78fa9a6221aa5c6cade44759dcb52254f799292d11 1572e71918cc4e0b7e028331b6d98c9db23100a3646cd3874d1915e06ab6211d lib/codeql/rust/elements/internal/generated/InferType.qll 23ee25135c59ea5578cdf7c34a41f606e217e7260c3c8f404d12836585d5cad4 400da322fa1be62c4e300ebdf481eb92d4226eb6c316c668da8cc5168065774f -lib/codeql/rust/elements/internal/generated/Item.qll 25e645cb41222c21065798fb6cb0488bfef007aeb9b89717f58913f9b29d5559 3146941e55db2ff7c51ec030b4414e20d66d154cf6854b1a3fa42e74a09dfb77 +lib/codeql/rust/elements/internal/generated/Item.qll 97f204f27c12689a01fef502a4eec3b587e4eaccd278ec07a34c70a33ce6119d 139af2d44f794d0f91d9aabc3d50d895107c34bd9bcb72457a2e243c14622e51 lib/codeql/rust/elements/internal/generated/ItemList.qll 73c8398a96d4caa47a2dc114d76c657bd3fcc59e4c63cb397ffac4a85b8cf8ab 540a13ca68d414e3727c3d53c6b1cc97687994d572bc74b3df99ecc8b7d8e791 lib/codeql/rust/elements/internal/generated/Label.qll 6630fe16e9d2de6c759ff2684f5b9950bc8566a1525c835c131ebb26f3eea63e 671143775e811fd88ec90961837a6c0ee4db96e54f42efd80c5ae2571661f108 lib/codeql/rust/elements/internal/generated/LabelableExpr.qll 896fd165b438b60d7169e8f30fa2a94946490c4d284e1bbadfec4253b909ee6c 5c6b029ea0b22cf096df2b15fe6f9384ad3e65b50b253cae7f19a2e5ffb04a58 @@ -512,7 +515,7 @@ 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 78723cac5f2999f91317f39cf53267043fd2a56e98e838f013eae01b6b39929e 26dd29e5fd868f89982269db6b25aa799be942abdbe41ff1a8ffd4dae4385bdc +lib/codeql/rust/elements/internal/generated/ParentChild.qll 0ef5a17cc0d38e942e8a3dbe26b34befdea3ba23bc18cc2450e0ce0bd55e145d 0aa61484a16cf47dc3802a77f46b055394d38bf3736f0197115e3ff004115635 lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 4c1c8e840ed57880e574142b081b11d7a7428a009f10e3aa8f4645e211f6b2e0 989668cf0f1bdee7557e2f97c01e41d2a56848227fed41477833f5fc1e1d35f6 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 @@ -525,7 +528,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 b342060fd7fe2214eea191859f559334a8a64cf6785048f784ed641ea1e616fd 4737f09bbd2e190eee9bb83476a0045887ff2982dd06cd4e6538fc31637ab521 +lib/codeql/rust/elements/internal/generated/Raw.qll 631450d9014ad3eb191007e2b0054162ca86aaccf9d5275be831ba762ee966a5 bc302f73decc7ceafbe285c32d74b5911830d2b3c95c7033507512de857feabb 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 @@ -551,7 +554,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 db8ffbd55def03f0b0278cafa60274220eb571257da36e185f380e3c5b2caedf 19074971c3e96a43414738976c9625385c4bbac6b01c7eca2f46432034a279b7 +lib/codeql/rust/elements/internal/generated/Synth.qll 65873a7fa44e223edc5e76cc768591a036eb2550960a6b6882476f43a01aefba 3e08e2bdfba53ae26d8f48f2d240b92b44c603f03105518c37a963e0cbe63e3f 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 @@ -577,7 +580,7 @@ lib/codeql/rust/elements/internal/generated/Union.qll 06a602aa7c7097e72fff6ea33d lib/codeql/rust/elements/internal/generated/Use.qll d42ccf3516a9f79ae8766f93ad5f09d3cdcd7b96844d4c9de64189b56018a7b4 70a9553a8f71f6cbfdd0f59a4b42292d13177613ceb0542436436e0ac2e1f8ee lib/codeql/rust/elements/internal/generated/UseTree.qll b39cbc96e473802372726d580febbfa7d73668ba476095aa4a61fae914865913 40ce6515b7df068fa8c0a7e5ae8984f50b71f6f96d625d631b28d525e3e868b7 lib/codeql/rust/elements/internal/generated/UseTreeList.qll 829441cf309f008a6a9d2e784aa414ab4c11880a658f8ee71aa4df385cd2b6a8 ced82df94fea7a191f414f7e6496d13791d2f535046844b6f712a390663ac3d0 -lib/codeql/rust/elements/internal/generated/Variant.qll 2e3d8e7a7a97f2f33d6cad458ec0ded498c17a14b697722a96fffecd50c83097 46149bb257c08d5cd9139198b6519d7ad3fd25cc9ea6bfe99deea66f5f1ef201 +lib/codeql/rust/elements/internal/generated/Variant.qll e40dbb23e07c5b70adc577efdf7a064e773207f216cad8fe8905882b1da9f4a9 13f7be36d043afcfc156d2c01bb828de882df69aa732f284aa76c5f00b063544 lib/codeql/rust/elements/internal/generated/VariantList.qll 4eb923ca341033c256ca9b8a8a5b4e14c7eac9d015be187fd97eeb25dfb1e18e e7865e975c35db49cd72cb8f9864797d3cfed16c3a675b5032b867ced2bbb405 lib/codeql/rust/elements/internal/generated/Visibility.qll aba81820f30bed0fd2cd06831f7256af15ae32525b2a437896420b4cc067ea38 d6aed90b27124b812daf2ddd14b4e181277cbe638b4ccaab74e27681ac30e4ab lib/codeql/rust/elements/internal/generated/WhereClause.qll d6c8f72bbec5d71c024f0d365c1c5e474f4d24ded0d34c56c1f66b1e4a384e9d ed14311d140eee00d3b26a4972f53e20d5af1bddf88fb5618e7e2d3ae1d816f3 @@ -586,7 +589,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll 7edf1f23fbf953a2baabcd 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 83bda9f3bc481aaecc039db9cecb628495e15e469cc843336ca089f0d707f8d6 83bda9f3bc481aaecc039db9cecb628495e15e469cc843336ca089f0d707f8d6 +lib/codeql/rust/elements.qll ced76fbeebc6e2e972ecaed65ef97851f90a215cf330f28a0f31a253f1c03442 ced76fbeebc6e2e972ecaed65ef97851f90a215cf330f28a0f31a253f1c03442 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 @@ -1097,9 +1100,11 @@ test/extractor-tests/generated/UseTree/UseTree_getRename.ql ec3917501f3c89ac4974 test/extractor-tests/generated/UseTree/UseTree_getUseTreeList.ql c265a88347e813840969ae934dfd2904bc06f502de77709bc0b1c7255e46382a 52a239c8ea5fd8fbfbd606559d70ecadc769887437a9bcab6fb3e774208ad868 test/extractor-tests/generated/UseTreeList/UseTreeList.ql cd943c15c86e66244caafeb95b960a5c3d351d5edbd506258744fb60a61af3b2 cfa584cd9d8aa08267fd1106745a66226b2c99fadd1da65059cc7ecf2f2e68cf test/extractor-tests/generated/UseTreeList/UseTreeList_getUseTree.ql dd72966b1cb7b04f0267503013809063fcfb145e2b2d7d5250d9f24d2e405f9a 75b953aa11c51ca0fe95e67d50d6238962d8df4a4b9054999a2c6338e5a5613d -test/extractor-tests/generated/Variant/Variant.ql bf9b928ab3b1911e6c81fdc3fb9811e754ea28bfd0e4a21dca08b844aa42c3f1 bffd4bcc5019f721010722453985b39a4285240774e474e233ebe46f1cd5beb1 +test/extractor-tests/generated/Variant/Variant.ql c60dd31adac91e09f8b1e5523d6b859747e64ef072c077b5a3326763f9f461f7 55d6446a3a831ed1137264678c5df027eb94cb3570a88d364994851fe6236999 test/extractor-tests/generated/Variant/Variant_getAttr.ql dd38e48e1eb05ce280b880652a90010eb63f7de3be7232411ba6265691249420 f8980680104de1e5fd40f264d8d62346aacaf6403a5e051f6fd680e234c82c1f +test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql 99e79930f8ff87a25f256926e5c3ce1ee0847daf6fadc5445fb33c85328b4c61 2dd64a53813790654c83be25b5e175c9c5b388e758723c2138fff095353fdd7b test/extractor-tests/generated/Variant/Variant_getExpr.ql ce00af303d28f60c5fd1dc7df628c7974aced21884e223a2f656cb4f0d1a74d5 9de51a65510cf9a15801d4207b616915bd959c95ec7330fdb502c5dff5b650cc +test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql fe6a4bfd1440e7629d47283910de84c5e8c2f5645512780e710f53540b5bc886 b1e31b765cb1a5fe063abb8c1b2115e881ae28aa3ccd39e088ff8f2af20d6cf4 test/extractor-tests/generated/Variant/Variant_getFieldList.ql 083c8cf61989663de33d99b72dec231c308ccc8bb6739921465c473a07e8ea03 d03bff6945853c940acdc053b813d53b008ddab9a8bd4307826433828d4763ce test/extractor-tests/generated/Variant/Variant_getName.ql 0d7b47bec9f9031c67f7b684112a84a311ef9b2efeb260bd7cd6f424011ca0d8 73565e6f965dd7fd7bb9b3408c7d7b69120e1971b67ab307fed293eb663a59ae test/extractor-tests/generated/Variant/Variant_getVisibility.ql 2c8f365d28d96af55589f4d71ac3fee718b319b4cbc784560c0591d1f605a119 13160d9cf39fe169410eff6c338f5d063e1948109e8f18dd33ea0064f1dd9283 diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 69c1ecbc2c6a..06285585e981 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -2,6 +2,7 @@ /.gitattributes linguist-generated /lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll linguist-generated /lib/codeql/rust/elements/Abi.qll linguist-generated +/lib/codeql/rust/elements/Addressable.qll linguist-generated /lib/codeql/rust/elements/ArgList.qll linguist-generated /lib/codeql/rust/elements/ArrayExpr.qll linguist-generated /lib/codeql/rust/elements/ArrayType.qll linguist-generated @@ -172,6 +173,7 @@ /lib/codeql/rust/elements/YieldExpr.qll linguist-generated /lib/codeql/rust/elements/internal/AbiConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/AbiImpl.qll linguist-generated +/lib/codeql/rust/elements/internal/AddressableImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayExprConstructor.qll linguist-generated @@ -415,6 +417,7 @@ /lib/codeql/rust/elements/internal/YieldExprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/YieldExprImpl.qll linguist-generated /lib/codeql/rust/elements/internal/generated/Abi.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/Addressable.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArgList.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArrayExpr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArrayType.qll linguist-generated @@ -1101,7 +1104,9 @@ /test/extractor-tests/generated/UseTreeList/UseTreeList_getUseTree.ql linguist-generated /test/extractor-tests/generated/Variant/Variant.ql linguist-generated /test/extractor-tests/generated/Variant/Variant_getAttr.ql linguist-generated +/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql linguist-generated /test/extractor-tests/generated/Variant/Variant_getExpr.ql linguist-generated +/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql linguist-generated /test/extractor-tests/generated/Variant/Variant_getFieldList.ql linguist-generated /test/extractor-tests/generated/Variant/Variant_getName.ql linguist-generated /test/extractor-tests/generated/Variant/Variant_getVisibility.ql linguist-generated diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index 7d752c1b9be6..e37dde90d618 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -4,6 +4,7 @@ */ import codeql.rust.elements.Abi +import codeql.rust.elements.Addressable import codeql.rust.elements.ArgList import codeql.rust.elements.ArrayExpr import codeql.rust.elements.ArrayType diff --git a/rust/ql/lib/codeql/rust/elements/Addressable.qll b/rust/ql/lib/codeql/rust/elements/Addressable.qll new file mode 100644 index 000000000000..c5edd19adcb0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Addressable.qll @@ -0,0 +1,14 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `Addressable`. + */ + +private import internal.AddressableImpl +import codeql.rust.elements.AstNode + +/** + * Something that can be addressed by a path. + * + * TODO: This does not yet include all possible cases. + */ +final class Addressable = Impl::Addressable; diff --git a/rust/ql/lib/codeql/rust/elements/Item.qll b/rust/ql/lib/codeql/rust/elements/Item.qll index 838ba32b964c..b95620551bad 100644 --- a/rust/ql/lib/codeql/rust/elements/Item.qll +++ b/rust/ql/lib/codeql/rust/elements/Item.qll @@ -4,6 +4,7 @@ */ private import internal.ItemImpl +import codeql.rust.elements.Addressable import codeql.rust.elements.Stmt /** diff --git a/rust/ql/lib/codeql/rust/elements/Variant.qll b/rust/ql/lib/codeql/rust/elements/Variant.qll index 6100928696ea..658143dbfa21 100644 --- a/rust/ql/lib/codeql/rust/elements/Variant.qll +++ b/rust/ql/lib/codeql/rust/elements/Variant.qll @@ -4,7 +4,7 @@ */ private import internal.VariantImpl -import codeql.rust.elements.AstNode +import codeql.rust.elements.Addressable import codeql.rust.elements.Attr import codeql.rust.elements.Expr import codeql.rust.elements.FieldList diff --git a/rust/ql/lib/codeql/rust/elements/internal/AddressableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/AddressableImpl.qll new file mode 100644 index 000000000000..b3fe47b294a2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/AddressableImpl.qll @@ -0,0 +1,21 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Addressable`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Addressable + +/** + * INTERNAL: This module contains the customizable definition of `Addressable` and should not + * be referenced directly. + */ +module Impl { + /** + * Something that can be addressed by a path. + * + * TODO: This does not yet include all possible cases. + */ + class Addressable extends Generated::Addressable { } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Addressable.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Addressable.qll new file mode 100644 index 000000000000..9d4ba1e976a3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Addressable.qll @@ -0,0 +1,58 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `Addressable`. + * 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 `Addressable` and should not + * be referenced directly. + */ +module Generated { + /** + * Something that can be addressed by a path. + * + * TODO: This does not yet include all possible cases. + * INTERNAL: Do not reference the `Generated::Addressable` class directly. + * Use the subclass `Addressable`, where the following predicates are available. + */ + class Addressable extends Synth::TAddressable, AstNodeImpl::AstNode { + /** + * Gets the extended canonical path of this addressable, if it exists. + * + * Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), + * or `{}::name` for addressable items defined in an anonymous block (and only + * addressable there-in). + * INTERNAL: Do not use. + */ + string getExtendedCanonicalPath() { + result = Synth::convertAddressableToRaw(this).(Raw::Addressable).getExtendedCanonicalPath() + } + + /** + * Holds if `getExtendedCanonicalPath()` exists. + * INTERNAL: Do not use. + */ + final predicate hasExtendedCanonicalPath() { exists(this.getExtendedCanonicalPath()) } + + /** + * Gets the crate origin of this addressable, if it exists. + * + * One of `rustc:`, `repo::` or `lang:`. + * INTERNAL: Do not use. + */ + string getCrateOrigin() { + result = Synth::convertAddressableToRaw(this).(Raw::Addressable).getCrateOrigin() + } + + /** + * Holds if `getCrateOrigin()` exists. + * INTERNAL: Do not use. + */ + final predicate hasCrateOrigin() { exists(this.getCrateOrigin()) } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Item.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Item.qll index 429221c7f18f..39149c252587 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Item.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Item.qll @@ -6,6 +6,7 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw +import codeql.rust.elements.internal.AddressableImpl::Impl as AddressableImpl import codeql.rust.elements.internal.StmtImpl::Impl as StmtImpl /** @@ -21,37 +22,5 @@ module Generated { * INTERNAL: Do not reference the `Generated::Item` class directly. * Use the subclass `Item`, where the following predicates are available. */ - class Item extends Synth::TItem, StmtImpl::Stmt { - /** - * Gets the extended canonical path of this item, if it exists. - * - * Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), - * or `{}::name` for addressable items defined in an anonymous block (and only - * addressable there-in). - * INTERNAL: Do not use. - */ - string getExtendedCanonicalPath() { - result = Synth::convertItemToRaw(this).(Raw::Item).getExtendedCanonicalPath() - } - - /** - * Holds if `getExtendedCanonicalPath()` exists. - * INTERNAL: Do not use. - */ - final predicate hasExtendedCanonicalPath() { exists(this.getExtendedCanonicalPath()) } - - /** - * Gets the crate origin of this item, if it exists. - * - * One of `rustc:`, `repo::` or `lang:`. - * INTERNAL: Do not use. - */ - string getCrateOrigin() { result = Synth::convertItemToRaw(this).(Raw::Item).getCrateOrigin() } - - /** - * Holds if `getCrateOrigin()` exists. - * INTERNAL: Do not use. - */ - final predicate hasCrateOrigin() { exists(this.getCrateOrigin()) } - } + class Item extends Synth::TItem, StmtImpl::Stmt, AddressableImpl::Addressable { } } 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 970cfb223640..91c8cf7b0bd7 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -128,6 +128,21 @@ private module Impl { ) } + private Element getImmediateChildOfAddressable( + Addressable 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 getImmediateChildOfArgList(ArgList e, int index, string partialPredicateCall) { exists(int b, int bAstNode, int n, int nArg | b = 0 and @@ -1088,37 +1103,6 @@ private module Impl { ) } - private Element getImmediateChildOfVariant(Variant e, int index, string partialPredicateCall) { - exists( - int b, int bAstNode, int n, int nAttr, int nExpr, int nFieldList, int nName, int nVisibility - | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nExpr = nAttr + 1 and - nFieldList = nExpr + 1 and - nName = nFieldList + 1 and - nVisibility = nName + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" - or - index = nAttr and result = e.getExpr() and partialPredicateCall = "Expr()" - or - index = nExpr and result = e.getFieldList() and partialPredicateCall = "FieldList()" - or - index = nFieldList and result = e.getName() and partialPredicateCall = "Name()" - or - index = nName and result = e.getVisibility() and partialPredicateCall = "Visibility()" - ) - ) - } - private Element getImmediateChildOfVariantList( VariantList e, int index, string partialPredicateCall ) { @@ -1817,14 +1801,18 @@ private module Impl { } private Element getImmediateChildOfItem(Item e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n | + exists(int b, int bStmt, int bAddressable, int n | b = 0 and bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + bAddressable = + bStmt + 1 + max(int i | i = -1 or exists(getImmediateChildOfAddressable(e, i, _)) | i) and + n = bAddressable and ( none() or result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + result = getImmediateChildOfAddressable(e, index - bStmt, partialPredicateCall) ) ) } @@ -2709,6 +2697,39 @@ private module Impl { ) } + private Element getImmediateChildOfVariant(Variant e, int index, string partialPredicateCall) { + exists( + int b, int bAddressable, int n, int nAttr, int nExpr, int nFieldList, int nName, + int nVisibility + | + b = 0 and + bAddressable = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAddressable(e, i, _)) | i) and + n = bAddressable and + nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nExpr = nAttr + 1 and + nFieldList = nExpr + 1 and + nName = nFieldList + 1 and + nVisibility = nName + 1 and + ( + none() + or + result = getImmediateChildOfAddressable(e, index - b, partialPredicateCall) + or + result = e.getAttr(index - n) and + partialPredicateCall = "Attr(" + (index - n).toString() + ")" + or + index = nAttr and result = e.getExpr() and partialPredicateCall = "Expr()" + or + index = nExpr and result = e.getFieldList() and partialPredicateCall = "FieldList()" + or + index = nFieldList and result = e.getName() and partialPredicateCall = "Name()" + or + index = nName and result = e.getVisibility() and partialPredicateCall = "Visibility()" + ) + ) + } + private Element getImmediateChildOfWildcardPat( WildcardPat e, int index, string partialPredicateCall ) { @@ -3665,8 +3686,6 @@ private module Impl { or result = getImmediateChildOfUseTreeList(e, index, partialAccessor) or - result = getImmediateChildOfVariant(e, index, partialAccessor) - or result = getImmediateChildOfVariantList(e, index, partialAccessor) or result = getImmediateChildOfVisibility(e, index, partialAccessor) @@ -3817,6 +3836,8 @@ private module Impl { or result = getImmediateChildOfUnderscoreExpr(e, index, partialAccessor) or + result = getImmediateChildOfVariant(e, index, partialAccessor) + or result = getImmediateChildOfWildcardPat(e, index, partialAccessor) or result = getImmediateChildOfYeetExpr(e, index, partialAccessor) 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 69aa32d4ad8c..41ca7ef13d55 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -61,6 +61,30 @@ module Raw { string getAbiString() { abi_abi_strings(this, result) } } + /** + * INTERNAL: Do not use. + * Something that can be addressed by a path. + * + * TODO: This does not yet include all possible cases. + */ + class Addressable extends @addressable, AstNode { + /** + * Gets the extended canonical path of this addressable, if it exists. + * + * Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), + * or `{}::name` for addressable items defined in an anonymous block (and only + * addressable there-in). + */ + string getExtendedCanonicalPath() { addressable_extended_canonical_paths(this, result) } + + /** + * Gets the crate origin of this addressable, if it exists. + * + * One of `rustc:`, `repo::` or `lang:`. + */ + string getCrateOrigin() { addressable_crate_origins(this, result) } + } + /** * INTERNAL: Do not use. * A ArgList. For example: @@ -999,42 +1023,6 @@ module Raw { UseTree getUseTree(int index) { use_tree_list_use_trees(this, index, result) } } - /** - * INTERNAL: Do not use. - * A Variant. For example: - * ```rust - * todo!() - * ``` - */ - class Variant extends @variant, AstNode { - override string toString() { result = "Variant" } - - /** - * Gets the `index`th attr of this variant (0-based). - */ - Attr getAttr(int index) { variant_attrs(this, index, result) } - - /** - * Gets the expression of this variant, if it exists. - */ - Expr getExpr() { variant_exprs(this, result) } - - /** - * Gets the field list of this variant, if it exists. - */ - FieldList getFieldList() { variant_field_lists(this, result) } - - /** - * Gets the name of this variant, if it exists. - */ - Name getName() { variant_names(this, result) } - - /** - * Gets the visibility of this variant, if it exists. - */ - Visibility getVisibility() { variant_visibilities(this, result) } - } - /** * INTERNAL: Do not use. * A VariantList. For example: @@ -1908,23 +1896,7 @@ module Raw { * todo!() * ``` */ - class Item extends @item, Stmt { - /** - * Gets the extended canonical path of this item, if it exists. - * - * Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), - * or `{}::name` for addressable items defined in an anonymous block (and only - * addressable there-in). - */ - string getExtendedCanonicalPath() { item_extended_canonical_paths(this, result) } - - /** - * Gets the crate origin of this item, if it exists. - * - * One of `rustc:`, `repo::` or `lang:`. - */ - string getCrateOrigin() { item_crate_origins(this, result) } - } + class Item extends @item, Stmt, Addressable { } /** * INTERNAL: Do not use. @@ -2933,6 +2905,42 @@ module Raw { Attr getAttr(int index) { underscore_expr_attrs(this, index, result) } } + /** + * INTERNAL: Do not use. + * A Variant. For example: + * ```rust + * todo!() + * ``` + */ + class Variant extends @variant, Addressable { + override string toString() { result = "Variant" } + + /** + * Gets the `index`th attr of this variant (0-based). + */ + Attr getAttr(int index) { variant_attrs(this, index, result) } + + /** + * Gets the expression of this variant, if it exists. + */ + Expr getExpr() { variant_exprs(this, result) } + + /** + * Gets the field list of this variant, if it exists. + */ + FieldList getFieldList() { variant_field_lists(this, result) } + + /** + * Gets the name of this variant, if it exists. + */ + Name getName() { variant_names(this, result) } + + /** + * Gets the visibility of this variant, if it exists. + */ + Visibility getVisibility() { variant_visibilities(this, result) } + } + /** * INTERNAL: Do not use. * A wildcard pattern. For example: 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 b6b1a92a01f7..0b4fa39cd848 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -611,6 +611,11 @@ module Synth { */ TYieldExpr(Raw::YieldExpr id) { constructYieldExpr(id) } + /** + * INTERNAL: Do not use. + */ + class TAddressable = TItem or TVariant; + /** * INTERNAL: Do not use. */ @@ -620,16 +625,16 @@ module Synth { * INTERNAL: Do not use. */ class TAstNode = - TAbi or TArgList or TAssocItem or TAssocItemList or TAttr or TCallable or TClosureBinder or - 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 TParamBase or TParamList or TPat or TPathSegment or - TRecordExprField or TRecordExprFieldList or TRecordField or TRecordPatField or - TRecordPatFieldList or TRename or TResolvable or TRetType or TReturnTypeSyntax 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; + TAbi or TAddressable or TArgList or TAssocItem or TAssocItemList or TAttr or TCallable or + TClosureBinder or 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 TParamBase or TParamList or + TPat or TPathSegment or TRecordExprField or TRecordExprFieldList or TRecordField or + TRecordPatField or TRecordPatFieldList or TRename or TResolvable or TRetType or + TReturnTypeSyntax or TSourceFile or TStmt or TStmtList or TToken or TTokenTree or + TTupleField or TTypeBound or TTypeBoundList or TTypeRef or TUseTree or TUseTreeList or + TVariantList or TVisibility or TWhereClause or TWherePred; /** * INTERNAL: Do not use. @@ -1629,6 +1634,16 @@ module Synth { */ TYieldExpr convertYieldExprFromRaw(Raw::Element e) { result = TYieldExpr(e) } + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TAddressable`, if possible. + */ + TAddressable convertAddressableFromRaw(Raw::Element e) { + result = convertItemFromRaw(e) + or + result = convertVariantFromRaw(e) + } + /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TAssocItem`, if possible. @@ -1650,6 +1665,8 @@ module Synth { TAstNode convertAstNodeFromRaw(Raw::Element e) { result = convertAbiFromRaw(e) or + result = convertAddressableFromRaw(e) + or result = convertArgListFromRaw(e) or result = convertAssocItemFromRaw(e) @@ -1752,8 +1769,6 @@ module Synth { or result = convertUseTreeListFromRaw(e) or - result = convertVariantFromRaw(e) - or result = convertVariantListFromRaw(e) or result = convertVisibilityFromRaw(e) @@ -3003,6 +3018,16 @@ module Synth { */ Raw::Element convertYieldExprToRaw(TYieldExpr e) { e = TYieldExpr(result) } + /** + * INTERNAL: Do not use. + * Converts a synthesized `TAddressable` to a raw DB element, if possible. + */ + Raw::Element convertAddressableToRaw(TAddressable e) { + result = convertItemToRaw(e) + or + result = convertVariantToRaw(e) + } + /** * INTERNAL: Do not use. * Converts a synthesized `TAssocItem` to a raw DB element, if possible. @@ -3024,6 +3049,8 @@ module Synth { Raw::Element convertAstNodeToRaw(TAstNode e) { result = convertAbiToRaw(e) or + result = convertAddressableToRaw(e) + or result = convertArgListToRaw(e) or result = convertAssocItemToRaw(e) @@ -3126,8 +3153,6 @@ module Synth { or result = convertUseTreeListToRaw(e) or - result = convertVariantToRaw(e) - or result = convertVariantListToRaw(e) or result = convertVisibilityToRaw(e) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Variant.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Variant.qll index ec57b2a03da2..b78043e09223 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Variant.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Variant.qll @@ -6,7 +6,7 @@ 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.internal.AddressableImpl::Impl as AddressableImpl import codeql.rust.elements.Attr import codeql.rust.elements.Expr import codeql.rust.elements.FieldList @@ -26,7 +26,7 @@ module Generated { * INTERNAL: Do not reference the `Generated::Variant` class directly. * Use the subclass `Variant`, where the following predicates are available. */ - class Variant extends Synth::TVariant, AstNodeImpl::AstNode { + class Variant extends Synth::TVariant, AddressableImpl::Addressable { override string getAPrimaryQlClass() { result = "Variant" } /** diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index 7c2ba7da58c8..d69d2bce0d8a 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -135,6 +135,7 @@ locatable_locations( @ast_node = @abi +| @addressable | @arg_list | @assoc_item | @assoc_item_list @@ -186,7 +187,6 @@ locatable_locations( | @type_ref | @use_tree | @use_tree_list -| @variant | @variant_list | @visibility | @where_clause @@ -211,6 +211,23 @@ abi_abi_strings( string abi_string: string ref ); +@addressable = + @item +| @variant +; + +#keyset[id] +addressable_extended_canonical_paths( + int id: @addressable ref, + string extended_canonical_path: string ref +); + +#keyset[id] +addressable_crate_origins( + int id: @addressable ref, + string crate_origin: string ref +); + arg_lists( unique int id: @arg_list ); @@ -1010,41 +1027,6 @@ use_tree_list_use_trees( int use_tree: @use_tree ref ); -variants( - unique int id: @variant -); - -#keyset[id, index] -variant_attrs( - int id: @variant ref, - int index: int ref, - int attr: @attr ref -); - -#keyset[id] -variant_exprs( - int id: @variant ref, - int expr: @expr ref -); - -#keyset[id] -variant_field_lists( - int id: @variant ref, - int field_list: @field_list ref -); - -#keyset[id] -variant_names( - int id: @variant ref, - int name: @name ref -); - -#keyset[id] -variant_visibilities( - int id: @variant ref, - int visibility: @visibility ref -); - variant_lists( unique int id: @variant_list ); @@ -1713,18 +1695,6 @@ infer_types( | @use ; -#keyset[id] -item_extended_canonical_paths( - int id: @item ref, - string extended_canonical_path: string ref -); - -#keyset[id] -item_crate_origins( - int id: @item ref, - string crate_origin: string ref -); - @labelable_expr = @block_expr | @looping_expr @@ -2443,6 +2413,41 @@ underscore_expr_attrs( int attr: @attr ref ); +variants( + unique int id: @variant +); + +#keyset[id, index] +variant_attrs( + int id: @variant ref, + int index: int ref, + int attr: @attr ref +); + +#keyset[id] +variant_exprs( + int id: @variant ref, + int expr: @expr ref +); + +#keyset[id] +variant_field_lists( + int id: @variant ref, + int field_list: @field_list ref +); + +#keyset[id] +variant_names( + int id: @variant ref, + int name: @name ref +); + +#keyset[id] +variant_visibilities( + int id: @variant ref, + int visibility: @visibility ref +); + wildcard_pats( unique int id: @wildcard_pat ); diff --git a/rust/ql/test/extractor-tests/canonical_path/anonymous.rs b/rust/ql/test/extractor-tests/canonical_path/anonymous.rs new file mode 100644 index 000000000000..81e32169bfb9 --- /dev/null +++ b/rust/ql/test/extractor-tests/canonical_path/anonymous.rs @@ -0,0 +1,36 @@ +use super::regular::Trait; + +fn canonicals() { + struct OtherStruct; + + trait OtherTrait { + fn g(&self); + } + + impl OtherTrait for OtherStruct { + fn g(&self) {} + } + + impl OtherTrait for crate::regular::Struct { + fn g(&self) {} + } + + impl crate::regular::Trait for OtherStruct { + fn f(&self) {} + } + + fn nested() { + struct OtherStruct; + } + + fn usage() { + let s = OtherStruct {}; + s.f(); + s.g(); + nested(); + } +} + +fn other() { + struct OtherStruct; +} diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected index 94bcc7379d95..0b973174828c 100644 --- a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected +++ b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected @@ -1,70 +1,89 @@ canonicalPaths -| canonical_paths.rs:1:1:34:1 | mod a | 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 Trait | repo::test | crate::canonical_paths::a::Trait | -| canonical_paths.rs:6:9:6:20 | fn f | repo::test | crate::canonical_paths::a::Trait::f | -| canonical_paths.rs:9:5:11:5 | impl Trait for Struct { ... } | None | None | -| canonical_paths.rs:10:9:10:22 | fn f | repo::test | ::f | -| canonical_paths.rs:13:5:15:5 | impl Struct { ... } | None | None | -| canonical_paths.rs:14:9:14:22 | fn g | repo::test | ::g | -| canonical_paths.rs:17:5:19:5 | trait TraitWithBlanketImpl | repo::test | crate::canonical_paths::a::TraitWithBlanketImpl | -| canonical_paths.rs:18:9:18:20 | fn h | repo::test | crate::canonical_paths::a::TraitWithBlanketImpl::h | -| canonical_paths.rs:21:5:23:5 | impl TraitWithBlanketImpl for T { ... } | None | None | -| canonical_paths.rs:22:9:22:22 | fn h | repo::test | <_ as crate::canonical_paths::a::TraitWithBlanketImpl>::h | -| canonical_paths.rs:25:5:25:16 | fn free | repo::test | crate::canonical_paths::a::free | -| canonical_paths.rs:27:5:33:5 | fn usage | repo::test | crate::canonical_paths::a::usage | -| canonical_paths.rs:36:1:73:1 | mod without | repo::test | crate::canonical_paths::without | -| canonical_paths.rs:37:5:37:24 | Use | None | None | -| canonical_paths.rs:39:5:68:5 | fn 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 OtherTrait | repo::test | {34}::OtherTrait | -| canonical_paths.rs:43:13:43:24 | fn g | repo::test | {34}::OtherTrait::g | -| canonical_paths.rs:46:9:48:9 | impl OtherTrait for OtherStruct { ... } | None | None | -| canonical_paths.rs:47:13:47:26 | fn g | repo::test | <{34}::OtherStruct as {34}::OtherTrait>::g | -| canonical_paths.rs:50:9:52:9 | impl OtherTrait for ...::Struct { ... } | None | None | -| canonical_paths.rs:51:13:51:26 | fn g | repo::test | ::g | -| canonical_paths.rs:54:9:56:9 | impl ...::Trait for OtherStruct { ... } | None | None | -| canonical_paths.rs:55:13:55:26 | fn f | repo::test | <{34}::OtherStruct as crate::canonical_paths::a::Trait>::f | -| canonical_paths.rs:58:9:60:9 | fn nested | repo::test | {34}::nested | -| canonical_paths.rs:59:13:59:31 | Struct | repo::test | {35}::OtherStruct | -| canonical_paths.rs:62:9:67:9 | fn usage | repo::test | {34}::usage | -| canonical_paths.rs:70:5:72:5 | fn 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 | mod canonical_paths | repo::test | crate::canonical_paths | +| anonymous.rs:1:1:1:26 | Use | None | None | +| anonymous.rs:3:1:32:1 | fn canonicals | repo::test | crate::anonymous::canonicals | +| anonymous.rs:4:5:4:23 | Struct | repo::test | {0}::OtherStruct | +| anonymous.rs:6:5:8:5 | trait OtherTrait | repo::test | {0}::OtherTrait | +| anonymous.rs:7:9:7:20 | fn g | repo::test | {0}::OtherTrait::g | +| anonymous.rs:10:5:12:5 | impl OtherTrait for OtherStruct { ... } | None | None | +| anonymous.rs:11:9:11:22 | fn g | repo::test | <{0}::OtherStruct as {0}::OtherTrait>::g | +| anonymous.rs:14:5:16:5 | impl OtherTrait for ...::Struct { ... } | None | None | +| anonymous.rs:15:9:15:22 | fn g | repo::test | ::g | +| anonymous.rs:18:5:20:5 | impl ...::Trait for OtherStruct { ... } | None | None | +| anonymous.rs:19:9:19:22 | fn f | repo::test | <{0}::OtherStruct as crate::regular::Trait>::f | +| anonymous.rs:22:5:24:5 | fn nested | repo::test | {0}::nested | +| anonymous.rs:23:9:23:27 | Struct | repo::test | {1}::OtherStruct | +| anonymous.rs:26:5:31:5 | fn usage | repo::test | {0}::usage | +| anonymous.rs:34:1:36:1 | fn other | repo::test | crate::anonymous::other | +| anonymous.rs:35:5:35:23 | Struct | repo::test | {36}::OtherStruct | +| lib.rs:1:1:1:14 | mod anonymous | repo::test | crate::anonymous | +| lib.rs:2:1:2:12 | mod regular | repo::test | crate::regular | +| regular.rs:1:1:2:18 | Struct | repo::test | crate::regular::Struct | +| regular.rs:4:1:6:1 | trait Trait | repo::test | crate::regular::Trait | +| regular.rs:5:5:5:16 | fn f | repo::test | crate::regular::Trait::f | +| regular.rs:8:1:10:1 | impl Trait for Struct { ... } | None | None | +| regular.rs:9:5:9:18 | fn f | repo::test | ::f | +| regular.rs:12:1:14:1 | impl Struct { ... } | None | None | +| regular.rs:13:5:13:18 | fn g | repo::test | ::g | +| regular.rs:16:1:18:1 | trait TraitWithBlanketImpl | repo::test | crate::regular::TraitWithBlanketImpl | +| regular.rs:17:5:17:16 | fn h | repo::test | crate::regular::TraitWithBlanketImpl::h | +| regular.rs:20:1:22:1 | impl TraitWithBlanketImpl for T { ... } | None | None | +| regular.rs:21:5:21:18 | fn h | repo::test | <_ as crate::regular::TraitWithBlanketImpl>::h | +| regular.rs:24:1:24:12 | fn free | repo::test | crate::regular::free | +| regular.rs:26:1:32:1 | fn usage | repo::test | crate::regular::usage | +| regular.rs:34:1:38:1 | enum MyEnum | repo::test | crate::regular::MyEnum | +| regular.rs:40:1:46:1 | fn enum_qualified_usage | repo::test | crate::regular::enum_qualified_usage | +| regular.rs:48:1:55:1 | fn enum_unqualified_usage | repo::test | crate::regular::enum_unqualified_usage | +| regular.rs:51:5:51:18 | Use | None | None | 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 | ...::a | repo::test | crate::canonical_paths::a | -| canonical_paths.rs:37:9:37:23 | ...::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 | ...::canonical_paths | repo::test | crate::canonical_paths | -| canonical_paths.rs:50:29:50:53 | ...::a | repo::test | crate::canonical_paths::a | -| canonical_paths.rs:50:29:50:61 | ...::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 | ...::canonical_paths | repo::test | crate::canonical_paths | -| canonical_paths.rs:54:14:54:38 | ...::a | repo::test | crate::canonical_paths::a | -| canonical_paths.rs:54:14:54:45 | ...::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 | +| anonymous.rs:1:5:1:9 | super | None | None | +| anonymous.rs:1:5:1:18 | ...::regular | repo::test | crate::regular | +| anonymous.rs:1:5:1:25 | ...::Trait | repo::test | crate::regular::Trait | +| anonymous.rs:10:10:10:19 | OtherTrait | repo::test | {0}::OtherTrait | +| anonymous.rs:10:25:10:35 | OtherStruct | repo::test | {0}::OtherStruct | +| anonymous.rs:14:10:14:19 | OtherTrait | repo::test | {0}::OtherTrait | +| anonymous.rs:14:25:14:29 | crate | None | None | +| anonymous.rs:14:25:14:38 | ...::regular | repo::test | crate::regular | +| anonymous.rs:14:25:14:46 | ...::Struct | repo::test | crate::regular::Struct | +| anonymous.rs:18:10:18:14 | crate | None | None | +| anonymous.rs:18:10:18:23 | ...::regular | repo::test | crate::regular | +| anonymous.rs:18:10:18:30 | ...::Trait | repo::test | crate::regular::Trait | +| anonymous.rs:18:36:18:46 | OtherStruct | repo::test | {0}::OtherStruct | +| anonymous.rs:27:17:27:27 | OtherStruct | repo::test | {0}::OtherStruct | +| anonymous.rs:28:9:28:9 | s | None | None | +| anonymous.rs:28:9:28:13 | ... .f(...) | repo::test | <{0}::OtherStruct as crate::regular::Trait>::f | +| anonymous.rs:29:9:29:9 | s | None | None | +| anonymous.rs:29:9:29:13 | ... .g(...) | repo::test | <{0}::OtherStruct as {0}::OtherTrait>::g | +| anonymous.rs:30:9:30:14 | nested | repo::test | {0}::nested | +| regular.rs:1:3:1:8 | derive | None | None | +| regular.rs:8:6:8:10 | Trait | repo::test | crate::regular::Trait | +| regular.rs:8:16:8:21 | Struct | repo::test | crate::regular::Struct | +| regular.rs:12:6:12:11 | Struct | repo::test | crate::regular::Struct | +| regular.rs:20:9:20:10 | Eq | lang:core | crate::cmp::Eq | +| regular.rs:20:13:20:32 | TraitWithBlanketImpl | repo::test | crate::regular::TraitWithBlanketImpl | +| regular.rs:20:38:20:38 | T | None | None | +| regular.rs:27:13:27:18 | Struct | repo::test | crate::regular::Struct | +| regular.rs:28:5:28:5 | s | None | None | +| regular.rs:28:5:28:9 | ... .f(...) | repo::test | ::f | +| regular.rs:29:5:29:5 | s | None | None | +| regular.rs:29:5:29:9 | ... .g(...) | repo::test | ::g | +| regular.rs:30:5:30:5 | s | None | None | +| regular.rs:30:5:30:9 | ... .h(...) | repo::test | <_ as crate::regular::TraitWithBlanketImpl>::h | +| regular.rs:31:5:31:8 | free | repo::test | crate::regular::free | +| regular.rs:36:14:36:18 | usize | None | None | +| regular.rs:37:19:37:23 | usize | None | None | +| regular.rs:41:9:41:14 | Option | lang:core | crate::option::Option | +| regular.rs:41:9:41:26 | ...::None::<...> | lang:core | crate::option::Option::None | +| regular.rs:42:9:42:14 | Option | lang:core | crate::option::Option | +| regular.rs:42:9:42:20 | ...::Some | lang:core | crate::option::Option::Some | +| regular.rs:43:9:43:14 | MyEnum | repo::test | crate::regular::MyEnum | +| regular.rs:43:9:43:24 | ...::Variant1 | repo::test | crate::regular::MyEnum::Variant1 | +| regular.rs:44:9:44:14 | MyEnum | repo::test | crate::regular::MyEnum | +| regular.rs:44:9:44:24 | ...::Variant2 | repo::test | crate::regular::MyEnum::Variant2 | +| regular.rs:45:9:45:14 | MyEnum | repo::test | crate::regular::MyEnum | +| regular.rs:45:9:45:24 | ...::Variant3 | repo::test | crate::regular::MyEnum::Variant3 | +| regular.rs:49:9:49:18 | None::<...> | lang:core | crate::option::Option::None | +| regular.rs:50:9:50:12 | Some | lang:core | crate::option::Option::Some | +| regular.rs:51:9:51:14 | MyEnum | repo::test | crate::regular::MyEnum | +| regular.rs:52:9:52:16 | Variant1 | repo::test | crate::regular::MyEnum::Variant1 | +| regular.rs:53:9:53:16 | Variant2 | repo::test | crate::regular::MyEnum::Variant2 | +| regular.rs:54:9:54:16 | Variant3 | repo::test | crate::regular::MyEnum::Variant3 | diff --git a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs b/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs deleted file mode 100644 index 7444903dc01f..000000000000 --- a/rust/ql/test/extractor-tests/canonical_path/canonical_paths.rs +++ /dev/null @@ -1,73 +0,0 @@ -mod a { - #[derive(Eq, PartialEq)] - pub struct Struct; - - pub trait Trait { - fn f(&self); - } - - impl Trait for Struct { - fn f(&self) {} - } - - impl Struct { - fn g(&self) {} - } - - trait TraitWithBlanketImpl { - fn h(&self); - } - - 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; - - trait OtherTrait { - fn g(&self); - } - - impl OtherTrait for OtherStruct { - fn g(&self) {} - } - - impl OtherTrait for crate::canonical_paths::a::Struct { - fn g(&self) {} - } - - impl crate::canonical_paths::a::Trait for OtherStruct { - fn f(&self) {} - } - - fn nested() { - struct OtherStruct; - } - - fn usage() { - let s = OtherStruct {}; - s.f(); - s.g(); - nested(); - } - } - - fn other() { - struct OtherStruct; - } -} diff --git a/rust/ql/test/extractor-tests/canonical_path/regular.rs b/rust/ql/test/extractor-tests/canonical_path/regular.rs new file mode 100644 index 000000000000..ac06a12d24aa --- /dev/null +++ b/rust/ql/test/extractor-tests/canonical_path/regular.rs @@ -0,0 +1,55 @@ +#[derive(Eq, PartialEq)] +pub struct Struct; + +pub trait Trait { + fn f(&self); +} + +impl Trait for Struct { + fn f(&self) {} +} + +impl Struct { + fn g(&self) {} +} + +trait TraitWithBlanketImpl { + fn h(&self); +} + +impl TraitWithBlanketImpl for T { + fn h(&self) {} +} + +fn free() {} + +fn usage() { + let s = Struct {}; + s.f(); + s.g(); + s.h(); + free(); +} + +enum MyEnum { + Variant1, + Variant2(usize), + Variant3 { x: usize }, +} + +fn enum_qualified_usage() { + _ = Option::None::<()>; + _ = Option::Some(0); + _ = MyEnum::Variant1; + _ = MyEnum::Variant2(0); + _ = MyEnum::Variant3 { x: 1 }; +} + +fn enum_unqualified_usage() { + _ = None::<()>; + _ = Some(0); + use MyEnum::*; + _ = Variant1; + _ = Variant2(0); + _ = Variant3 { x: 1 }; +} diff --git a/rust/ql/test/extractor-tests/generated/Variant/Variant.ql b/rust/ql/test/extractor-tests/generated/Variant/Variant.ql index 2cbcd20cbf06..92ebcbe55eed 100644 --- a/rust/ql/test/extractor-tests/generated/Variant/Variant.ql +++ b/rust/ql/test/extractor-tests/generated/Variant/Variant.ql @@ -3,15 +3,22 @@ import codeql.rust.elements import TestUtils from - Variant x, int getNumberOfAttrs, string hasExpr, string hasFieldList, string hasName, - string hasVisibility + Variant x, string hasExtendedCanonicalPath, string hasCrateOrigin, int getNumberOfAttrs, + string hasExpr, string hasFieldList, string hasName, string hasVisibility where toBeTested(x) and not x.isUnknown() and + ( + if x.hasExtendedCanonicalPath() + then hasExtendedCanonicalPath = "yes" + else hasExtendedCanonicalPath = "no" + ) and + (if x.hasCrateOrigin() then hasCrateOrigin = "yes" else hasCrateOrigin = "no") and getNumberOfAttrs = x.getNumberOfAttrs() and (if x.hasExpr() then hasExpr = "yes" else hasExpr = "no") and (if x.hasFieldList() then hasFieldList = "yes" else hasFieldList = "no") and (if x.hasName() then hasName = "yes" else hasName = "no") and if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no" -select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasExpr:", hasExpr, "hasFieldList:", hasFieldList, +select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin, + "getNumberOfAttrs:", getNumberOfAttrs, "hasExpr:", hasExpr, "hasFieldList:", hasFieldList, "hasName:", hasName, "hasVisibility:", hasVisibility diff --git a/rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.expected b/rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql b/rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql new file mode 100644 index 000000000000..0acfd9827fee --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from Variant x +where toBeTested(x) and not x.isUnknown() +select x, x.getCrateOrigin() diff --git a/rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.expected b/rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql b/rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql new file mode 100644 index 000000000000..ad8aaf86a5cf --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from Variant x +where toBeTested(x) and not x.isUnknown() +select x, x.getExtendedCanonicalPath() diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index 9e857ad7b0f2..7f9588425cef 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -1741,7 +1741,7 @@ class _: """ -@annotate(Variant) +@annotate(Variant, replace_bases={AstNode: Addressable}) class _: """ A Variant. For example: @@ -1852,11 +1852,6 @@ class FormatArgument(Locatable): parent: Format variable: optional[FormatTemplateVariableAccess] | child -@annotate(Item) +@annotate(Item, add_bases=(Addressable,)) class _: - extended_canonical_path: optional[string] | desc(""" - Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), - or `{}::name` for addressable items defined in an anonymous block (and only - addressable there-in). - """) | rust.detach | ql.internal - crate_origin: optional[string] | desc("One of `rustc:`, `repo::` or `lang:`.") | rust.detach | ql.internal + pass diff --git a/rust/schema/prelude.py b/rust/schema/prelude.py index 60de626e59cb..ffd65959b5ab 100644 --- a/rust/schema/prelude.py +++ b/rust/schema/prelude.py @@ -73,6 +73,20 @@ class Callable(AstNode): attrs: list["Attr"] | child +class Addressable(AstNode): + """ + Something that can be addressed by a path. + + TODO: This does not yet include all possible cases. + """ + extended_canonical_path: optional[string] | desc(""" + Either a canonical path (see https://doc.rust-lang.org/reference/paths.html#canonical-paths), + or `{}::name` for addressable items defined in an anonymous block (and only + addressable there-in). + """) | rust.detach | ql.internal + crate_origin: optional[string] | desc("One of `rustc:`, `repo::` or `lang:`.") | rust.detach | ql.internal + + class Resolvable(AstNode): """ Either a `Path`, or a `MethodCallExpr`.