mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: add extended canonical paths on enum variants
This commit is contained in:
2
rust/extractor/src/generated/.generated.list
generated
2
rust/extractor/src/generated/.generated.list
generated
@@ -1,2 +1,2 @@
|
||||
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
|
||||
top.rs cdfb9890318d847e6db320abd8b9e9939524ecc47bcdc8491b9c8253bd3178c2 cdfb9890318d847e6db320abd8b9e9939524ecc47bcdc8491b9c8253bd3178c2
|
||||
top.rs 97394877b36188b1ec327272cca896b070c68ae2620781aa62f43afd405b871a 97394877b36188b1ec327272cca896b070c68ae2620781aa62f43afd405b871a
|
||||
|
||||
357
rust/extractor/src/generated/top.rs
generated
357
rust/extractor/src/generated/top.rs
generated
@@ -200,6 +200,51 @@ impl From<trap::Label<Abi>> for trap::Label<Locatable> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Addressable {
|
||||
_unused: ()
|
||||
}
|
||||
|
||||
impl Addressable {
|
||||
pub fn emit_extended_canonical_path(id: trap::Label<Self>, 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<Self>, 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<trap::Label<Addressable>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Addressable>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Addressable is a subclass of AstNode
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Addressable>> for trap::Label<Element> {
|
||||
fn from(value: trap::Label<Addressable>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Addressable is a subclass of Element
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Addressable>> for trap::Label<Locatable> {
|
||||
fn from(value: trap::Label<Addressable>) -> 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<ArgList>,
|
||||
@@ -2817,72 +2862,6 @@ impl From<trap::Label<UseTreeList>> for trap::Label<Locatable> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Variant {
|
||||
pub id: trap::TrapId<Variant>,
|
||||
pub attrs: Vec<trap::Label<Attr>>,
|
||||
pub expr: Option<trap::Label<Expr>>,
|
||||
pub field_list: Option<trap::Label<FieldList>>,
|
||||
pub name: Option<trap::Label<Name>>,
|
||||
pub visibility: Option<trap::Label<Visibility>>,
|
||||
}
|
||||
|
||||
impl trap::TrapEntry for Variant {
|
||||
fn extract_id(&mut self) -> trap::TrapId<Self> {
|
||||
std::mem::replace(&mut self.id, trap::TrapId::Star)
|
||||
}
|
||||
|
||||
fn emit(self, id: trap::Label<Self>, 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<trap::Label<Variant>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Variant>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Variant is a subclass of AstNode
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Variant>> for trap::Label<Element> {
|
||||
fn from(value: trap::Label<Variant>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Variant is a subclass of Element
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Variant>> for trap::Label<Locatable> {
|
||||
fn from(value: trap::Label<Variant>) -> 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<VariantList>,
|
||||
@@ -5119,19 +5098,19 @@ pub struct Item {
|
||||
_unused: ()
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn emit_extended_canonical_path(id: trap::Label<Self>, 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<Self>, 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<trap::Label<Item>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Item>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Item is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Item>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Item>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Item is a subclass of AstNode
|
||||
@@ -7914,6 +7893,81 @@ impl From<trap::Label<UnderscoreExpr>> for trap::Label<Locatable> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Variant {
|
||||
pub id: trap::TrapId<Variant>,
|
||||
pub attrs: Vec<trap::Label<Attr>>,
|
||||
pub expr: Option<trap::Label<Expr>>,
|
||||
pub field_list: Option<trap::Label<FieldList>>,
|
||||
pub name: Option<trap::Label<Name>>,
|
||||
pub visibility: Option<trap::Label<Visibility>>,
|
||||
}
|
||||
|
||||
impl trap::TrapEntry for Variant {
|
||||
fn extract_id(&mut self) -> trap::TrapId<Self> {
|
||||
std::mem::replace(&mut self.id, trap::TrapId::Star)
|
||||
}
|
||||
|
||||
fn emit(self, id: trap::Label<Self>, 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<trap::Label<Variant>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Variant>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Variant is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Variant>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Variant>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Variant is a subclass of AstNode
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Variant>> for trap::Label<Element> {
|
||||
fn from(value: trap::Label<Variant>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Variant is a subclass of Element
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Variant>> for trap::Label<Locatable> {
|
||||
fn from(value: trap::Label<Variant>) -> 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 WhileExpr {
|
||||
pub id: trap::TrapId<WhileExpr>,
|
||||
@@ -8289,6 +8343,15 @@ impl trap::TrapClass for Const {
|
||||
fn class_name() -> &'static str { "Const" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Const>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Const>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Const is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Const>> for trap::Label<AssocItem> {
|
||||
fn from(value: trap::Label<Const>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Const is a subclass of AssocItem
|
||||
@@ -8386,6 +8449,15 @@ impl trap::TrapClass for Enum {
|
||||
fn class_name() -> &'static str { "Enum" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Enum>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Enum>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Enum>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Enum>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Enum is a subclass of AstNode
|
||||
@@ -8466,6 +8538,15 @@ impl trap::TrapClass for ExternBlock {
|
||||
fn class_name() -> &'static str { "ExternBlock" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<ExternBlock>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<ExternBlock>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme ExternBlock is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<ExternBlock>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<ExternBlock>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme ExternBlock is a subclass of AstNode
|
||||
@@ -8546,6 +8627,15 @@ impl trap::TrapClass for ExternCrate {
|
||||
fn class_name() -> &'static str { "ExternCrate" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<ExternCrate>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<ExternCrate>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme ExternCrate is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<ExternCrate>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<ExternCrate>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme ExternCrate is a subclass of AstNode
|
||||
@@ -8666,6 +8756,15 @@ impl trap::TrapClass for Function {
|
||||
fn class_name() -> &'static str { "Function" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Function>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Function>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Function is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Function>> for trap::Label<AssocItem> {
|
||||
fn from(value: trap::Label<Function>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Function is a subclass of AssocItem
|
||||
@@ -8797,6 +8896,15 @@ impl trap::TrapClass for Impl {
|
||||
fn class_name() -> &'static str { "Impl" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Impl>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Impl>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Impl is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Impl>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Impl>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Impl is a subclass of AstNode
|
||||
@@ -8879,6 +8987,15 @@ impl trap::TrapClass for MacroCall {
|
||||
fn class_name() -> &'static str { "MacroCall" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroCall>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<MacroCall>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroCall is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroCall>> for trap::Label<AssocItem> {
|
||||
fn from(value: trap::Label<MacroCall>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroCall is a subclass of AssocItem
|
||||
@@ -8981,6 +9098,15 @@ impl trap::TrapClass for MacroDef {
|
||||
fn class_name() -> &'static str { "MacroDef" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroDef>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<MacroDef>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroDef is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroDef>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<MacroDef>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroDef is a subclass of AstNode
|
||||
@@ -9061,6 +9187,15 @@ impl trap::TrapClass for MacroRules {
|
||||
fn class_name() -> &'static str { "MacroRules" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroRules>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<MacroRules>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroRules is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroRules>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<MacroRules>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroRules is a subclass of AstNode
|
||||
@@ -9234,6 +9369,15 @@ impl trap::TrapClass for Module {
|
||||
fn class_name() -> &'static str { "Module" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Module>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Module>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Module is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Module>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Module>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Module is a subclass of AstNode
|
||||
@@ -9398,6 +9542,15 @@ impl trap::TrapClass for Static {
|
||||
fn class_name() -> &'static str { "Static" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Static>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Static>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Static is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Static>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Static>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Static is a subclass of AstNode
|
||||
@@ -9495,6 +9648,15 @@ impl trap::TrapClass for Struct {
|
||||
fn class_name() -> &'static str { "Struct" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Struct>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Struct>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Struct>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Struct>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Struct is a subclass of AstNode
|
||||
@@ -9595,6 +9757,15 @@ impl trap::TrapClass for Trait {
|
||||
fn class_name() -> &'static str { "Trait" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Trait>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Trait>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Trait is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Trait>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Trait>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Trait is a subclass of AstNode
|
||||
@@ -9683,6 +9854,15 @@ impl trap::TrapClass for TraitAlias {
|
||||
fn class_name() -> &'static str { "TraitAlias" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<TraitAlias>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<TraitAlias>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme TraitAlias is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<TraitAlias>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<TraitAlias>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme TraitAlias is a subclass of AstNode
|
||||
@@ -9779,6 +9959,15 @@ impl trap::TrapClass for TypeAlias {
|
||||
fn class_name() -> &'static str { "TypeAlias" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<TypeAlias>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<TypeAlias>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme TypeAlias is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<TypeAlias>> for trap::Label<AssocItem> {
|
||||
fn from(value: trap::Label<TypeAlias>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme TypeAlias is a subclass of AssocItem
|
||||
@@ -9885,6 +10074,15 @@ impl trap::TrapClass for Union {
|
||||
fn class_name() -> &'static str { "Union" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Union>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Union>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Union is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Union>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Union>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Union is a subclass of AstNode
|
||||
@@ -9961,6 +10159,15 @@ impl trap::TrapClass for Use {
|
||||
fn class_name() -> &'static str { "Use" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<Use>> for trap::Label<Addressable> {
|
||||
fn from(value: trap::Label<Use>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Use is a subclass of Addressable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<Use>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<Use>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme Use is a subclass of AstNode
|
||||
|
||||
@@ -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<String> {
|
||||
// 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<T: AstNode>(&self, item: impl AddressableHir<T>) -> 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<T: AddressableAst + HasName>(
|
||||
&mut self,
|
||||
item: &T,
|
||||
label: Label<generated::Item>,
|
||||
label: Label<generated::Addressable>,
|
||||
) {
|
||||
(|| {
|
||||
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<generated::Variant>,
|
||||
) {
|
||||
(|| {
|
||||
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(())
|
||||
})();
|
||||
}
|
||||
|
||||
23
rust/ql/.generated.list
generated
23
rust/ql/.generated.list
generated
@@ -1,5 +1,6 @@
|
||||
lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll a2d9717410e73aca512cad3af633700158ddd80b1c07dfd6ebe0f84723b4ac5b 3cfd6ae768958db3a4d633b4d781a8f4be80eb7a0d2ee871773584128e4551fd
|
||||
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/LetElse.qll 85d16cb9cb2162493a9bacfe4b9e6a3b325d9466175b6d1a8e649bdf2191b864 c268d0878e9f82e8ede930b3825745c39ab8cd4db818eb9be6dc5ca49bee7579
|
||||
@@ -156,7 +157,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
|
||||
@@ -167,6 +168,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
|
||||
@@ -453,6 +455,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
|
||||
@@ -510,7 +513,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/LetElse.qll 7ca556118b5446bfc85abba8f0edd4970e029b30d414ea824a1b5f568310a76c a403540881336f9d0269cbcdb4b87107a17ab234a985247dc52a380f150a1641
|
||||
@@ -549,7 +552,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 c1eca840f6c97dc3c7fec5deaf1be98c17558610ffc37b503571779afdadc912 9564f6ae3803505c2bc086b76e43570127a13374655d2013c77ce1863e0c1397
|
||||
lib/codeql/rust/elements/internal/generated/ParentChild.qll f82255af6c746fd074d9a1128ed481765d23b47676c7d0cca9c36b31ff1875be 80b2796553686333e8170dc2dcd6dd878e623dbdfdaef652b500b5652f0bb374
|
||||
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
|
||||
lib/codeql/rust/elements/internal/generated/Path.qll f2b1be2f8f44001a6533533c978c4a9a8b7d64838d6f39eef5f0c0e7890611b8 d724a00a38f42429ffa8fb3bffbb5ec69e16a32ceeeb1d1f026fc7adf87424a8
|
||||
lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140
|
||||
@@ -562,7 +565,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 d679e866776a927f61d62ba980203e1142454606bdac69cc9b6720679ca5bbdd f47922df7f8c8efba0e2e5adde030247e43f02e9df7d263096c697bfe65c4277
|
||||
lib/codeql/rust/elements/internal/generated/Raw.qll 57c2c6a750c469f7db059660f02e4903b50c5b2f99f23f972000567dbf14e34b e16ceed92616c66b8e8b553b7043966c371154e0c75c12a02083e3b3487695db
|
||||
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
|
||||
@@ -588,7 +591,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 1ba88215c3f0640558a644534b954e4b93acb15a0f51a1e4887230f451718aa9 747eb3bec1c7245e59ea2b500604f5b4e614e4f061473d1a22fa398ee48ba080
|
||||
lib/codeql/rust/elements/internal/generated/Synth.qll 93dd2fbc5b86714883e8b02d3dea6f4364f881a38473bc46dab4e1bcb9dd99a7 3514ae3251ad06636e1e648331943e62a26b5e6a439f51e44d4c11b94e02013b
|
||||
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
|
||||
@@ -614,7 +617,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
|
||||
@@ -623,7 +626,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 173d5ffbcc2874757033caab37559e84dbcbfed319730f8e41a4e9e10b146835 173d5ffbcc2874757033caab37559e84dbcbfed319730f8e41a4e9e10b146835
|
||||
lib/codeql/rust/elements.qll 8924e84ab56326a81e5147202d31cd2ba50f73d35353d9f145da7a4a6c06b243 8924e84ab56326a81e5147202d31cd2ba50f73d35353d9f145da7a4a6c06b243
|
||||
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
|
||||
@@ -1134,9 +1137,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
|
||||
|
||||
5
rust/ql/.gitattributes
generated
vendored
5
rust/ql/.gitattributes
generated
vendored
@@ -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
|
||||
@@ -169,6 +170,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
|
||||
@@ -455,6 +457,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
|
||||
@@ -1138,7 +1141,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
|
||||
|
||||
1
rust/ql/lib/codeql/rust/elements.qll
generated
1
rust/ql/lib/codeql/rust/elements.qll
generated
@@ -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
|
||||
|
||||
14
rust/ql/lib/codeql/rust/elements/Addressable.qll
generated
Normal file
14
rust/ql/lib/codeql/rust/elements/Addressable.qll
generated
Normal file
@@ -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;
|
||||
1
rust/ql/lib/codeql/rust/elements/Item.qll
generated
1
rust/ql/lib/codeql/rust/elements/Item.qll
generated
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
private import internal.ItemImpl
|
||||
import codeql.rust.elements.Addressable
|
||||
import codeql.rust.elements.Stmt
|
||||
|
||||
/**
|
||||
|
||||
2
rust/ql/lib/codeql/rust/elements/Variant.qll
generated
2
rust/ql/lib/codeql/rust/elements/Variant.qll
generated
@@ -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
|
||||
|
||||
21
rust/ql/lib/codeql/rust/elements/internal/AddressableImpl.qll
generated
Normal file
21
rust/ql/lib/codeql/rust/elements/internal/AddressableImpl.qll
generated
Normal file
@@ -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 { }
|
||||
}
|
||||
58
rust/ql/lib/codeql/rust/elements/internal/generated/Addressable.qll
generated
Normal file
58
rust/ql/lib/codeql/rust/elements/internal/generated/Addressable.qll
generated
Normal file
@@ -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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.
|
||||
* 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()) }
|
||||
}
|
||||
}
|
||||
@@ -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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.
|
||||
* 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 { }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -1117,37 +1132,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
|
||||
) {
|
||||
@@ -1898,14 +1882,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)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -2758,6 +2746,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 getImmediateChildOfWhileExpr(WhileExpr e, int index, string partialPredicateCall) {
|
||||
exists(int b, int bExpr, int n, int nAttr, int nCondition, int nLabel, int nLoopBody |
|
||||
b = 0 and
|
||||
@@ -3641,8 +3662,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)
|
||||
@@ -3795,6 +3814,8 @@ private module Impl {
|
||||
or
|
||||
result = getImmediateChildOfUnderscoreExpr(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfVariant(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfWhileExpr(e, index, partialAccessor)
|
||||
or
|
||||
result = getImmediateChildOfWildcardPat(e, index, partialAccessor)
|
||||
|
||||
@@ -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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.
|
||||
*/
|
||||
string getCrateOrigin() { addressable_crate_origins(this, result) }
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
* A ArgList. For example:
|
||||
@@ -1048,42 +1072,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:
|
||||
@@ -2057,23 +2045,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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.
|
||||
*/
|
||||
string getCrateOrigin() { item_crate_origins(this, result) }
|
||||
}
|
||||
class Item extends @item, Stmt, Addressable { }
|
||||
|
||||
/**
|
||||
* INTERNAL: Do not use.
|
||||
@@ -3067,6 +3039,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 WhileExpr. For example:
|
||||
|
||||
@@ -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 TParam 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
|
||||
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;
|
||||
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 TParam 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 TSelfParam 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.
|
||||
@@ -1614,6 +1619,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.
|
||||
@@ -1635,6 +1650,8 @@ module Synth {
|
||||
TAstNode convertAstNodeFromRaw(Raw::Element e) {
|
||||
result = convertAbiFromRaw(e)
|
||||
or
|
||||
result = convertAddressableFromRaw(e)
|
||||
or
|
||||
result = convertArgListFromRaw(e)
|
||||
or
|
||||
result = convertAssocItemFromRaw(e)
|
||||
@@ -1739,8 +1756,6 @@ module Synth {
|
||||
or
|
||||
result = convertUseTreeListFromRaw(e)
|
||||
or
|
||||
result = convertVariantFromRaw(e)
|
||||
or
|
||||
result = convertVariantListFromRaw(e)
|
||||
or
|
||||
result = convertVisibilityFromRaw(e)
|
||||
@@ -2964,6 +2979,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.
|
||||
@@ -2985,6 +3010,8 @@ module Synth {
|
||||
Raw::Element convertAstNodeToRaw(TAstNode e) {
|
||||
result = convertAbiToRaw(e)
|
||||
or
|
||||
result = convertAddressableToRaw(e)
|
||||
or
|
||||
result = convertArgListToRaw(e)
|
||||
or
|
||||
result = convertAssocItemToRaw(e)
|
||||
@@ -3089,8 +3116,6 @@ module Synth {
|
||||
or
|
||||
result = convertUseTreeListToRaw(e)
|
||||
or
|
||||
result = convertVariantToRaw(e)
|
||||
or
|
||||
result = convertVariantListToRaw(e)
|
||||
or
|
||||
result = convertVisibilityToRaw(e)
|
||||
|
||||
@@ -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" }
|
||||
|
||||
/**
|
||||
|
||||
@@ -135,6 +135,7 @@ locatable_locations(
|
||||
|
||||
@ast_node =
|
||||
@abi
|
||||
| @addressable
|
||||
| @arg_list
|
||||
| @assoc_item
|
||||
| @assoc_item_list
|
||||
@@ -187,7 +188,6 @@ locatable_locations(
|
||||
| @type_ref
|
||||
| @use_tree
|
||||
| @use_tree_list
|
||||
| @variant
|
||||
| @variant_list
|
||||
| @visibility
|
||||
| @where_clause
|
||||
@@ -212,6 +212,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
|
||||
);
|
||||
@@ -1053,41 +1070,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
|
||||
);
|
||||
@@ -1844,18 +1826,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
|
||||
);
|
||||
|
||||
let_exprs(
|
||||
unique int id: @let_expr
|
||||
);
|
||||
@@ -2555,6 +2525,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
|
||||
);
|
||||
|
||||
while_exprs(
|
||||
unique int id: @while_expr
|
||||
);
|
||||
|
||||
36
rust/ql/test/extractor-tests/canonical_path/anonymous.rs
Normal file
36
rust/ql/test/extractor-tests/canonical_path/anonymous.rs
Normal file
@@ -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;
|
||||
}
|
||||
@@ -1,70 +1,89 @@
|
||||
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 | <crate::canonical_paths::a::Struct as crate::canonical_paths::a::Trait>::f |
|
||||
| canonical_paths.rs:13:5:15:5 | Impl | None | None |
|
||||
| canonical_paths.rs:14:9:14:22 | g | repo::test | <crate::canonical_paths::a::Struct>::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 | <crate::canonical_paths::a::Struct as {34}::OtherTrait>::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 |
|
||||
| anonymous.rs:1:1:1:26 | Use | None | None |
|
||||
| anonymous.rs:3:1:32:1 | canonicals | repo::test | crate::anonymous::canonicals |
|
||||
| anonymous.rs:4:5:4:23 | Struct | repo::test | {0}::OtherStruct |
|
||||
| anonymous.rs:6:5:8:5 | Trait | repo::test | {0}::OtherTrait |
|
||||
| anonymous.rs:7:9:7:20 | g | repo::test | {0}::OtherTrait::g |
|
||||
| anonymous.rs:10:5:12:5 | Impl | None | None |
|
||||
| anonymous.rs:11:9:11:22 | g | repo::test | <{0}::OtherStruct as {0}::OtherTrait>::g |
|
||||
| anonymous.rs:14:5:16:5 | Impl | None | None |
|
||||
| anonymous.rs:15:9:15:22 | g | repo::test | <crate::regular::Struct as {0}::OtherTrait>::g |
|
||||
| anonymous.rs:18:5:20:5 | Impl | None | None |
|
||||
| anonymous.rs:19:9:19:22 | f | repo::test | <{0}::OtherStruct as crate::regular::Trait>::f |
|
||||
| anonymous.rs:22:5:24:5 | nested | repo::test | {0}::nested |
|
||||
| anonymous.rs:23:9:23:27 | Struct | repo::test | {1}::OtherStruct |
|
||||
| anonymous.rs:26:5:31:5 | usage | repo::test | {0}::usage |
|
||||
| anonymous.rs:34:1:36:1 | other | repo::test | crate::anonymous::other |
|
||||
| anonymous.rs:35:5:35:23 | Struct | repo::test | {36}::OtherStruct |
|
||||
| lib.rs:1:1:1:14 | Module | repo::test | crate::anonymous |
|
||||
| lib.rs:2:1:2:12 | Module | repo::test | crate::regular |
|
||||
| regular.rs:1:1:2:18 | Struct | repo::test | crate::regular::Struct |
|
||||
| regular.rs:4:1:6:1 | Trait | repo::test | crate::regular::Trait |
|
||||
| regular.rs:5:5:5:16 | f | repo::test | crate::regular::Trait::f |
|
||||
| regular.rs:8:1:10:1 | Impl | None | None |
|
||||
| regular.rs:9:5:9:18 | f | repo::test | <crate::regular::Struct as crate::regular::Trait>::f |
|
||||
| regular.rs:12:1:14:1 | Impl | None | None |
|
||||
| regular.rs:13:5:13:18 | g | repo::test | <crate::regular::Struct>::g |
|
||||
| regular.rs:16:1:18:1 | Trait | repo::test | crate::regular::TraitWithBlanketImpl |
|
||||
| regular.rs:17:5:17:16 | h | repo::test | crate::regular::TraitWithBlanketImpl::h |
|
||||
| regular.rs:20:1:22:1 | Impl | None | None |
|
||||
| regular.rs:21:5:21:18 | h | repo::test | <_ as crate::regular::TraitWithBlanketImpl>::h |
|
||||
| regular.rs:24:1:24:12 | free | repo::test | crate::regular::free |
|
||||
| regular.rs:26:1:32:1 | usage | repo::test | crate::regular::usage |
|
||||
| regular.rs:34:1:38:1 | Enum | repo::test | crate::regular::MyEnum |
|
||||
| regular.rs:40:1:46:1 | enum_qualified_usage | repo::test | crate::regular::enum_qualified_usage |
|
||||
| regular.rs:48:1:55:1 | 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 | <crate::canonical_paths::a::Struct as crate::canonical_paths::a::Trait>::f |
|
||||
| canonical_paths.rs:30:9:30:9 | s | None | None |
|
||||
| canonical_paths.rs:30:9:30:13 | ... .g(...) | repo::test | <crate::canonical_paths::a::Struct>::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 |
|
||||
| anonymous.rs:1:5:1:9 | super | None | None |
|
||||
| anonymous.rs:1:5:1:18 | super::regular | repo::test | crate::regular |
|
||||
| anonymous.rs:1:5:1:25 | super::regular::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 | crate::regular | repo::test | crate::regular |
|
||||
| anonymous.rs:14:25:14:46 | crate::regular::Struct | repo::test | crate::regular::Struct |
|
||||
| anonymous.rs:18:10:18:14 | crate | None | None |
|
||||
| anonymous.rs:18:10:18:23 | crate::regular | repo::test | crate::regular |
|
||||
| anonymous.rs:18:10:18:30 | crate::regular::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 | <crate::regular::Struct as crate::regular::Trait>::f |
|
||||
| regular.rs:29:5:29:5 | s | None | None |
|
||||
| regular.rs:29:5:29:9 | ... .g(...) | repo::test | <crate::regular::Struct>::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 | Option::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 | Option::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 | MyEnum::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 | MyEnum::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 | MyEnum::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 |
|
||||
|
||||
@@ -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<T: Eq> 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;
|
||||
}
|
||||
}
|
||||
55
rust/ql/test/extractor-tests/canonical_path/regular.rs
Normal file
55
rust/ql/test/extractor-tests/canonical_path/regular.rs
Normal file
@@ -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<T: Eq> 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 };
|
||||
}
|
||||
@@ -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
|
||||
|
||||
7
rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql
generated
Normal file
7
rust/ql/test/extractor-tests/generated/Variant/Variant_getCrateOrigin.ql
generated
Normal file
@@ -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()
|
||||
7
rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql
generated
Normal file
7
rust/ql/test/extractor-tests/generated/Variant/Variant_getExtendedCanonicalPath.ql
generated
Normal file
@@ -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()
|
||||
@@ -1700,7 +1700,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(Variant)
|
||||
@annotate(Variant, replace_bases={AstNode: Addressable})
|
||||
class _:
|
||||
"""
|
||||
A Variant. For example:
|
||||
@@ -1809,11 +1809,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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.") | rust.detach | ql.internal
|
||||
pass
|
||||
|
||||
@@ -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 `{<block id>}::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:<name>`, `repo:<repository>:<name>` or `lang:<name>`.") | rust.detach | ql.internal
|
||||
|
||||
|
||||
class Resolvable(AstNode):
|
||||
"""
|
||||
Either a `Path`, or a `MethodCallExpr`.
|
||||
|
||||
Reference in New Issue
Block a user