diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index 4b68c1d42a62..ffb6e69ef6de 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -64,6 +64,12 @@ fn has_special_emission(type_name: &str) -> bool { | "Struct" | "Enum" | "Union" + | "PathExpr" + | "RecordExpr" + | "PathPat" + | "RecordPat" + | "TupleStructPat" + | "MethodCallExpr" | "PathSegment" | "Const" ) diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index fa35ec65d4c5..3b889197b22d 100644 --- a/rust/extractor/src/generated/.generated.list +++ b/rust/extractor/src/generated/.generated.list @@ -1,2 +1,2 @@ mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 -top.rs 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814 +top.rs d39ac3110938f829e640f84ef13c9a0ea7d0a2ff5b77d7e3e013dbfe72523ea5 d39ac3110938f829e640f84ef13c9a0ea7d0a2ff5b77d7e3e013dbfe72523ea5 diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index 3c4b51c78e6a..5853d889b0dd 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -1938,42 +1938,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct PathAstNode { - _unused: () -} - -impl trap::TrapClass for PathAstNode { - fn class_name() -> &'static str { "PathAstNode" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct PathSegment { pub id: trap::TrapId, @@ -2101,6 +2065,53 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Resolvable { + _unused: () +} + +impl Resolvable { + pub fn emit_resolved_path(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("resolvable_resolved_paths", vec![id.into(), value.into()]); + } + + pub fn emit_resolved_crate_origin(id: trap::Label, value: String, out: &mut trap::Writer) { + out.add_tuple("resolvable_resolved_crate_origins", vec![id.into(), value.into()]); + } + +} + +impl trap::TrapClass for Resolvable { + fn class_name() -> &'static str { "Resolvable" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct RetTypeRepr { pub id: trap::TrapId, @@ -6919,44 +6930,44 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct PathExprBase { +pub struct PathAstNode { _unused: () } -impl trap::TrapClass for PathExprBase { - fn class_name() -> &'static str { "PathExprBase" } +impl trap::TrapClass for PathAstNode { + fn class_name() -> &'static str { "PathAstNode" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Expr +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Resolvable unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } @@ -6964,67 +6975,44 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct PathPat { - pub id: trap::TrapId, - pub path: Option>, -} - -impl trap::TrapEntry for PathPat { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("path_pats", vec![id.into()]); - if let Some(v) = self.path { - out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for PathPat { - fn class_name() -> &'static str { "PathPat" } +pub struct PathExprBase { + _unused: () } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Pat - unsafe { - Self::from_untyped(value.as_untyped()) - } - } +impl trap::TrapClass for PathExprBase { + fn class_name() -> &'static str { "PathExprBase" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathPat is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Expr unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme PathPat is a subclass of PathAstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathExprBase is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } @@ -7886,78 +7874,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct StructExpr { - pub id: trap::TrapId, - pub path: Option>, - pub struct_expr_field_list: Option>, -} - -impl trap::TrapEntry for StructExpr { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("struct_exprs", vec![id.into()]); - if let Some(v) = self.path { - out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); - } - if let Some(v) = self.struct_expr_field_list { - out.add_tuple("struct_expr_struct_expr_field_lists", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for StructExpr { - fn class_name() -> &'static str { "StructExpr" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Expr - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of PathAstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct StructFieldList { pub id: trap::TrapId, @@ -8018,107 +7934,35 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct StructPat { - pub id: trap::TrapId, - pub path: Option>, - pub struct_pat_field_list: Option>, +pub struct TryExpr { + pub id: trap::TrapId, + pub attrs: Vec>, + pub expr: Option>, } -impl trap::TrapEntry for StructPat { +impl trap::TrapEntry for TryExpr { fn extract_id(&mut self) -> trap::TrapId { std::mem::replace(&mut self.id, trap::TrapId::Star) } fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("struct_pats", vec![id.into()]); - if let Some(v) = self.path { - out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); + out.add_tuple("try_exprs", vec![id.into()]); + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("try_expr_attrs", vec![id.into(), i.into(), v.into()]); } - if let Some(v) = self.struct_pat_field_list { - out.add_tuple("struct_pat_struct_pat_field_lists", vec![id.into(), v.into()]); + if let Some(v) = self.expr { + out.add_tuple("try_expr_exprs", vec![id.into(), v.into()]); } } } -impl trap::TrapClass for StructPat { - fn class_name() -> &'static str { "StructPat" } +impl trap::TrapClass for TryExpr { + fn class_name() -> &'static str { "TryExpr" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Pat - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructPat is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme StructPat is a subclass of PathAstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -#[derive(Debug)] -pub struct TryExpr { - pub id: trap::TrapId, - pub attrs: Vec>, - pub expr: Option>, -} - -impl trap::TrapEntry for TryExpr { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("try_exprs", vec![id.into()]); - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("try_expr_attrs", vec![id.into(), i.into(), v.into()]); - } - if let Some(v) = self.expr { - out.add_tuple("try_expr_exprs", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for TryExpr { - fn class_name() -> &'static str { "TryExpr" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TryExpr is a subclass of Expr +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TryExpr is a subclass of Expr unsafe { Self::from_untyped(value.as_untyped()) } @@ -8333,78 +8177,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct TupleStructPat { - pub id: trap::TrapId, - pub path: Option>, - pub fields: Vec>, -} - -impl trap::TrapEntry for TupleStructPat { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("tuple_struct_pats", vec![id.into()]); - if let Some(v) = self.path { - out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); - } - for (i, v) in self.fields.into_iter().enumerate() { - out.add_tuple("tuple_struct_pat_fields", vec![id.into(), i.into(), v.into()]); - } - } -} - -impl trap::TrapClass for TupleStructPat { - fn class_name() -> &'static str { "TupleStructPat" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Pat - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of PathAstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct TupleTypeRepr { pub id: trap::TrapId, @@ -9992,6 +9764,15 @@ impl From> for trap::Label { } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct Module { pub id: trap::TrapId, @@ -10162,6 +9943,254 @@ impl From> for trap::Label { } } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathExpr is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +#[derive(Debug)] +pub struct PathPat { + pub id: trap::TrapId, + pub path: Option>, +} + +impl trap::TrapEntry for PathPat { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("path_pats", vec![id.into()]); + if let Some(v) = self.path { + out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for PathPat { + fn class_name() -> &'static str { "PathPat" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Pat + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of PathAstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme PathPat is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +#[derive(Debug)] +pub struct StructExpr { + pub id: trap::TrapId, + pub path: Option>, + pub struct_expr_field_list: Option>, +} + +impl trap::TrapEntry for StructExpr { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("struct_exprs", vec![id.into()]); + if let Some(v) = self.path { + out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); + } + if let Some(v) = self.struct_expr_field_list { + out.add_tuple("struct_expr_struct_expr_field_lists", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for StructExpr { + fn class_name() -> &'static str { "StructExpr" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Expr + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of PathAstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +#[derive(Debug)] +pub struct StructPat { + pub id: trap::TrapId, + pub path: Option>, + pub struct_pat_field_list: Option>, +} + +impl trap::TrapEntry for StructPat { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("struct_pats", vec![id.into()]); + if let Some(v) = self.path { + out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); + } + if let Some(v) = self.struct_pat_field_list { + out.add_tuple("struct_pat_struct_pat_field_lists", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for StructPat { + fn class_name() -> &'static str { "StructPat" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Pat + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of PathAstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme StructPat is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct Trait { pub id: trap::TrapId, @@ -10368,6 +10397,87 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct TupleStructPat { + pub id: trap::TrapId, + pub path: Option>, + pub fields: Vec>, +} + +impl trap::TrapEntry for TupleStructPat { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("tuple_struct_pats", vec![id.into()]); + if let Some(v) = self.path { + out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]); + } + for (i, v) in self.fields.into_iter().enumerate() { + out.add_tuple("tuple_struct_pat_fields", vec![id.into(), i.into(), v.into()]); + } + } +} + +impl trap::TrapClass for TupleStructPat { + fn class_name() -> &'static str { "TupleStructPat" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Pat + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of PathAstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Resolvable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct Use { pub id: trap::TrapId, diff --git a/rust/extractor/src/translate/base.rs b/rust/extractor/src/translate/base.rs index ee26da665b27..c37af0f14c12 100644 --- a/rust/extractor/src/translate/base.rs +++ b/rust/extractor/src/translate/base.rs @@ -1,11 +1,16 @@ -use super::mappings::Emission; +use super::mappings::{AddressableHir, Emission, PathAst}; use crate::generated::{self}; use crate::rust_analyzer::FileSemanticInformation; use crate::trap::{DiagnosticSeverity, TrapFile, TrapId}; use crate::trap::{Label, TrapClass}; -use ra_ap_base_db::EditionedFileId; -use ra_ap_hir::Semantics; +use itertools::Either; +use ra_ap_base_db::{CrateOrigin, EditionedFileId}; use ra_ap_hir::db::ExpandDatabase; +use ra_ap_hir::{ + Adt, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type, Variant, +}; +use ra_ap_hir_def::ModuleId; +use ra_ap_hir_def::type_ref::Mutability; use ra_ap_hir_expand::{ExpandResult, ExpandTo, InFile}; use ra_ap_ide_db::RootDatabase; use ra_ap_ide_db::line_index::{LineCol, LineIndex}; @@ -82,6 +87,42 @@ impl Emission for Translator<'_> { } } +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::PathExpr, label: Label) { + self.extract_path_canonical_destination(node, label.into()); + } +} + +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::RecordExpr, label: Label) { + self.extract_path_canonical_destination(node, label.into()); + } +} + +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::PathPat, label: Label) { + self.extract_path_canonical_destination(node, label.into()); + } +} + +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::RecordPat, label: Label) { + self.extract_path_canonical_destination(node, label.into()); + } +} + +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::TupleStructPat, label: Label) { + self.extract_path_canonical_destination(node, label.into()); + } +} + +impl Emission for Translator<'_> { + fn post_emit(&mut self, node: &ast::MethodCallExpr, label: Label) { + self.extract_method_canonical_destination(node, label); + } +} + impl Emission for Translator<'_> { fn post_emit(&mut self, node: &ast::PathSegment, label: Label) { self.extract_types_from_path_segment(node, label); @@ -462,6 +503,254 @@ impl<'a> Translator<'a> { } } + fn canonical_path_from_type(&self, ty: Type) -> Option { + let sema = self.semantics.as_ref().unwrap(); + // rust-analyzer doesn't provide a type enum directly + if let Some(it) = ty.as_adt() { + return match it { + Adt::Struct(it) => self.canonical_path_from_hir(it), + Adt::Union(it) => self.canonical_path_from_hir(it), + Adt::Enum(it) => self.canonical_path_from_hir(it), + }; + }; + if let Some((it, size)) = ty.as_array(sema.db) { + return self + .canonical_path_from_type(it) + .map(|p| format!("[{p}; {size}]")); + } + if let Some(it) = ty.as_slice() { + return self.canonical_path_from_type(it).map(|p| format!("[{p}]")); + } + if let Some(it) = ty.as_builtin() { + return Some(it.name().as_str().to_owned()); + } + if let Some(it) = ty.as_dyn_trait() { + return self.canonical_path_from_hir(it).map(|p| format!("dyn {p}")); + } + if let Some((it, mutability)) = ty.as_reference() { + let mut_str = match mutability { + Mutability::Shared => "", + Mutability::Mut => "mut ", + }; + return self + .canonical_path_from_type(it) + .map(|p| format!("&{mut_str}{p}")); + } + if let Some(it) = ty.as_impl_traits(sema.db) { + let paths = it + .map(|t| self.canonical_path_from_hir(t)) + .collect::>>()?; + return Some(format!("impl {}", paths.join(" + "))); + } + if ty.as_type_param(sema.db).is_some() { + // from the canonical path perspective, we just want a special name + // e.g. `crate::<_ as SomeTrait>::func` + return Some("_".to_owned()); + } + None + } + + fn canonical_path_from_hir_module(&self, item: Module) -> Option { + if ModuleId::from(item).containing_block().is_some() { + // this means this is a block module, i.e. a virtual module for an anonymous block scope + return None; + } + if item.is_crate_root() { + return Some("crate".into()); + } + self.canonical_path_from_hir::(item) + } + + fn canonical_path_from_hir(&self, item: impl AddressableHir) -> Option { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + let name = item.name(sema)?; + let container = item.container(sema.db); + let prefix = match container { + ItemContainer::Trait(it) => self.canonical_path_from_hir(it), + ItemContainer::Impl(it) => { + let ty = self.canonical_path_from_type(it.self_ty(sema.db))?; + if let Some(trait_) = it.trait_(sema.db) { + let tr = self.canonical_path_from_hir(trait_)?; + Some(format!("<{ty} as {tr}>")) + } else { + Some(format!("<{ty}>")) + } + } + ItemContainer::Module(it) => self.canonical_path_from_hir_module(it), + ItemContainer::ExternBlock(..) | ItemContainer::Crate(..) => Some("".to_owned()), + }?; + Some(format!("{prefix}::{name}")) + } + + fn canonical_path_from_module_def(&self, item: ModuleDef) -> Option { + match item { + ModuleDef::Module(it) => self.canonical_path_from_hir(it), + ModuleDef::Function(it) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Enum(it)) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Struct(it)) => self.canonical_path_from_hir(it), + ModuleDef::Adt(Adt::Union(it)) => self.canonical_path_from_hir(it), + ModuleDef::Trait(it) => self.canonical_path_from_hir(it), + ModuleDef::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::Const(_) => None, + } + } + + fn canonical_path_from_enum_variant(&self, item: Variant) -> Option { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + let prefix = self.canonical_path_from_hir(item.parent_enum(sema.db))?; + let name = item.name(sema.db); + Some(format!("{prefix}::{}", name.as_str())) + } + + fn origin_from_hir(&self, item: impl AddressableHir) -> String { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + self.origin_from_crate(item.module(sema).krate()) + } + + fn origin_from_crate(&self, item: Crate) -> String { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + match item.origin(sema.db) { + CrateOrigin::Rustc { name } => format!("rustc:{name}"), + CrateOrigin::Local { repo, name } => format!( + "repo:{}:{}", + repo.unwrap_or_default(), + name.map(|s| s.as_str().to_owned()).unwrap_or_default() + ), + CrateOrigin::Library { repo, name } => { + format!("repo:{}:{}", repo.unwrap_or_default(), name) + } + CrateOrigin::Lang(it) => format!("lang:{it}"), + } + } + + fn origin_from_module_def(&self, item: ModuleDef) -> Option { + match item { + ModuleDef::Module(it) => Some(self.origin_from_hir(it)), + ModuleDef::Function(it) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Enum(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Struct(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Adt(Adt::Union(it)) => Some(self.origin_from_hir(it)), + ModuleDef::Trait(it) => Some(self.origin_from_hir(it)), + ModuleDef::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::Const(_) => None, + } + } + + fn origin_from_enum_variant(&self, item: Variant) -> String { + // if we have a Hir entity, it means we have semantics + let sema = self.semantics.as_ref().unwrap(); + self.origin_from_hir(item.parent_enum(sema.db)) + } + + // pub(crate) fn extract_canonical_origin( + // &mut self, + // item: &T, + // label: Label, + // ) { + // // if !self.resolve_paths { + // // return; + // // } + // (|| { + // 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::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, + // ) { + // // if !self.resolve_paths { + // // return; + // // } + // (|| { + // 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(()) + // })(); + // } + + pub(crate) fn extract_path_canonical_destination( + &mut self, + item: &impl PathAst, + label: Label, + ) { + // if !self.resolve_paths { + // return; + // } + (|| { + let path = item.path()?; + let sema = self.semantics.as_ref()?; + let resolution = sema.resolve_path(&path)?; + let PathResolution::Def(def) = resolution else { + return None; + }; + let origin = self.origin_from_module_def(def)?; + let path = self.canonical_path_from_module_def(def)?; + generated::Resolvable::emit_resolved_crate_origin(label, origin, &mut self.trap.writer); + generated::Resolvable::emit_resolved_path(label, path, &mut self.trap.writer); + Some(()) + })(); + } + + pub(crate) fn extract_method_canonical_destination( + &mut self, + item: &ast::MethodCallExpr, + label: Label, + ) { + // if !self.resolve_paths { + // return; + // } + (|| { + let sema = self.semantics.as_ref()?; + let resolved = sema.resolve_method_call_fallback(item)?; + let (Either::Left(function), _) = resolved else { + return None; + }; + let origin = self.origin_from_hir(function); + let path = self.canonical_path_from_hir(function)?; + generated::Resolvable::emit_resolved_crate_origin( + label.into(), + origin, + &mut self.trap.writer, + ); + generated::Resolvable::emit_resolved_path(label.into(), path, &mut self.trap.writer); + Some(()) + })(); + } + pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool { self.semantics.is_some_and(|sema| { item.attrs().any(|attr| { diff --git a/rust/extractor/src/translate/generated.rs b/rust/extractor/src/translate/generated.rs index e6cc06419fce..01128934cd99 100644 --- a/rust/extractor/src/translate/generated.rs +++ b/rust/extractor/src/translate/generated.rs @@ -1715,6 +1715,9 @@ impl Translator<'_> { &mut self, node: &ast::MethodCallExpr, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } if self.should_be_excluded(node) { return None; } @@ -1734,6 +1737,7 @@ impl Translator<'_> { receiver, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -1935,6 +1939,9 @@ impl Translator<'_> { &mut self, node: &ast::PathExpr, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } if self.should_be_excluded(node) { return None; } @@ -1946,6 +1953,7 @@ impl Translator<'_> { path, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -1953,12 +1961,16 @@ impl Translator<'_> { &mut self, node: &ast::PathPat, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } let path = node.path().and_then(|x| self.emit_path(&x)); let label = self.trap.emit(generated::PathPat { id: TrapId::Star, path, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -2086,6 +2098,9 @@ impl Translator<'_> { &mut self, node: &ast::RecordExpr, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } let path = node.path().and_then(|x| self.emit_path(&x)); let struct_expr_field_list = node .record_expr_field_list() @@ -2096,6 +2111,7 @@ impl Translator<'_> { struct_expr_field_list, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -2188,6 +2204,9 @@ impl Translator<'_> { &mut self, node: &ast::RecordPat, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } let path = node.path().and_then(|x| self.emit_path(&x)); let struct_pat_field_list = node .record_pat_field_list() @@ -2198,6 +2217,7 @@ impl Translator<'_> { struct_pat_field_list, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -2676,6 +2696,9 @@ impl Translator<'_> { &mut self, node: &ast::TupleStructPat, ) -> Option> { + if let Some(label) = self.pre_emit(node) { + return Some(label); + } let fields = node.fields().filter_map(|x| self.emit_pat(&x)).collect(); let path = node.path().and_then(|x| self.emit_path(&x)); let label = self.trap.emit(generated::TupleStructPat { @@ -2684,6 +2707,7 @@ impl Translator<'_> { path, }); self.emit_location(label, node); + self.post_emit(node, label); self.emit_tokens(node, label.into(), node.syntax().children_with_tokens()); Some(label) } @@ -3111,12 +3135,30 @@ impl HasTrapClass for ast::MacroCall { impl HasTrapClass for ast::Meta { type TrapClass = generated::Meta; } +impl HasTrapClass for ast::MethodCallExpr { + type TrapClass = generated::MethodCallExpr; +} +impl HasTrapClass for ast::PathExpr { + type TrapClass = generated::PathExpr; +} +impl HasTrapClass for ast::PathPat { + type TrapClass = generated::PathPat; +} impl HasTrapClass for ast::PathSegment { type TrapClass = generated::PathSegment; } +impl HasTrapClass for ast::RecordExpr { + type TrapClass = generated::StructExpr; +} +impl HasTrapClass for ast::RecordPat { + type TrapClass = generated::StructPat; +} impl HasTrapClass for ast::Struct { type TrapClass = generated::Struct; } +impl HasTrapClass for ast::TupleStructPat { + type TrapClass = generated::TupleStructPat; +} impl HasTrapClass for ast::Union { type TrapClass = generated::Union; } diff --git a/rust/extractor/src/translate/mappings.rs b/rust/extractor/src/translate/mappings.rs index f1a42dbf2457..1fbcb675a321 100644 --- a/rust/extractor/src/translate/mappings.rs +++ b/rust/extractor/src/translate/mappings.rs @@ -1,4 +1,6 @@ use crate::trap::{Label, TrapClass}; +use ra_ap_hir::{Enum, Function, HasContainer, Module, Semantics, Struct, Trait, Union}; +use ra_ap_ide_db::RootDatabase; use ra_ap_syntax::{AstNode, ast, ast::RangeItem}; pub(crate) trait HasTrapClass: AstNode { @@ -63,3 +65,102 @@ impl TextValue for ast::RangePat { self.op_token().map(|x| x.text().to_string()) } } + +pub(crate) trait AddressableHir: HasContainer + Copy { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option; + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module; +} + +impl AddressableHir for Function { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + Some(self.name(sema.db).as_str().to_owned()) + } + + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module { + self.module(sema.db) + } +} + +impl AddressableHir for Trait { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + Some(self.name(sema.db).as_str().to_owned()) + } + + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module { + self.module(sema.db) + } +} + +impl AddressableHir for Module { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + self.name(sema.db).map(|s| s.as_str().to_owned()) + } + + fn module(self, _sema: &Semantics<'_, RootDatabase>) -> Module { + self + } +} + +impl AddressableHir for Struct { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + Some(self.name(sema.db).as_str().to_owned()) + } + + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module { + self.module(sema.db) + } +} + +impl AddressableHir for Enum { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + Some(self.name(sema.db).as_str().to_owned()) + } + + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module { + self.module(sema.db) + } +} + +impl AddressableHir for Union { + fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option { + Some(self.name(sema.db).as_str().to_owned()) + } + + fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module { + self.module(sema.db) + } +} + +pub trait PathAst: AstNode { + fn path(&self) -> Option; +} + +impl PathAst for ast::PathExpr { + fn path(&self) -> Option { + self.path() + } +} + +impl PathAst for ast::RecordExpr { + fn path(&self) -> Option { + self.path() + } +} + +impl PathAst for ast::PathPat { + fn path(&self) -> Option { + self.path() + } +} + +impl PathAst for ast::RecordPat { + fn path(&self) -> Option { + self.path() + } +} + +impl PathAst for ast::TupleStructPat { + fn path(&self) -> Option { + self.path() + } +} diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 1f580178999e..e86df615f218 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -103,7 +103,7 @@ lib/codeql/rust/elements/MatchArmList.qll f221c5e344814fa44db06ab897afdc249e8e88 lib/codeql/rust/elements/MatchExpr.qll e9ef1664f020823b6f4bb72d906a9dc0c1ee6432d4a9a13f7dbdbab2b2b1ee4d 38d71e5c487abcb5682293c573343be66e499a6e131bb630604c120d34b7777b lib/codeql/rust/elements/MatchGuard.qll 58256689a90f24b16401543452c2a32f00d619ddac6c0fe8b65a8cd3e46401bb 8efb2ac03c69a9db687e382331085d7a6cfbf8eca559174ba2727a9549ec7ddd lib/codeql/rust/elements/Meta.qll b17d7bf605bd0cf4f6d6c6cf4f39a16cfc431d256d45b93663a7569181d36168 815cdfef06231de4b4b1c85e321b8ccb3e22379e5a4e111df9cc9ca6be593841 -lib/codeql/rust/elements/MethodCallExpr.qll 91b411e0fb1a0547dcad8726db460dccc61bed972741598d5cb3740593fe75a7 538d23b6db115bb699389d29a1829bb0449c08424a1fff80377828eb7ceb2563 +lib/codeql/rust/elements/MethodCallExpr.qll 318a46ba61e3e4f0d6ce0e8fa9f79ccbbf2d0f3d0638e6813e1bcb44d624715a 35e03ed4beddd75834fcfc4371bd65eaf099053aa23f7f1d1e6bea2e5825aa6e lib/codeql/rust/elements/Missing.qll 70e6ac9790314752849c9888443c98223ccfc93a193998b7ce350b2c6ebe8ea4 e2f0623511acaa76b091f748d417714137a8b94f1f2bdbbd177f1c682c786dad lib/codeql/rust/elements/Module.qll 0bc85019177709256f8078d9de2a36f62f848d476225bff7bba1e35f249875c7 3fbb70e0c417a644dd0cada2c364c6e6876cfa16f37960e219c87e49c966c94e lib/codeql/rust/elements/Name.qll af41479d4260fe931d46154dda15484e4733c952b98f0e370106e6e9e8ce398b e188a0d0309dd1b684c0cb88df435b38e306eb94d6b66a2b748e75252f15e095 @@ -120,7 +120,7 @@ lib/codeql/rust/elements/ParenTypeRepr.qll 2388b6c663b2d02c834592c5da5cafac71baa lib/codeql/rust/elements/ParenthesizedArgList.qll aa3be48d2f8b5cec56db3866fb7d4e0cd97787e9123e2d947912eb8155bf372b 32790971728c9ae2f3d59155d46283aaf4f08238e47bb028a1f20a6d3a734b98 lib/codeql/rust/elements/Pat.qll 56211c5cb4709e7c12a2bfd2da5e413a451672d99e23a8386c08ad0b999fd45c b1b1893a13a75c4f0390f7e2a14ee98a46f067cfdc991a8d43adc82497d20aff lib/codeql/rust/elements/Path.qll 16264a9c978a3027f623530e386a9ad16541305b252fed5e1bedcfbe1d6475d5 8c21063c7f344ce686342e7c12542fec05004e364681f7a31b65f5ee9263a46d -lib/codeql/rust/elements/PathAstNode.qll 68160b08272ecde0e636779b7c547f808356d69d1150863b37188ea84e110cab cafa2de0bf3be978854319bbcf5ad1591acd64abd7b0958ff14c96a7529fcc99 +lib/codeql/rust/elements/PathAstNode.qll c5c8627caaf863089d4d6004e206b2e62bc466db2ed5da9f3f443bf3dc29faf9 01107b1ce17cbee08a764962fb13d3f02edbd10675fa5bd89e089f03075ba443 lib/codeql/rust/elements/PathExpr.qll 0232228845a2005fc63d6b8aea8b49ff50415e0e90fd18f863ee1d6e44f53c07 47b15cc6ae576d13f14b29ffa4620451accc603ff87071dfe48660dbe018bf36 lib/codeql/rust/elements/PathExprBase.qll bb41092ec690ae926e3233c215dcaf1fd8e161b8a6955151949f492e02dba13a b2257072f8062d31c29c63ee1311b07e0d2eb37075f582cfc76bb542ef773198 lib/codeql/rust/elements/PathPat.qll a7069d1dd77ba66814d6c84e135ed2975d7fcf379624079e6a76dc44b5de832e 2294d524b65ab0d038094b2a00f73feb8ab70c8f49fb4d91e9d390073205631d @@ -134,6 +134,7 @@ lib/codeql/rust/elements/RefExpr.qll 91a0d3a86002289dc01ffbe8daca13e34e92e522fbb lib/codeql/rust/elements/RefPat.qll fe076bdccb454111b38f360837d180274ba8a003b4cffe910b5197cd74188089 2604c8bb2b0b47091d5fc4aa276de46fe3561e346bd98f291c3783cef402ba06 lib/codeql/rust/elements/RefTypeRepr.qll 563d2edc097aa1896b3dea5a3918e6225f23dda91b3fb46e2f4c32feb813d56c af3bd746239130e3e94dd41ab682473b29b8b900b05c557beb8a2eba6508ebd9 lib/codeql/rust/elements/Rename.qll 5cb0ebad580d9842cfe65033059d4d373a1386f047f3a78f402a93e060e2c13e 642c6f37d94442575df12b2e998572a725d094ac5ae76147a56057e75138d72b +lib/codeql/rust/elements/Resolvable.qll efeec2b4b14d85334ec745b9a0c5aa6f7b9f86fe3caa45b005dccaee4f5265c4 7efe0063340ba61dd31125bc770773ca23a7067893c0d1e06d149da6e9a9ee92 lib/codeql/rust/elements/RestPat.qll 5fedfac18080b068f597c9bbb84de672834f72cc22295d6312e111f151f8e3c7 c0e1f77bfcdd40e8ab06ad8c138e6098d79940247758adf9de03a05b00c23de3 lib/codeql/rust/elements/RetTypeRepr.qll d68b7c6c2eda13821fcfe085ac3d63010d89a206be09d23deaf531cac405ba96 6db787a96d95265ca20a17ce00603a678b39ac8c7c1d0e1ad6ed119dcf9858fa lib/codeql/rust/elements/ReturnExpr.qll b87187cff55bc33c8c18558c9b88617179183d1341b322c1cab35ba07167bbdb 892f3a9df2187e745c869e67f33c228ee42754bc9e4f8f4c1718472eb8f8c80f @@ -366,6 +367,7 @@ lib/codeql/rust/elements/internal/RefTypeReprConstructor.qll 8e7012b456ebf1cc7a2 lib/codeql/rust/elements/internal/RefTypeReprImpl.qll 553dd95e1a49ab7aef5db08e7bb550104c604ec33c9a3c7529370cd47c6a0965 8902db7c814f631c2a995df5911a7b13b6a38c524417e4bbbf2bda74ad53e14c lib/codeql/rust/elements/internal/RenameConstructor.qll 65fa2e938978d154701e6cac05b56320b176ee014ef5c20a7b66f3e94fd5c4a7 dfc0ff4606b8e1c14003cc93a0811f4d62ec993b07ff3c1aa0776746577ed103 lib/codeql/rust/elements/internal/RenameImpl.qll 61c681055f1f86402af0772539f702e9e19a123f8cfcfca225535c3a1a4cb1d7 1aa1c78616c4b54a31c8af74de141aef9e5ada53f3859df631ecb4238faabdbf +lib/codeql/rust/elements/internal/ResolvableImpl.qll 7d6d02eceef54d588de6204abbcf7a6454916e49180e3db8a72131032cec5837 9c3a28ea0d293b449c69982e3695903a10510096e765a53c1b34ac3ad009a9f4 lib/codeql/rust/elements/internal/RestPatConstructor.qll 45430925ddf08fba70ede44c7f413ddb41b3113c149b7efc276e0c2bf72507b4 25c678898d72446e7a975bb8b7f2fde51e55b59dbd42f2cca997c833b1a995f1 lib/codeql/rust/elements/internal/RetTypeReprConstructor.qll 6dcb56c92a13f5ca2c9a8344bc05638cc611543896c578cd6ca185054f155537 3fe34953ba397dc31533bd28b48df76693e86b51c4a89c26ad4dfdbd816a0874 lib/codeql/rust/elements/internal/RetTypeReprImpl.qll 321355a9b39193e09ef7c38b807d7f3c221dce06b0cafd2e0ceccdfbb81712e4 02ea0fb17416889b400e0706eeacc0afc6b489b76158e8c26b9b77102df6bd60 @@ -553,7 +555,7 @@ lib/codeql/rust/elements/internal/generated/MatchArmList.qll 12d969ecb267a749918 lib/codeql/rust/elements/internal/generated/MatchExpr.qll b686842e7000fd61e3a0598bf245fb4e18167b99eca9162fdfdff0b0963def22 00f1743b1b0f1a92c5a687f5260fda02d80cc5871694cad0d5e7d94bac7fe977 lib/codeql/rust/elements/internal/generated/MatchGuard.qll 58fa1d6979ef22de2bd68574c7ffcf4a021d7543445f68834d879ff8cee3abcb 072f22a7929df3c0e764b2a770b4cdf03504b3053067d9b9008d6655fb5837e1 lib/codeql/rust/elements/internal/generated/Meta.qll 15e98e8d38f5618b7053057a629b135aae5e105fbf72731833a644fb695244c0 2977b6a0781c89383e87c595b14a39851f27b2508296f3e77466eea44c916188 -lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 0cd0f84147e5f3887d609cc58246eb493d3461aee00ff37e7d26282c835f73af 6f4c5dc1decbce54fc12300d34798b890a85129208b25565130205c9d8ee2e29 +lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 816267f27f990d655f1ef2304eb73a9468935ffbfddd908773a77fa3860bb970 adda2574300a169a13ea9e33af05c804bf00868d3e8930f0f78d6a8722ad688d lib/codeql/rust/elements/internal/generated/Missing.qll 16735d91df04a4e1ae52fae25db5f59a044e540755734bbab46b5fbb0fe6b0bd 28ca4e49fb7e6b4734be2f2f69e7c224c570344cc160ef80c5a5cd413e750dad lib/codeql/rust/elements/internal/generated/Module.qll ebae5d8963c9fd569c0fbad1d7770abd3fd2479437f236cbce0505ba9f9af52c fa3c382115fed18a26f1a755d8749a201b9489f82c09448a88fb8e9e1435fe5f lib/codeql/rust/elements/internal/generated/Name.qll e6bd6240a051383a52b21ab539bc204ce7bcd51a1a4379e497dff008d4eef5b4 578a3b45e70f519d57b3e3a3450f6272716c849940daee49889717c7aaa85fc9 @@ -568,11 +570,11 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126 -lib/codeql/rust/elements/internal/generated/ParentChild.qll 6e86fd9b6d5ec1b4aeeb5472cc6d2ebf3328bbaa8605cf52c9add56652cc47dc 3cf2a8e12ffb6631221c7b94fa112e8e3be96efba697996862685a87b2c9aff7 +lib/codeql/rust/elements/internal/generated/ParentChild.qll fa3b893e380531f11791b64809ecddcdbed1493a74ed93018b4283abc4b9416e d5a08e3e5f97df5b574537b4cfbf27fb195b935f30b543b1e25e8d963d863eda lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd -lib/codeql/rust/elements/internal/generated/PathAstNode.qll b02654422f80e398027069135bb01205358f0ab82ded3408d83d066f300996a3 345e7f92a75bfc71657b223602f60c36f7637d6f2e3798f07e2d2926eea2431b +lib/codeql/rust/elements/internal/generated/PathAstNode.qll e6d4d5bffd3c623baaaee46bc183eb31ce88795535f164f6a9b9b4d98bbd6101 168db515404933479ba6b150c72e012d28592cbc32366aefcb1bf9599dbcd183 lib/codeql/rust/elements/internal/generated/PathExpr.qll 34ebad4d062ce8b7e517f2ab09d52745fb8455203f4a936df7284ad296638387 ba66781cdbdeb89c27a4bfb2be0f27f85fb34978d699b4e343446fb0d7ad2aa6 lib/codeql/rust/elements/internal/generated/PathExprBase.qll d8218e201b8557fa6d9ca2c30b764e5ad9a04a2e4fb695cc7219bbd7636a6ac2 4ef178426d7095a156f4f8c459b4d16f63abc64336cb50a6cf883a5f7ee09113 lib/codeql/rust/elements/internal/generated/PathPat.qll 003d10a4d18681da67c7b20fcb16b15047cf9cc4b1723e7674ef74e40589cc5a 955e66f6d317ca5562ad1b5b13e1cd230c29e2538b8e86f072795b0fdd8a1c66 @@ -583,11 +585,12 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 8d0ea4f6c7f8203340bf lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9 -lib/codeql/rust/elements/internal/generated/Raw.qll f50925f4925848cef73003adf01420566ca3efa16f491eadac62a30972ee9204 17d62252413618e1fa162c6c0b303ccfcac5f7f70cc170d739b20cc95f57035b +lib/codeql/rust/elements/internal/generated/Raw.qll 31b480b76446da2a41ffaa85aa13cb54d5e62a840c8ffb32e4b91b2502402a2e d16fbf6b850a4ff2b87cc3b48b2a30ed2b078d10dc29655e747c2b1db3145c52 lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66 lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05 lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 5b0663a6d234572fb3e467e276d019415caa95ef006438cc59b7af4e1783161e 0e27c8a8f0e323c0e4d6db01fca821bf07c0864d293cdf96fa891b10820c1e4b lib/codeql/rust/elements/internal/generated/Rename.qll 53dd50d35aa38cb6eb4174c94e8e23042b42bdc4f38df009489ebf707380483b db14fbce0d95b4dae3d7512f9bdee92e0dc2dffde5ba5d7458f2f5dd632876b0 +lib/codeql/rust/elements/internal/generated/Resolvable.qll 586eefb01794220679c3b5d69c059d50c2238cf78ab33efe7185bbd07dea8dbd 1b7c7297d541b9de9e881d18fed4ae40dd327396366a3a6f52a24b85685fa9c1 lib/codeql/rust/elements/internal/generated/RestPat.qll 369f5828bb78f2856d528679a9869f81859b375c2f831ff72f4507daaee976e3 17f24ce8aa6a27359c10a654667b7877ca7a1509509e2ab246ed26fe15ef66b4 lib/codeql/rust/elements/internal/generated/RetTypeRepr.qll 853b7fd6c1f3678d0f9315ac23a99a0828a6e54148de24016a265039c7b1941c f1e140d2b113c494601143b735482869ee817c8a7d92026f6a511bc5c1420552 lib/codeql/rust/elements/internal/generated/ReturnExpr.qll c9c05400d326cd8e0da11c3bfa524daa08b2579ecaee80e468076e5dd7911d56 e7694926727220f46a7617b6ca336767450e359c6fa3782e82b1e21d85d37268 @@ -608,7 +611,7 @@ lib/codeql/rust/elements/internal/generated/StructFieldList.qll 5da528a51a6a5db9 lib/codeql/rust/elements/internal/generated/StructPat.qll c76fa005c2fd0448a8803233e1e8818c4123301eb66ac5cf69d0b9eaafc61e98 6e0dffccdce24bca20e87d5ba0f0995c9a1ae8983283e71e7dbfcf6fffc67a58 lib/codeql/rust/elements/internal/generated/StructPatField.qll 5b5c7302dbc4a902ca8e69ff31875c867e295a16a626ba3cef29cd0aa248f179 4e192a0df79947f5cb0d47fdbbba7986137a6a40a1be92ae119873e2fad67edf lib/codeql/rust/elements/internal/generated/StructPatFieldList.qll 1a95a1bd9f64fb18e9571657cf2d02a8b13c747048a1f0f74baf31b91f0392ad fc274e414ff4ed54386046505920de92755ad0b4d39a7523cdffa4830bd53b37 -lib/codeql/rust/elements/internal/generated/Synth.qll 4c741d502d21d449c4e01010776f767c69b408c80ce7d10784b599463bcfd0e3 c76b8628663c126914ead897c779ce782294e9109125d61de958e0eee543abce +lib/codeql/rust/elements/internal/generated/Synth.qll e1f47da257976aa7689461ee3ea9022fc0d27494a556f14f1086f8149b885d5c 59b979f378be6ce75ecfd3430887bff747c273d1536c686f90def9e6c4ed2c12 lib/codeql/rust/elements/internal/generated/SynthConstructors.qll f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 1a3c4f5f30659738641abdd28cb793dab3cfde484196b59656fc0a2767e53511 de2ebb210c7759ef7a6f7ee9f805e1cac879221287281775fc80ba34a5492edf @@ -645,7 +648,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll 0353aab87c49569e1fbf58 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 d3beb3a35f2b5ea47d60aeefd86fb0d6406dd0a1b7cd89aecbb2732b4e72da38 d3beb3a35f2b5ea47d60aeefd86fb0d6406dd0a1b7cd89aecbb2732b4e72da38 +lib/codeql/rust/elements.qll 49df59c1b9574135b6ff2b0480b645f7303e81df042714b22b1070351d0076b9 49df59c1b9574135b6ff2b0480b645f7303e81df042714b22b1070351d0076b9 test/extractor-tests/generated/Abi/Abi.ql 086ed104ab1a7e7fe5c1ed29e03f1719a797c7096c738868bf6ebe872ab8fdaa fe23fe67ab0d9201e1177ea3f844b18ed428e13e3ce77381bf2b6910adfa3a0e test/extractor-tests/generated/ArgList/ArgList.ql da97b5b25418b2aa8cb8df793f48870c89fa00759cdade8ddba60d7f1f4bbc01 acfd5d2caf67282ad2d57b961068472100482d0f770a52a3c00214c647d18c75 test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql 42b365276aa43e2cad588338463542d3ce1dd0db3a428621554584b07a1431d5 08a66a8b69af35ee3bc64c35c453a19a6c9881cc6cc7e65275d1fff056121270 @@ -730,7 +733,7 @@ test/extractor-tests/generated/MatchArmList/MatchArmList.ql bbc679fe6d8dedf9131d test/extractor-tests/generated/MatchExpr/MatchExpr.ql b75a5936401bb5ca38686f1413f5c8267ad685722560a2e9041dacf2f8d54abc 7da57118fe5b1f7f5cbe8d6b5f3ae70816fd4837b1c2e6401b98175b36ca233f test/extractor-tests/generated/MatchGuard/MatchGuard.ql 91de18a0a18d120db568b2c329e5cb26f83e327cf22c5825c555ea17249d7d23 0bcdb25895362128517227c860b9dad76851215c2cdf9b2d0e5cc3534278f4ec test/extractor-tests/generated/Meta/Meta.ql 43dd1cd669099b38396b316616992af6d84b0c1cee953b19235a00ab3d3bb43c 80b1885809aa074357e21707d1f8c6dca19f0b968ccff43229bb0d5c6fffb2b2 -test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 05ca29fdab8ce600469728b964c369368e5097b2a5eb35b84a7630ef044ac6b6 aa45fdbb7fba8afee9f6cef10d337622429d3f0fb71f7fbf861afb4906bdef71 +test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 617bc809816dc3cc1de1c0b49c494568164fe2a048472f4cce1b83f0a1f54a42 1b323e0b1812dbfdd78ee58798353e20326a3ca7529f52d5c984d1d92889a65f test/extractor-tests/generated/Module/Module.ql d7c442fd1b1f4f00da87e2228fc1aeeab0bb86648b2aa06a9dd6f40dbae1ee28 3229388727d14048e87238bcda5fde1bed503e5cac088922381e5833cfc32fa9 test/extractor-tests/generated/Name/Name.ql b2fe417f7c816f71d12622b4f84ece74eba3c128c806266a55b53f8120fa4fb3 8bc65bbf3f2909637485f5db7830d6fc110a94c9b12eefe12d7627f41eae2256 test/extractor-tests/generated/NameRef/NameRef.ql 210a70e0957f3444195eed3a3dfbb5806e349238c0b390dc00597e6b8b05fcec d74fbce3c71aa7b08ae4cb646ccb114335767cb4fe000322f9dd371c1bb3784f @@ -744,8 +747,8 @@ test/extractor-tests/generated/ParenPat/ParenPat.ql 50f99c6a7e5e2f76dc5bbc10a6b2 test/extractor-tests/generated/ParenTypeRepr/ParenTypeRepr.ql 86a45a9f9696a55562a7125f08297bcd50b368225a13cd31b6e9eb4071d04e13 53c0b8c4f453a748c9534220960c6ce8c52bd7501cf1d1f74e3928fc6512667c test/extractor-tests/generated/ParenthesizedArgList/ParenthesizedArgList.ql 6d0e3f7cbcc835f2a5784ccb09b0d65c2bb063c1904edded2e7fc8c9fb57c4fa e41c898b8b0d61078e0d76c6e2e141251dca71f79ad5fa119c012220c54cc409 test/extractor-tests/generated/Path/Path.ql 0f6b63c723da7f140411c8e9a4bb9fbe043a997a1748a4a491add4bd6e81fd6e 5081db5bd590b72780c3c8032532e65b5d453c327c8771da6b87c10e30071523 -test/extractor-tests/generated/Path/PathExpr.ql caa2a41b5cc3af837fcf52b49abc5f45ba924821ea0f75d5b25daa8d2b6d4b66 7c2d587d7a73c21dcc0a85c38baa0adcd64826719b2f12f92ae758d290f37706 -test/extractor-tests/generated/Path/PathPat.ql 8a6a759f4bbf4fa9c23fd235ce4d63f04bd715a86a6e71bba0a324fe1231d947 be23d83e4f6ac209f3f7c382fce6b9bc57db17a26b236bdf8215848285e345ff +test/extractor-tests/generated/Path/PathExpr.ql 2b032a00d8f5570b34f44bdb4209f199f821e093011472b5c686918a063442a5 9f10b1e38863da09365fc45f749578dde74bbb64d35972fa34b83e6814f0004a +test/extractor-tests/generated/Path/PathPat.ql 8d8053588dba1f35fff3bb89eb66f1534f637cf3b56338a6f3c19d748db7e1ca d7405ca5bf3bfa6960426964be3ea32562e1367c74b1f438c0827573eeaf773a test/extractor-tests/generated/Path/PathSegment.ql 87774cc2e9d1be7aaf8748d418b151d7ec03fb20fda9430ebabd86ddaebf5538 699545d8eb2d6325bcd2c253d56339bd71170b34e80efe5155189fbbdde9fbbc test/extractor-tests/generated/Path/PathTypeRepr.ql 32023340cb9aa1fbf52a1a3e330c6f3206e1c64c9dce2f795d9e434aa5a1533b f451de0d4941ab79014d2883b46291f9f05f79d479fcdcab387020ab3ed68703 test/extractor-tests/generated/PrefixExpr/PrefixExpr.ql 63e9dbae0d0b46d5e9d60c313e408c4c7ee1a93c5a26fe4c01a632911de961d0 09fcc28bb22553356aebf9ea93811703e5404b88022be8dab61ac81d3b187b75 @@ -767,12 +770,12 @@ test/extractor-tests/generated/SourceFile/SourceFile.ql 19ae5570a88b9e2d82db6668 test/extractor-tests/generated/Static/Static.ql ec2e5cf081453bbae16216d1250f5d8324be81d1d6ad8744e969934d2ef21b0d 7bde1afbafdc16f9c999e902626c77dc0efe3f1b3d687e9fe1a3e9db6b1f62a9 test/extractor-tests/generated/StmtList/StmtList.ql 4c6b9d5d8fd7535f97d81b968d4f67fc50e10c5d0f980e7c2704bbf5cd07481e ad972adb8d9a7892e6f8a12d96649340441f947afc99e633ea438c4d5c795ce4 test/extractor-tests/generated/Struct/Struct.ql 846ef41cb4dfbe94f495fd68de26a68609e7b5ab0830d6ee844a67afea3ac591 6799a1246da45ecbf1f1040ffb7d1a5578ab9e236cce3029e6cc17c93b3bf138 -test/extractor-tests/generated/StructExpr/StructExpr.ql 3b98205260e750cc7adc42b318deef2854cc3b4f921cbcfffc6d701553af3903 368bccf01db2fa069dca30d9fb0878f8e6a88d4ce58b333b24a18620933e4c91 +test/extractor-tests/generated/StructExpr/StructExpr.ql 1e577f7cc83aa86fc82e4ac467bfb8a0c239408d4217f92a0a689957ea4fe6fe 35568a6cb7f0aaa3026e11a3b0e750eb5e93d4c0b6f737171e27c84f5dc967ac test/extractor-tests/generated/StructExprField/StructExprField.ql b65375963aa24f0d1dd4c10784e32ab8c337ad431462ea1d081a0e456fbb1362 7f5a49e8df03ed0890b51c2e941d636fbbf70445a53d3af2c0f34a04f26bc6ef test/extractor-tests/generated/StructExprFieldList/StructExprFieldList.ql 01dc3ef66d79836a3d372464f05454015648ab093f9547c5d9c5d55271acb718 83625301c097fa38d4e6021ea28b8adc6338076c8c2aa88a86a22aac412839f6 test/extractor-tests/generated/StructField/StructField.ql dbdb627202975a0ca07ed441449ecc95d9d0764084a49a18e7849164b2e65ce2 8e7f32f28d15104575eaa985e892c162ec775adf3481c227ef618b5668168de7 test/extractor-tests/generated/StructFieldList/StructFieldList.ql 292170b20f3a55c0cd6a8d78ce99474ca68daf6fb380cffe00b2bd7074e1b73a 404bab780f290ae04d1d71d3c6d4e0092bb3d8c55e956168d2a445cbd6d1f06d -test/extractor-tests/generated/StructPat/StructPat.ql 894babd64d3def35717cbeed6eb4799cf9f52e73992822b72fc521c93efb4935 5bd1502b69014d70464b4b76795e1732ac2a6db5d028bea52929cf1998af5f07 +test/extractor-tests/generated/StructPat/StructPat.ql 73bd755ffb8d5ff3c77d7570c6d50eab7b51d8d4a44b638cf5904c37065f496e 9589dc8d8abd80d9f48d445af3dbdbd906a9c19dc75582688bf9c3abaa16861e test/extractor-tests/generated/StructPatField/StructPatField.ql 92cb6a4b5234359c02d66085b10d41f37b77370491ed478ad6d4d9b12b943ecf 14bc2079763b53bc6ab11356f3bb21820ae9e4dd1b2a42a78665c32181c4ef92 test/extractor-tests/generated/StructPatFieldList/StructPatFieldList.ql a3ba3e99d3c87d5e0ae0ad82cbea3600ac1745e9364d54d8d51224b51a5a09a5 5942ed2722c006bae99de9174249110bfc79594c5ef9a6dfc098ae2be269b8f3 test/extractor-tests/generated/TokenTree/TokenTree.ql 55592f43a6fe99045d0b0b1e2323211d3a3fd64a8c7d2b083f2518d4c3e2e4b0 8eeef2060c80b0918857ba9b3a8543a4b866ca04be3d5ca18aae8a26cbdb836e @@ -784,7 +787,7 @@ test/extractor-tests/generated/TupleExpr/TupleExpr.ql 4011d94438903e96fa32128555 test/extractor-tests/generated/TupleField/TupleField.ql ed681b7fee5e68d24db4999389727b2589e5af793d3c2ddc8b1e245713c0e1f8 4f867b29adf91b4bfa5052e16d392c16bf260e858aad11b60c42f1eddb476e61 test/extractor-tests/generated/TupleFieldList/TupleFieldList.ql 3c3fcef21231550bbbf6804314b94d44cc18d445987c23cb6f2c88015570cc4a 8958e6748296bc6d0ad469e52852c38445fe462a8599a2e71867aa5d7066595e test/extractor-tests/generated/TuplePat/TuplePat.ql 80609f1c525e90e13f34d55a81d47a83a03e064241f8d33232e2a79eaeea5159 d289b19dae4cbae0180cc58bb946f41646bb9dc008f5ce8a0e12eaddbc7e63e9 -test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql ea588383e16328486156e872f4d6f999a35534cde49d69b66a6186f01b1c2581 2a2e179b4241a4ff7d486e987cb667ba62025bc8dd48a507142cfec882bd35cc +test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql d00b185013bb4e5f878a5ec261ab2cfbf1fe2f67d1ad2e05d062629211f677ec 24254631a28c24ca78b4fa1b89c53b0b002cb43fe585e274155fcca0c481056c test/extractor-tests/generated/TupleTypeRepr/TupleTypeRepr.ql 2f1503734d272cd0616e5885cd344659cbd0ae7309a375c8351f57f2b86c3302 276a4fe91b8dc64cdca4467343e2bb2e240c66ec1e4e11bf8cba73819c6532cc test/extractor-tests/generated/TypeAlias/TypeAlias.ql cbd2ed23ffff6bae81b121e32c9a7efce43c23d33f82fbfcee833b1043892c60 abf9779da9ee2b267a3dc3be7143f111cac8441c378828329749457bb56aeee3 test/extractor-tests/generated/TypeArg/TypeArg.ql e1ca286c03bd2d44054f5dd75aac250382037f243046c49ec752ad8d65e4c0ba f316d5fa84a721427c0aadf6bfa0ed4cfd86e4d318cfb0fe82efc52e65c4733b diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index ff149fb36d36..88fa9904f56a 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -136,6 +136,7 @@ /lib/codeql/rust/elements/RefPat.qll linguist-generated /lib/codeql/rust/elements/RefTypeRepr.qll linguist-generated /lib/codeql/rust/elements/Rename.qll linguist-generated +/lib/codeql/rust/elements/Resolvable.qll linguist-generated /lib/codeql/rust/elements/RestPat.qll linguist-generated /lib/codeql/rust/elements/RetTypeRepr.qll linguist-generated /lib/codeql/rust/elements/ReturnExpr.qll linguist-generated @@ -368,6 +369,7 @@ /lib/codeql/rust/elements/internal/RefTypeReprImpl.qll linguist-generated /lib/codeql/rust/elements/internal/RenameConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/RenameImpl.qll linguist-generated +/lib/codeql/rust/elements/internal/ResolvableImpl.qll linguist-generated /lib/codeql/rust/elements/internal/RestPatConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/RetTypeReprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/RetTypeReprImpl.qll linguist-generated @@ -590,6 +592,7 @@ /lib/codeql/rust/elements/internal/generated/RefPat.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/Rename.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/Resolvable.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RestPat.qll linguist-generated /lib/codeql/rust/elements/internal/generated/RetTypeRepr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ReturnExpr.qll linguist-generated diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll index 9fa0f0a5a834..218907f6e94b 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll @@ -814,6 +814,7 @@ module RustDataFlow implements InputSig { // A path expression, that resolves to a function, evaluates to a function // pointer. Except if the path occurs directly in a call, then it's just a // call to the function and not a function being passed as data. + e.(PathExpr).hasResolvedPath() and resolvePath(e.(PathExpr).getPath()) = c.asCfgScope() and not any(CallExpr call).getFunction() = e ) diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll index 2763908ae02e..21bf27f9d20b 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll @@ -146,6 +146,7 @@ private module StepsInput implements Impl::Private::StepsInputSig { /** Get the callable that `expr` refers to. */ private Callable getCallable(Expr expr) { + expr.(PathExpr).hasResolvedPath() and result = resolvePath(expr.(PathExpr).getPath()).(Function) or result = expr.(ClosureExpr) diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index b42a93efc6c3..64e497000a05 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -139,6 +139,7 @@ import codeql.rust.elements.RefExpr import codeql.rust.elements.RefPat import codeql.rust.elements.RefTypeRepr import codeql.rust.elements.Rename +import codeql.rust.elements.Resolvable import codeql.rust.elements.RestPat import codeql.rust.elements.RetTypeRepr import codeql.rust.elements.ReturnExpr diff --git a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll index fca8b0861345..c3d62106100e 100644 --- a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll @@ -8,6 +8,7 @@ import codeql.rust.elements.CallExprBase import codeql.rust.elements.Expr import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef +import codeql.rust.elements.Resolvable /** * A method call expression. For example: diff --git a/rust/ql/lib/codeql/rust/elements/PathAstNode.qll b/rust/ql/lib/codeql/rust/elements/PathAstNode.qll index 2e97383cf739..c8ff02e634c8 100644 --- a/rust/ql/lib/codeql/rust/elements/PathAstNode.qll +++ b/rust/ql/lib/codeql/rust/elements/PathAstNode.qll @@ -4,8 +4,8 @@ */ private import internal.PathAstNodeImpl -import codeql.rust.elements.AstNode import codeql.rust.elements.Path +import codeql.rust.elements.Resolvable /** * An AST element wrapping a path (`PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat`). diff --git a/rust/ql/lib/codeql/rust/elements/Resolvable.qll b/rust/ql/lib/codeql/rust/elements/Resolvable.qll new file mode 100644 index 000000000000..6a2304a3be7d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Resolvable.qll @@ -0,0 +1,12 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `Resolvable`. + */ + +private import internal.ResolvableImpl +import codeql.rust.elements.AstNode + +/** + * One of `PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat` or `MethodCallExpr`. + */ +final class Resolvable = Impl::Resolvable; diff --git a/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll index 5723e1fdbb52..8c0ccb120e15 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll @@ -16,7 +16,10 @@ module Impl { private import codeql.rust.internal.PathResolution as PathResolution pragma[nomagic] - Path getFunctionPath(CallExpr ce) { result = ce.getFunction().(PathExpr).getPath() } + Path getFunctionPath(CallExpr ce) { + ce.getFunction().(PathExpr).hasResolvedPath() and + result = ce.getFunction().(PathExpr).getPath() + } pragma[nomagic] PathResolution::ItemNode getResolvedFunction(CallExpr ce) { diff --git a/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll new file mode 100644 index 000000000000..893708164d80 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll @@ -0,0 +1,19 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Resolvable`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Resolvable + +/** + * INTERNAL: This module contains the customizable definition of `Resolvable` and should not + * be referenced directly. + */ +module Impl { + /** + * One of `PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat` or `MethodCallExpr`. + */ + class Resolvable extends Generated::Resolvable { } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/StructExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/StructExprImpl.qll index 5cbeb62c7a4a..d07905a8554d 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/StructExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/StructExprImpl.qll @@ -36,6 +36,7 @@ module Impl { pragma[nomagic] private PathResolution::ItemNode getResolvedPath(string name) { + this.hasResolvedPath() and result = PathResolution::resolvePath(this.getPath()) and exists(this.getFieldExpr(name)) } diff --git a/rust/ql/lib/codeql/rust/elements/internal/StructPatImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/StructPatImpl.qll index 28afc2a5b0d7..ac77f00ab5cc 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/StructPatImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/StructPatImpl.qll @@ -29,6 +29,7 @@ module Impl { pragma[nomagic] private PathResolution::ItemNode getResolvedPath(string name) { + this.hasResolvedPath() and result = PathResolution::resolvePath(this.getPath()) and name = this.getStructPatFieldList().getAField().getFieldName() } diff --git a/rust/ql/lib/codeql/rust/elements/internal/TupleStructPatImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/TupleStructPatImpl.qll index 38259efadb74..77472ce903d3 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/TupleStructPatImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/TupleStructPatImpl.qll @@ -30,6 +30,7 @@ module Impl { pragma[nomagic] private PathResolution::ItemNode getResolvedPath(int pos) { + this.hasResolvedPath() and result = PathResolution::resolvePath(this.getPath()) and exists(this.getField(pragma[only_bind_into](pos))) } @@ -37,7 +38,10 @@ module Impl { /** * Gets the struct matched by this pattern. */ - Struct getStruct() { result = PathResolution::resolvePath(this.getPath()) } + Struct getStruct() { + this.hasResolvedPath() and + result = PathResolution::resolvePath(this.getPath()) + } /** Gets the tuple field that matches the `pos`th pattern of this pattern. */ pragma[nomagic] diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll index 8908b71b7aff..116488ae6ef1 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll @@ -10,6 +10,7 @@ import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl import codeql.rust.elements.Expr import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef +import codeql.rust.elements.internal.ResolvableImpl::Impl as ResolvableImpl /** * INTERNAL: This module contains the fully generated definition of `MethodCallExpr` and should not @@ -25,7 +26,9 @@ module Generated { * INTERNAL: Do not reference the `Generated::MethodCallExpr` class directly. * Use the subclass `MethodCallExpr`, where the following predicates are available. */ - class MethodCallExpr extends Synth::TMethodCallExpr, CallExprBaseImpl::CallExprBase { + class MethodCallExpr extends Synth::TMethodCallExpr, CallExprBaseImpl::CallExprBase, + ResolvableImpl::Resolvable + { override string getAPrimaryQlClass() { result = "MethodCallExpr" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 7b8d4d4e4627..58020fcd01e9 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -1669,18 +1669,6 @@ private module Impl { ) } - private Element getImmediateChildOfPathPat(PathPat e, int index, string partialPredicateCall) { - exists(int n, int nPath | - n = 0 and - nPath = n + 1 and - ( - none() - or - index = n and result = e.getPath() and partialPredicateCall = "Path()" - ) - ) - } - private Element getImmediateChildOfPathTypeRepr( PathTypeRepr e, int index, string partialPredicateCall ) { @@ -1882,23 +1870,6 @@ private module Impl { ) } - private Element getImmediateChildOfStructExpr(StructExpr e, int index, string partialPredicateCall) { - exists(int n, int nPath, int nStructExprFieldList | - n = 0 and - nPath = n + 1 and - nStructExprFieldList = nPath + 1 and - ( - none() - or - index = n and result = e.getPath() and partialPredicateCall = "Path()" - or - index = nPath and - result = e.getStructExprFieldList() and - partialPredicateCall = "StructExprFieldList()" - ) - ) - } - private Element getImmediateChildOfStructFieldList( StructFieldList e, int index, string partialPredicateCall ) { @@ -1914,23 +1885,6 @@ private module Impl { ) } - private Element getImmediateChildOfStructPat(StructPat e, int index, string partialPredicateCall) { - exists(int n, int nPath, int nStructPatFieldList | - n = 0 and - nPath = n + 1 and - nStructPatFieldList = nPath + 1 and - ( - none() - or - index = n and result = e.getPath() and partialPredicateCall = "Path()" - or - index = nPath and - result = e.getStructPatFieldList() and - partialPredicateCall = "StructPatFieldList()" - ) - ) - } - private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr | n = 0 and @@ -1992,24 +1946,6 @@ private module Impl { ) } - private Element getImmediateChildOfTupleStructPat( - TupleStructPat e, int index, string partialPredicateCall - ) { - exists(int n, int nPath, int nField | - n = 0 and - nPath = n + 1 and - nField = nPath + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and - ( - none() - or - index = n and result = e.getPath() and partialPredicateCall = "Path()" - or - result = e.getField(index - nPath) and - partialPredicateCall = "Field(" + (index - nPath).toString() + ")" - ) - ) - } - private Element getImmediateChildOfTupleTypeRepr( TupleTypeRepr e, int index, string partialPredicateCall ) { @@ -2497,6 +2433,52 @@ private module Impl { ) } + private Element getImmediateChildOfPathPat(PathPat e, int index, string partialPredicateCall) { + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and + ( + none() + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + ) + ) + } + + private Element getImmediateChildOfStructExpr(StructExpr e, int index, string partialPredicateCall) { + exists(int n, int nPath, int nStructExprFieldList | + n = 0 and + nPath = n + 1 and + nStructExprFieldList = nPath + 1 and + ( + none() + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + index = nPath and + result = e.getStructExprFieldList() and + partialPredicateCall = "StructExprFieldList()" + ) + ) + } + + private Element getImmediateChildOfStructPat(StructPat e, int index, string partialPredicateCall) { + exists(int n, int nPath, int nStructPatFieldList | + n = 0 and + nPath = n + 1 and + nStructPatFieldList = nPath + 1 and + ( + none() + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + index = nPath and + result = e.getStructPatFieldList() and + partialPredicateCall = "StructPatFieldList()" + ) + ) + } + private Element getImmediateChildOfTrait(Trait e, int index, string partialPredicateCall) { exists( int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList, @@ -2586,6 +2568,24 @@ private module Impl { ) } + private Element getImmediateChildOfTupleStructPat( + TupleStructPat e, int index, string partialPredicateCall + ) { + exists(int n, int nPath, int nField | + n = 0 and + nPath = n + 1 and + nField = nPath + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + ( + none() + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + result = e.getField(index - nPath) and + partialPredicateCall = "Field(" + (index - nPath).toString() + ")" + ) + ) + } + private Element getImmediateChildOfUse(Use e, int index, string partialPredicateCall) { exists(int n, int nAttributeMacroExpansion, int nAttr, int nUseTree, int nVisibility | n = 0 and @@ -3249,8 +3249,6 @@ private module Impl { or result = getImmediateChildOfParenTypeRepr(e, index, partialAccessor) or - result = getImmediateChildOfPathPat(e, index, partialAccessor) - or result = getImmediateChildOfPathTypeRepr(e, index, partialAccessor) or result = getImmediateChildOfPrefixExpr(e, index, partialAccessor) @@ -3277,12 +3275,8 @@ private module Impl { or result = getImmediateChildOfSliceTypeRepr(e, index, partialAccessor) or - result = getImmediateChildOfStructExpr(e, index, partialAccessor) - or result = getImmediateChildOfStructFieldList(e, index, partialAccessor) or - result = getImmediateChildOfStructPat(e, index, partialAccessor) - or result = getImmediateChildOfTryExpr(e, index, partialAccessor) or result = getImmediateChildOfTupleExpr(e, index, partialAccessor) @@ -3291,8 +3285,6 @@ private module Impl { or result = getImmediateChildOfTuplePat(e, index, partialAccessor) or - result = getImmediateChildOfTupleStructPat(e, index, partialAccessor) - or result = getImmediateChildOfTupleTypeRepr(e, index, partialAccessor) or result = getImmediateChildOfTypeArg(e, index, partialAccessor) @@ -3337,10 +3329,18 @@ private module Impl { or result = getImmediateChildOfPathExpr(e, index, partialAccessor) or + result = getImmediateChildOfPathPat(e, index, partialAccessor) + or + result = getImmediateChildOfStructExpr(e, index, partialAccessor) + or + result = getImmediateChildOfStructPat(e, index, partialAccessor) + or result = getImmediateChildOfTrait(e, index, partialAccessor) or result = getImmediateChildOfTraitAlias(e, index, partialAccessor) or + result = getImmediateChildOfTupleStructPat(e, index, partialAccessor) + or result = getImmediateChildOfUse(e, index, partialAccessor) or result = getImmediateChildOfConst(e, index, partialAccessor) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/PathAstNode.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/PathAstNode.qll index b250b94ef9aa..a69957e75450 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/PathAstNode.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/PathAstNode.qll @@ -6,8 +6,8 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl import codeql.rust.elements.Path +import codeql.rust.elements.internal.ResolvableImpl::Impl as ResolvableImpl /** * INTERNAL: This module contains the fully generated definition of `PathAstNode` and should not @@ -19,7 +19,7 @@ module Generated { * INTERNAL: Do not reference the `Generated::PathAstNode` class directly. * Use the subclass `PathAstNode`, where the following predicates are available. */ - class PathAstNode extends Synth::TPathAstNode, AstNodeImpl::AstNode { + class PathAstNode extends Synth::TPathAstNode, ResolvableImpl::Resolvable { /** * Gets the path of this path ast node, if it exists. */ diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index 21782ed7db43..4ba117cdc015 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -787,17 +787,6 @@ module Raw { PathSegment getSegment() { path_segments_(this, result) } } - /** - * INTERNAL: Do not use. - * An AST element wrapping a path (`PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat`). - */ - class PathAstNode extends @path_ast_node, AstNode { - /** - * Gets the path of this path ast node, if it exists. - */ - Path getPath() { path_ast_node_paths(this, result) } - } - /** * INTERNAL: Do not use. * A path segment, which is one part of a whole path. @@ -868,6 +857,22 @@ module Raw { Name getName() { rename_names(this, result) } } + /** + * INTERNAL: Do not use. + * One of `PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat` or `MethodCallExpr`. + */ + class Resolvable extends @resolvable, AstNode { + /** + * Gets the resolved path of this resolvable, if it exists. + */ + string getResolvedPath() { resolvable_resolved_paths(this, result) } + + /** + * Gets the resolved crate origin of this resolvable, if it exists. + */ + string getResolvedCrateOrigin() { resolvable_resolved_crate_origins(this, result) } + } + /** * INTERNAL: Do not use. * A return type in a function signature. @@ -2891,23 +2896,20 @@ module Raw { /** * INTERNAL: Do not use. - * A path expression or a variable access in a formatting template. See `PathExpr` and `FormatTemplateVariableAccess` for further details. + * An AST element wrapping a path (`PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat`). */ - class PathExprBase extends @path_expr_base, Expr { } + class PathAstNode extends @path_ast_node, Resolvable { + /** + * Gets the path of this path ast node, if it exists. + */ + Path getPath() { path_ast_node_paths(this, result) } + } /** * INTERNAL: Do not use. - * A path pattern. For example: - * ```rust - * match x { - * Foo::Bar => "ok", - * _ => "fail", - * } - * ``` + * A path expression or a variable access in a formatting template. See `PathExpr` and `FormatTemplateVariableAccess` for further details. */ - class PathPat extends @path_pat, Pat, PathAstNode { - override string toString() { result = "PathPat" } - } + class PathExprBase extends @path_expr_base, Expr { } /** * INTERNAL: Do not use. @@ -3267,27 +3269,6 @@ module Raw { TypeRepr getTypeRepr() { slice_type_repr_type_reprs(this, result) } } - /** - * INTERNAL: Do not use. - * A struct expression. For example: - * ```rust - * let first = Foo { a: 1, b: 2 }; - * let second = Foo { a: 2, ..first }; - * let n = Foo { a: 1, b: 2 }.b; - * Foo { a: m, .. } = second; - * ``` - */ - class StructExpr extends @struct_expr, Expr, PathAstNode { - override string toString() { result = "StructExpr" } - - /** - * Gets the struct expression field list of this struct expression, if it exists. - */ - StructExprFieldList getStructExprFieldList() { - struct_expr_struct_expr_field_lists(this, result) - } - } - /** * INTERNAL: Do not use. * A list of fields in a struct declaration. @@ -3307,25 +3288,6 @@ module Raw { StructField getField(int index) { struct_field_list_fields(this, index, result) } } - /** - * INTERNAL: Do not use. - * A struct pattern. For example: - * ```rust - * match x { - * Foo { a: 1, b: 2 } => "ok", - * Foo { .. } => "fail", - * } - * ``` - */ - class StructPat extends @struct_pat, Pat, PathAstNode { - override string toString() { result = "StructPat" } - - /** - * Gets the struct pattern field list of this struct pattern, if it exists. - */ - StructPatFieldList getStructPatFieldList() { struct_pat_struct_pat_field_lists(this, result) } - } - /** * INTERNAL: Do not use. * A try expression using the `?` operator. @@ -3409,26 +3371,6 @@ module Raw { Pat getField(int index) { tuple_pat_fields(this, index, result) } } - /** - * INTERNAL: Do not use. - * A tuple struct pattern. For example: - * ```rust - * match x { - * Tuple("a", 1, 2, 3) => "great", - * Tuple(.., 3) => "fine", - * Tuple(..) => "fail", - * }; - * ``` - */ - class TupleStructPat extends @tuple_struct_pat, Pat, PathAstNode { - override string toString() { result = "TupleStructPat" } - - /** - * Gets the `index`th field of this tuple struct pattern (0-based). - */ - Pat getField(int index) { tuple_struct_pat_fields(this, index, result) } - } - /** * INTERNAL: Do not use. * A tuple type. @@ -3987,7 +3929,7 @@ module Raw { * x.foo::(42); * ``` */ - class MethodCallExpr extends @method_call_expr, CallExprBase { + class MethodCallExpr extends @method_call_expr, CallExprBase, Resolvable { override string toString() { result = "MethodCallExpr" } /** @@ -4061,6 +4003,60 @@ module Raw { Attr getAttr(int index) { path_expr_attrs(this, index, result) } } + /** + * INTERNAL: Do not use. + * A path pattern. For example: + * ```rust + * match x { + * Foo::Bar => "ok", + * _ => "fail", + * } + * ``` + */ + class PathPat extends @path_pat, Pat, PathAstNode { + override string toString() { result = "PathPat" } + } + + /** + * INTERNAL: Do not use. + * A struct expression. For example: + * ```rust + * let first = Foo { a: 1, b: 2 }; + * let second = Foo { a: 2, ..first }; + * let n = Foo { a: 1, b: 2 }.b; + * Foo { a: m, .. } = second; + * ``` + */ + class StructExpr extends @struct_expr, Expr, PathAstNode { + override string toString() { result = "StructExpr" } + + /** + * Gets the struct expression field list of this struct expression, if it exists. + */ + StructExprFieldList getStructExprFieldList() { + struct_expr_struct_expr_field_lists(this, result) + } + } + + /** + * INTERNAL: Do not use. + * A struct pattern. For example: + * ```rust + * match x { + * Foo { a: 1, b: 2 } => "ok", + * Foo { .. } => "fail", + * } + * ``` + */ + class StructPat extends @struct_pat, Pat, PathAstNode { + override string toString() { result = "StructPat" } + + /** + * Gets the struct pattern field list of this struct pattern, if it exists. + */ + StructPatFieldList getStructPatFieldList() { struct_pat_struct_pat_field_lists(this, result) } + } + /** * INTERNAL: Do not use. * A Trait. For example: @@ -4166,6 +4162,26 @@ module Raw { WhereClause getWhereClause() { trait_alias_where_clauses(this, result) } } + /** + * INTERNAL: Do not use. + * A tuple struct pattern. For example: + * ```rust + * match x { + * Tuple("a", 1, 2, 3) => "great", + * Tuple(.., 3) => "fine", + * Tuple(..) => "fail", + * }; + * ``` + */ + class TupleStructPat extends @tuple_struct_pat, Pat, PathAstNode { + override string toString() { result = "TupleStructPat" } + + /** + * Gets the `index`th field of this tuple struct pattern (0-based). + */ + Pat getField(int index) { tuple_struct_pat_fields(this, index, result) } + } + /** * INTERNAL: Do not use. * A `use` statement. For example: diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll new file mode 100644 index 000000000000..fb0d7975cf9b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Resolvable.qll @@ -0,0 +1,52 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `Resolvable`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.elements.internal.generated.Synth +private import codeql.rust.elements.internal.generated.Raw +import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl + +/** + * INTERNAL: This module contains the fully generated definition of `Resolvable` and should not + * be referenced directly. + */ +module Generated { + /** + * One of `PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat` or `MethodCallExpr`. + * INTERNAL: Do not reference the `Generated::Resolvable` class directly. + * Use the subclass `Resolvable`, where the following predicates are available. + */ + class Resolvable extends Synth::TResolvable, AstNodeImpl::AstNode { + /** + * Gets the resolved path of this resolvable, if it exists. + * + * INTERNAL: Do not use. + */ + string getResolvedPath() { + result = Synth::convertResolvableToRaw(this).(Raw::Resolvable).getResolvedPath() + } + + /** + * Holds if `getResolvedPath()` exists. + * INTERNAL: Do not use. + */ + final predicate hasResolvedPath() { exists(this.getResolvedPath()) } + + /** + * Gets the resolved crate origin of this resolvable, if it exists. + * + * INTERNAL: Do not use. + */ + string getResolvedCrateOrigin() { + result = Synth::convertResolvableToRaw(this).(Raw::Resolvable).getResolvedCrateOrigin() + } + + /** + * Holds if `getResolvedCrateOrigin()` exists. + * INTERNAL: Do not use. + */ + final predicate hasResolvedCrateOrigin() { exists(this.getResolvedCrateOrigin()) } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll index 9ed7961f63ce..42d5c99eb0a0 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -722,8 +722,8 @@ module Synth { TExternItemList or TFieldList or TForBinder or TFormatArgsArg or TGenericArg or TGenericArgList or TGenericParam or TGenericParamList or TItemList or TLabel or TLetElse or TMacroItems or TMatchArm or TMatchArmList or TMatchGuard or TMeta or TName or TParamBase or - TParamList or TParenthesizedArgList or TPat or TPath or TPathAstNode or TPathSegment or - TRename or TRetTypeRepr or TReturnTypeSyntax or TSourceFile or TStmt or TStmtList or + TParamList or TParenthesizedArgList or TPat or TPath or TPathSegment or TRename or + TResolvable or TRetTypeRepr or TReturnTypeSyntax or TSourceFile or TStmt or TStmtList or TStructExprField or TStructExprFieldList or TStructField or TStructPatField or TStructPatFieldList or TToken or TTokenTree or TTupleField or TTypeBound or TTypeBoundList or TTypeRepr or TUseBoundGenericArg or TUseBoundGenericArgs or TUseTree or @@ -815,6 +815,11 @@ module Synth { */ class TPathExprBase = TFormatTemplateVariableAccess or TPathExpr; + /** + * INTERNAL: Do not use. + */ + class TResolvable = TMethodCallExpr or TPathAstNode; + /** * INTERNAL: Do not use. */ @@ -1994,12 +1999,12 @@ module Synth { or result = convertPathFromRaw(e) or - result = convertPathAstNodeFromRaw(e) - or result = convertPathSegmentFromRaw(e) or result = convertRenameFromRaw(e) or + result = convertResolvableFromRaw(e) + or result = convertRetTypeReprFromRaw(e) or result = convertReturnTypeSyntaxFromRaw(e) @@ -2349,6 +2354,16 @@ module Synth { result = convertPathExprFromRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TResolvable`, if possible. + */ + TResolvable convertResolvableFromRaw(Raw::Element e) { + result = convertMethodCallExprFromRaw(e) + or + result = convertPathAstNodeFromRaw(e) + } + /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TStmt`, if possible. @@ -3570,12 +3585,12 @@ module Synth { or result = convertPathToRaw(e) or - result = convertPathAstNodeToRaw(e) - or result = convertPathSegmentToRaw(e) or result = convertRenameToRaw(e) or + result = convertResolvableToRaw(e) + or result = convertRetTypeReprToRaw(e) or result = convertReturnTypeSyntaxToRaw(e) @@ -3925,6 +3940,16 @@ module Synth { result = convertPathExprToRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a synthesized `TResolvable` to a raw DB element, if possible. + */ + Raw::Element convertResolvableToRaw(TResolvable e) { + result = convertMethodCallExprToRaw(e) + or + result = convertPathAstNodeToRaw(e) + } + /** * INTERNAL: Do not use. * Converts a synthesized `TStmt` to a raw DB element, if possible. diff --git a/rust/ql/lib/codeql/rust/internal/TypeInference.qll b/rust/ql/lib/codeql/rust/internal/TypeInference.qll index 905175803a24..a8b0ed6f6b40 100644 --- a/rust/ql/lib/codeql/rust/internal/TypeInference.qll +++ b/rust/ql/lib/codeql/rust/internal/TypeInference.qll @@ -3215,6 +3215,7 @@ private module Cached { /** Gets an item (function or tuple struct/variant) that `call` resolves to, if any. */ cached Addressable resolveCallTarget(Call call) { + call.(Resolvable).hasResolvedPath() and result = call.(MethodResolution::MethodCall).resolveCallTarget(_, _) or result = call.(NonMethodResolution::NonMethodCall).resolveCallTarget() diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index 30a0713e5bf6..e41b50d3723e 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -200,9 +200,9 @@ named_crates( | @parenthesized_arg_list | @pat | @path -| @path_ast_node | @path_segment | @rename +| @resolvable | @ret_type_repr | @return_type_syntax | @source_file @@ -735,20 +735,6 @@ path_segments_( int segment: @path_segment ref ); -@path_ast_node = - @path_expr -| @path_pat -| @struct_expr -| @struct_pat -| @tuple_struct_pat -; - -#keyset[id] -path_ast_node_paths( - int id: @path_ast_node ref, - int path: @path ref -); - path_segments( unique int id: @path_segment ); @@ -805,6 +791,23 @@ rename_names( int name: @name ref ); +@resolvable = + @method_call_expr +| @path_ast_node +; + +#keyset[id] +resolvable_resolved_paths( + int id: @resolvable ref, + string resolved_path: string ref +); + +#keyset[id] +resolvable_resolved_crate_origins( + int id: @resolvable ref, + string resolved_crate_origin: string ref +); + ret_type_reprs( unique int id: @ret_type_repr ); @@ -2196,14 +2199,24 @@ paren_type_repr_type_reprs( int type_repr: @type_repr ref ); -@path_expr_base = +@path_ast_node = @path_expr +| @path_pat +| @struct_expr +| @struct_pat +| @tuple_struct_pat ; -path_pats( - unique int id: @path_pat +#keyset[id] +path_ast_node_paths( + int id: @path_ast_node ref, + int path: @path ref ); +@path_expr_base = + @path_expr +; + path_type_reprs( unique int id: @path_type_repr ); @@ -2451,16 +2464,6 @@ slice_type_repr_type_reprs( int type_repr: @type_repr ref ); -struct_exprs( - unique int id: @struct_expr -); - -#keyset[id] -struct_expr_struct_expr_field_lists( - int id: @struct_expr ref, - int struct_expr_field_list: @struct_expr_field_list ref -); - struct_field_lists( unique int id: @struct_field_list ); @@ -2472,16 +2475,6 @@ struct_field_list_fields( int field: @struct_field ref ); -struct_pats( - unique int id: @struct_pat -); - -#keyset[id] -struct_pat_struct_pat_field_lists( - int id: @struct_pat ref, - int struct_pat_field_list: @struct_pat_field_list ref -); - try_exprs( unique int id: @try_expr ); @@ -2539,17 +2532,6 @@ tuple_pat_fields( int field: @pat ref ); -tuple_struct_pats( - unique int id: @tuple_struct_pat -); - -#keyset[id, index] -tuple_struct_pat_fields( - int id: @tuple_struct_pat ref, - int index: int ref, - int field: @pat ref -); - tuple_type_reprs( unique int id: @tuple_type_repr ); @@ -3050,6 +3032,30 @@ path_expr_attrs( int attr: @attr ref ); +path_pats( + unique int id: @path_pat +); + +struct_exprs( + unique int id: @struct_expr +); + +#keyset[id] +struct_expr_struct_expr_field_lists( + int id: @struct_expr ref, + int struct_expr_field_list: @struct_expr_field_list ref +); + +struct_pats( + unique int id: @struct_pat +); + +#keyset[id] +struct_pat_struct_pat_field_lists( + int id: @struct_pat ref, + int struct_pat_field_list: @struct_pat_field_list ref +); + traits( unique int id: @trait ); @@ -3148,6 +3154,17 @@ trait_alias_where_clauses( int where_clause: @where_clause ref ); +tuple_struct_pats( + unique int id: @tuple_struct_pat +); + +#keyset[id, index] +tuple_struct_pat_fields( + int id: @tuple_struct_pat ref, + int index: int ref, + int field: @pat ref +); + uses( unique int id: @use ); diff --git a/rust/ql/src/queries/telemetry/DatabaseQuality.qll b/rust/ql/src/queries/telemetry/DatabaseQuality.qll index 64adf9826dc1..16adcbc2040a 100644 --- a/rust/ql/src/queries/telemetry/DatabaseQuality.qll +++ b/rust/ql/src/queries/telemetry/DatabaseQuality.qll @@ -21,7 +21,10 @@ private class RelevantFile extends File { module CallTargetStats implements StatsSig { int getNumberOfOk() { result = - count(CallExprBase c | c.getFile() instanceof RelevantFile and exists(c.getStaticTarget())) + count(CallExprBase c | + c.getFile() instanceof RelevantFile and + c.(Resolvable).hasResolvedPath() + ) } private predicate isLambdaCall(CallExpr call) { @@ -33,7 +36,7 @@ module CallTargetStats implements StatsSig { additional predicate isNotOkCall(CallExprBase c) { c.getFile() instanceof RelevantFile and - not exists(c.getStaticTarget()) and + not c.(Resolvable).hasResolvedPath() and not isLambdaCall(c) } diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected index 0eedcc70b5d2..61054a3841ad 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected @@ -8,6 +8,8 @@ getAttr getArg | gen_method_call_expr.rs:5:5:5:13 | x.foo(...) | 0 | gen_method_call_expr.rs:5:11:5:12 | 42 | | gen_method_call_expr.rs:6:5:6:25 | x.foo(...) | 0 | gen_method_call_expr.rs:6:23:6:24 | 42 | +getResolvedPath +getResolvedCrateOrigin getGenericArgList | gen_method_call_expr.rs:6:5:6:25 | x.foo(...) | gen_method_call_expr.rs:6:10:6:21 | <...> | getIdentifier diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql index d1b6d5a13046..73ddf8e7d2e8 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql @@ -16,6 +16,14 @@ query predicate getArg(MethodCallExpr x, int index, Expr getArg) { toBeTested(x) and not x.isUnknown() and getArg = x.getArg(index) } +query predicate getResolvedPath(MethodCallExpr x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(MethodCallExpr x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getGenericArgList(MethodCallExpr x, GenericArgList getGenericArgList) { toBeTested(x) and not x.isUnknown() and getGenericArgList = x.getGenericArgList() } diff --git a/rust/ql/test/extractor-tests/generated/Path/PathExpr.expected b/rust/ql/test/extractor-tests/generated/Path/PathExpr.expected index 9a26eca5b66d..5a2df7ee29f9 100644 --- a/rust/ql/test/extractor-tests/generated/Path/PathExpr.expected +++ b/rust/ql/test/extractor-tests/generated/Path/PathExpr.expected @@ -5,6 +5,8 @@ instances | gen_path_expr.rs:7:13:7:20 | ...::foo | | gen_path_expr.rs:8:13:8:36 | ...::foo | | gen_path_pat.rs:5:11:5:11 | x | +getResolvedPath +getResolvedCrateOrigin getPath | gen_path.rs:6:5:6:12 | ...::bar | gen_path.rs:6:5:6:12 | ...::bar | | gen_path_expr.rs:5:13:5:20 | variable | gen_path_expr.rs:5:13:5:20 | variable | diff --git a/rust/ql/test/extractor-tests/generated/Path/PathExpr.ql b/rust/ql/test/extractor-tests/generated/Path/PathExpr.ql index 87017b801ec5..70bff600ace0 100644 --- a/rust/ql/test/extractor-tests/generated/Path/PathExpr.ql +++ b/rust/ql/test/extractor-tests/generated/Path/PathExpr.ql @@ -4,6 +4,14 @@ import TestUtils query predicate instances(PathExpr x) { toBeTested(x) and not x.isUnknown() } +query predicate getResolvedPath(PathExpr x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(PathExpr x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getPath(PathExpr x, Path getPath) { toBeTested(x) and not x.isUnknown() and getPath = x.getPath() } diff --git a/rust/ql/test/extractor-tests/generated/Path/PathPat.expected b/rust/ql/test/extractor-tests/generated/Path/PathPat.expected index d211f4c05d2f..9bcce9035582 100644 --- a/rust/ql/test/extractor-tests/generated/Path/PathPat.expected +++ b/rust/ql/test/extractor-tests/generated/Path/PathPat.expected @@ -1,4 +1,6 @@ instances | gen_path_pat.rs:6:9:6:16 | ...::Bar | +getResolvedPath +getResolvedCrateOrigin getPath | gen_path_pat.rs:6:9:6:16 | ...::Bar | gen_path_pat.rs:6:9:6:16 | ...::Bar | diff --git a/rust/ql/test/extractor-tests/generated/Path/PathPat.ql b/rust/ql/test/extractor-tests/generated/Path/PathPat.ql index 78138ed5d82d..9c5a874cabf5 100644 --- a/rust/ql/test/extractor-tests/generated/Path/PathPat.ql +++ b/rust/ql/test/extractor-tests/generated/Path/PathPat.ql @@ -4,6 +4,14 @@ import TestUtils query predicate instances(PathPat x) { toBeTested(x) and not x.isUnknown() } +query predicate getResolvedPath(PathPat x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(PathPat x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getPath(PathPat x, Path getPath) { toBeTested(x) and not x.isUnknown() and getPath = x.getPath() } diff --git a/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.expected b/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.expected index 988d3ec6299f..23e4e3e49171 100644 --- a/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.expected +++ b/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.expected @@ -3,6 +3,8 @@ instances | gen_struct_expr.rs:6:18:6:38 | Foo {...} | | gen_struct_expr.rs:7:13:7:30 | Foo {...} | | gen_struct_expr.rs:8:5:8:20 | Foo {...} | +getResolvedPath +getResolvedCrateOrigin getPath | gen_struct_expr.rs:5:17:5:34 | Foo {...} | gen_struct_expr.rs:5:17:5:19 | Foo | | gen_struct_expr.rs:6:18:6:38 | Foo {...} | gen_struct_expr.rs:6:18:6:20 | Foo | diff --git a/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.ql b/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.ql index 858a0812024f..4a71efa31ee6 100644 --- a/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.ql +++ b/rust/ql/test/extractor-tests/generated/StructExpr/StructExpr.ql @@ -4,6 +4,14 @@ import TestUtils query predicate instances(StructExpr x) { toBeTested(x) and not x.isUnknown() } +query predicate getResolvedPath(StructExpr x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(StructExpr x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getPath(StructExpr x, Path getPath) { toBeTested(x) and not x.isUnknown() and getPath = x.getPath() } diff --git a/rust/ql/test/extractor-tests/generated/StructPat/StructPat.expected b/rust/ql/test/extractor-tests/generated/StructPat/StructPat.expected index 5f1a7bed8442..894e52fb1965 100644 --- a/rust/ql/test/extractor-tests/generated/StructPat/StructPat.expected +++ b/rust/ql/test/extractor-tests/generated/StructPat/StructPat.expected @@ -1,6 +1,8 @@ instances | gen_struct_pat.rs:6:9:6:26 | Foo {...} | | gen_struct_pat.rs:7:9:7:18 | Foo {...} | +getResolvedPath +getResolvedCrateOrigin getPath | gen_struct_pat.rs:6:9:6:26 | Foo {...} | gen_struct_pat.rs:6:9:6:11 | Foo | | gen_struct_pat.rs:7:9:7:18 | Foo {...} | gen_struct_pat.rs:7:9:7:11 | Foo | diff --git a/rust/ql/test/extractor-tests/generated/StructPat/StructPat.ql b/rust/ql/test/extractor-tests/generated/StructPat/StructPat.ql index d117695d0902..4aad29aede9c 100644 --- a/rust/ql/test/extractor-tests/generated/StructPat/StructPat.ql +++ b/rust/ql/test/extractor-tests/generated/StructPat/StructPat.ql @@ -4,6 +4,14 @@ import TestUtils query predicate instances(StructPat x) { toBeTested(x) and not x.isUnknown() } +query predicate getResolvedPath(StructPat x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(StructPat x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getPath(StructPat x, Path getPath) { toBeTested(x) and not x.isUnknown() and getPath = x.getPath() } diff --git a/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.expected b/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.expected index dcefb6cb7a49..c5ce2e2640a0 100644 --- a/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.expected +++ b/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.expected @@ -2,6 +2,8 @@ instances | gen_tuple_struct_pat.rs:6:9:6:27 | Tuple(...) | | gen_tuple_struct_pat.rs:7:9:7:20 | Tuple(...) | | gen_tuple_struct_pat.rs:8:9:8:17 | Tuple(...) | +getResolvedPath +getResolvedCrateOrigin getPath | gen_tuple_struct_pat.rs:6:9:6:27 | Tuple(...) | gen_tuple_struct_pat.rs:6:9:6:13 | Tuple | | gen_tuple_struct_pat.rs:7:9:7:20 | Tuple(...) | gen_tuple_struct_pat.rs:7:9:7:13 | Tuple | diff --git a/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql b/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql index e6bde1d82aaa..408c892ea3cd 100644 --- a/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql +++ b/rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql @@ -4,6 +4,14 @@ import TestUtils query predicate instances(TupleStructPat x) { toBeTested(x) and not x.isUnknown() } +query predicate getResolvedPath(TupleStructPat x, string getResolvedPath) { + toBeTested(x) and not x.isUnknown() and getResolvedPath = x.getResolvedPath() +} + +query predicate getResolvedCrateOrigin(TupleStructPat x, string getResolvedCrateOrigin) { + toBeTested(x) and not x.isUnknown() and getResolvedCrateOrigin = x.getResolvedCrateOrigin() +} + query predicate getPath(TupleStructPat x, Path getPath) { toBeTested(x) and not x.isUnknown() and getPath = x.getPath() } diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index 5861ede759b7..1db03397287f 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -252,7 +252,7 @@ class _: attrs: drop -@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}, cfg=True) +@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}, add_bases=(Resolvable,), cfg=True) class _: """ A method call expression. For example: diff --git a/rust/schema/prelude.py b/rust/schema/prelude.py index 9ca62f33acc1..33e7b88990bf 100644 --- a/rust/schema/prelude.py +++ b/rust/schema/prelude.py @@ -84,8 +84,14 @@ class Addressable(AstNode): TODO: This does not yet include all possible cases. """ +class Resolvable(AstNode): + """ + One of `PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat` or `MethodCallExpr`. + """ + resolved_path: optional[string] | rust.detach | ql.internal + resolved_crate_origin: optional[string] | rust.detach | ql.internal -class PathAstNode(AstNode): +class PathAstNode(Resolvable): """ An AST element wrapping a path (`PathExpr`, `RecordExpr`, `PathPat`, `RecordPat`, `TupleStructPat`). """