Rust: expand derive macros

This commit is contained in:
Paolo Tranquilli
2025-06-20 11:19:06 +02:00
parent cdd6245b98
commit e935bd6faf
32 changed files with 2856 additions and 794 deletions

View File

@@ -66,6 +66,20 @@ impl {{name}} {
pub fn emit_{{singular_field_name}}(id: trap::Label<Self>{{^is_predicate}}{{#is_repeated}}{{^is_unordered}}, i: usize{{/is_unordered}}{{/is_repeated}}, value: {{base_type}}{{/is_predicate}}, out: &mut trap::Writer) {
out.add_tuple("{{table_name}}", vec![id.into(){{^is_predicate}}{{#is_repeated}}{{^is_unordered}}, i.into(){{/is_unordered}}{{/is_repeated}}, value.into(){{/is_predicate}}]);
}
{{#is_repeated}}
pub fn emit_{{field_name}}(id: trap::Label<Self>, values: impl IntoIterator<Item={{base_type}}>, out: &mut trap::Writer) {
values
.into_iter()
{{^is_unordered}}
.enumerate()
.for_each(|(i, value)| Self::emit_{{singular_field_name}}(id, i, value, out));
{{/is_unordered}}
{{#is_unordered}}
.for_each(|value| Self::emit_{{singular_field_name}}(id, value, out));
{{/is_unordered}}
}
{{/is_repeated}}
{{/detached_fields}}
}
{{/has_detached_fields}}

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs 69c1fcaf0efea87feb898f32fdb7bcb842a22119b69ecedd61c2d946eb7e67de 69c1fcaf0efea87feb898f32fdb7bcb842a22119b69ecedd61c2d946eb7e67de
top.rs 78da6fde6bc6f66baf63b298b3d565d6a057b54e891f739a3510aff4563a9f1b 78da6fde6bc6f66baf63b298b3d565d6a057b54e891f739a3510aff4563a9f1b

View File

@@ -335,9 +335,11 @@ impl Addressable {
pub fn emit_extended_canonical_path(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("addressable_extended_canonical_paths", vec![id.into(), value.into()]);
}
pub fn emit_crate_origin(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("addressable_crate_origins", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for Addressable {
@@ -2058,9 +2060,11 @@ impl PathSegment {
pub fn emit_type_repr(id: trap::Label<Self>, value: trap::Label<TypeRepr>, out: &mut trap::Writer) {
out.add_tuple("path_segment_type_reprs", vec![id.into(), value.into()]);
}
pub fn emit_trait_type_repr(id: trap::Label<Self>, value: trap::Label<PathTypeRepr>, out: &mut trap::Writer) {
out.add_tuple("path_segment_trait_type_reprs", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for PathSegment {
@@ -2153,9 +2157,11 @@ impl Resolvable {
pub fn emit_resolved_path(id: trap::Label<Self>, 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<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("resolvable_resolved_crate_origins", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for Resolvable {
@@ -5764,6 +5770,7 @@ impl Item {
pub fn emit_attribute_macro_expansion(id: trap::Label<Self>, value: trap::Label<MacroItems>, out: &mut trap::Writer) {
out.add_tuple("item_attribute_macro_expansions", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for Item {
@@ -8865,6 +8872,82 @@ impl From<trap::Label<YieldExpr>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct Adt {
_unused: ()
}
impl Adt {
pub fn emit_derive_macro_expansion(id: trap::Label<Self>, i: usize, value: trap::Label<MacroItems>, out: &mut trap::Writer) {
out.add_tuple("adt_derive_macro_expansions", vec![id.into(), i.into(), value.into()]);
}
pub fn emit_derive_macro_expansions(id: trap::Label<Self>, values: impl IntoIterator<Item=trap::Label<MacroItems>>, out: &mut trap::Writer) {
values
.into_iter()
.enumerate()
.for_each(|(i, value)| Self::emit_derive_macro_expansion(id, i, value, out));
}
}
impl trap::TrapClass for Adt {
fn class_name() -> &'static str { "Adt" }
}
impl From<trap::Label<Adt>> for trap::Label<Item> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Adt>> for trap::Label<Stmt> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Adt>> for trap::Label<AstNode> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Adt>> for trap::Label<Locatable> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Adt>> for trap::Label<Element> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Adt>> for trap::Label<Addressable> {
fn from(value: trap::Label<Adt>) -> Self {
// SAFETY: this is safe because in the dbscheme Adt is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct BlockExpr {
pub id: trap::TrapId<BlockExpr>,
@@ -9088,6 +9171,7 @@ impl Const {
pub fn emit_has_implementation(id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("const_has_implementation", vec![id.into()]);
}
}
impl trap::TrapClass for Const {
@@ -9157,103 +9241,6 @@ impl From<trap::Label<Const>> for trap::Label<Addressable> {
}
}
#[derive(Debug)]
pub struct Enum {
pub id: trap::TrapId<Enum>,
pub attrs: Vec<trap::Label<Attr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub variant_list: Option<trap::Label<VariantList>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Enum {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("enums", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("enum_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("enum_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("enum_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.variant_list {
out.add_tuple("enum_variant_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("enum_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("enum_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Enum {
fn class_name() -> &'static str { "Enum" }
}
impl From<trap::Label<Enum>> for trap::Label<Item> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Stmt> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<AstNode> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Locatable> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Element> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Addressable> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct ExternBlock {
pub id: trap::TrapId<ExternBlock>,
@@ -9507,6 +9494,7 @@ impl Function {
pub fn emit_has_implementation(id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("function_has_implementation", vec![id.into()]);
}
}
impl trap::TrapClass for Function {
@@ -9792,6 +9780,7 @@ impl MacroCall {
pub fn emit_macro_call_expansion(id: trap::Label<Self>, value: trap::Label<AstNode>, out: &mut trap::Writer) {
out.add_tuple("macro_call_macro_call_expansions", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for MacroCall {
@@ -10515,112 +10504,6 @@ impl From<trap::Label<Static>> for trap::Label<Addressable> {
}
}
#[derive(Debug)]
pub struct Struct {
pub id: trap::TrapId<Struct>,
pub attrs: Vec<trap::Label<Attr>>,
pub field_list: Option<trap::Label<FieldList>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Struct {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("structs", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("struct_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.field_list {
out.add_tuple("struct_field_lists_", vec![id.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("struct_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("struct_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("struct_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("struct_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Struct {
fn class_name() -> &'static str { "Struct" }
}
impl From<trap::Label<Struct>> for trap::Label<Item> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Stmt> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<AstNode> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Locatable> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Element> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Addressable> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<VariantDef> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of VariantDef
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct StructExpr {
pub id: trap::TrapId<StructExpr>,
@@ -11193,112 +11076,6 @@ impl From<trap::Label<TypeAlias>> for trap::Label<Addressable> {
}
}
#[derive(Debug)]
pub struct Union {
pub id: trap::TrapId<Union>,
pub attrs: Vec<trap::Label<Attr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub struct_field_list: Option<trap::Label<StructFieldList>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Union {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("unions", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("union_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("union_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("union_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_field_list {
out.add_tuple("union_struct_field_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("union_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("union_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Union {
fn class_name() -> &'static str { "Union" }
}
impl From<trap::Label<Union>> for trap::Label<Item> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Stmt> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<AstNode> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Locatable> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Element> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Addressable> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<VariantDef> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of VariantDef
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct Use {
pub id: trap::TrapId<Use>,
@@ -11384,6 +11161,112 @@ impl From<trap::Label<Use>> for trap::Label<Addressable> {
}
}
#[derive(Debug)]
pub struct Enum {
pub id: trap::TrapId<Enum>,
pub attrs: Vec<trap::Label<Attr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub variant_list: Option<trap::Label<VariantList>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Enum {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("enums", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("enum_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("enum_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("enum_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.variant_list {
out.add_tuple("enum_variant_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("enum_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("enum_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Enum {
fn class_name() -> &'static str { "Enum" }
}
impl From<trap::Label<Enum>> for trap::Label<Adt> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Adt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Item> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Stmt> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<AstNode> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Locatable> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Element> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Enum>> for trap::Label<Addressable> {
fn from(value: trap::Label<Enum>) -> Self {
// SAFETY: this is safe because in the dbscheme Enum is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct ForExpr {
pub id: trap::TrapId<ForExpr>,
@@ -11562,6 +11445,236 @@ impl From<trap::Label<LoopExpr>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct Struct {
pub id: trap::TrapId<Struct>,
pub attrs: Vec<trap::Label<Attr>>,
pub field_list: Option<trap::Label<FieldList>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Struct {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("structs", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("struct_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.field_list {
out.add_tuple("struct_field_lists_", vec![id.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("struct_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("struct_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("struct_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("struct_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Struct {
fn class_name() -> &'static str { "Struct" }
}
impl From<trap::Label<Struct>> for trap::Label<Adt> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Adt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Item> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Stmt> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<AstNode> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Locatable> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Element> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<Addressable> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Struct>> for trap::Label<VariantDef> {
fn from(value: trap::Label<Struct>) -> Self {
// SAFETY: this is safe because in the dbscheme Struct is a subclass of VariantDef
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct Union {
pub id: trap::TrapId<Union>,
pub attrs: Vec<trap::Label<Attr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub name: Option<trap::Label<Name>>,
pub struct_field_list: Option<trap::Label<StructFieldList>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
impl trap::TrapEntry for Union {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("unions", vec![id.into()]);
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("union_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("union_generic_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.name {
out.add_tuple("union_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_field_list {
out.add_tuple("union_struct_field_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("union_visibilities", vec![id.into(), v.into()]);
}
if let Some(v) = self.where_clause {
out.add_tuple("union_where_clauses", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for Union {
fn class_name() -> &'static str { "Union" }
}
impl From<trap::Label<Union>> for trap::Label<Adt> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Adt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Item> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Item
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Stmt> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Stmt
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<AstNode> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Locatable> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Element> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<Addressable> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of Addressable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Union>> for trap::Label<VariantDef> {
fn from(value: trap::Label<Union>) -> Self {
// SAFETY: this is safe because in the dbscheme Union is a subclass of VariantDef
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct WhileExpr {
pub id: trap::TrapId<WhileExpr>,

View File

@@ -16,7 +16,7 @@ use ra_ap_ide_db::RootDatabase;
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
use ra_ap_parser::SyntaxKind;
use ra_ap_span::TextSize;
use ra_ap_syntax::ast::HasName;
use ra_ap_syntax::ast::{HasAttrs, HasName};
use ra_ap_syntax::{
AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken, TextRange,
ast,
@@ -45,12 +45,15 @@ macro_rules! post_emit {
$self.extract_canonical_origin($node, $label.into());
};
(Struct, $self:ident, $node:ident, $label:ident) => {
$self.emit_derive_expansion($node, $label);
$self.extract_canonical_origin($node, $label.into());
};
(Enum, $self:ident, $node:ident, $label:ident) => {
$self.emit_derive_expansion($node, $label);
$self.extract_canonical_origin($node, $label.into());
};
(Union, $self:ident, $node:ident, $label:ident) => {
$self.emit_derive_expansion($node, $label);
$self.extract_canonical_origin($node, $label.into());
};
(Module, $self:ident, $node:ident, $label:ident) => {
@@ -250,6 +253,25 @@ impl<'a> Translator<'a> {
.emit_diagnostic(severity, tag, message, full_message, location);
}
}
pub fn emit_diagnostic_for_node(
&mut self,
node: &impl ast::AstNode,
severity: DiagnosticSeverity,
tag: String,
message: String,
full_message: String,
) {
let location = self.location_for_node(node);
self.emit_diagnostic(
severity,
tag,
message,
full_message,
location.unwrap_or(UNKNOWN_LOCATION),
);
}
pub fn emit_parse_error(&mut self, owner: &impl ast::AstNode, err: &SyntaxError) {
let owner_range: TextRange = owner.syntax().text_range();
let err_range = err.range();
@@ -726,6 +748,39 @@ impl<'a> Translator<'a> {
None
}
fn process_item_macro_expansion(
&mut self,
node: &impl ast::AstNode,
ExpandResult { value, err }: ExpandResult<SyntaxNode>,
) -> Option<Label<generated::MacroItems>> {
let semantics = self.semantics.unwrap(); // if we are here, we have semantics
self.emit_macro_expansion_parse_errors(node, &value);
if let Some(err) = err {
let rendered = err.render_to_string(semantics.db);
self.emit_diagnostic_for_node(
node,
DiagnosticSeverity::Warning,
"item_expansion".to_owned(),
format!("item expansion failed ({})", rendered.kind),
rendered.message,
);
}
if let Some(items) = ast::MacroItems::cast(value) {
self.emit_macro_items(&items)
} else {
let message =
"attribute or derive macro expansion cannot be cast to MacroItems".to_owned();
self.emit_diagnostic_for_node(
node,
DiagnosticSeverity::Warning,
"item_expansion".to_owned(),
message.clone(),
message,
);
None
}
}
fn emit_attribute_macro_expansion(
&mut self,
node: &ast::Item,
@@ -741,23 +796,8 @@ impl<'a> Translator<'a> {
// only expand the outermost attribute macro
return None;
}
let ExpandResult {
value: expanded, ..
} = semantics.expand_attr_macro(node)?;
self.emit_macro_expansion_parse_errors(node, &expanded);
let macro_items = ast::MacroItems::cast(expanded).or_else(|| {
let message = "attribute macro expansion cannot be cast to MacroItems".to_owned();
let location = self.location_for_node(node);
self.emit_diagnostic(
DiagnosticSeverity::Warning,
"item_expansion".to_owned(),
message.clone(),
message,
location.unwrap_or(UNKNOWN_LOCATION),
);
None
})?;
self.emit_macro_items(&macro_items)
let expansion = semantics.expand_attr_macro(node)?;
self.process_item_macro_expansion(node, expansion)
}
pub(crate) fn emit_item_expansion(&mut self, node: &ast::Item, label: Label<generated::Item>) {
@@ -785,4 +825,26 @@ impl<'a> Translator<'a> {
generated::Const::emit_has_implementation(label, &mut self.trap.writer);
}
}
pub(crate) fn emit_derive_expansion(
&mut self,
node: &(impl Into<ast::Adt> + Clone),
label: impl Into<Label<generated::Adt>> + Copy,
) {
let Some(semantics) = self.semantics else {
return;
};
let node: ast::Adt = node.clone().into();
let expansions = node
.attrs()
.filter_map(|attr| semantics.expand_derive_macro(&attr))
.flatten()
.filter_map(|expansion| self.process_item_macro_expansion(&node, expansion))
.collect::<Vec<_>>();
generated::Adt::emit_derive_macro_expansions(
label.into(),
expansions,
&mut self.trap.writer,
);
}
}

View File

@@ -1,6 +1,7 @@
lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 6a103a6d04c951ca2f0c2989bed737cdbac56dd5ea9432b858da3416412bbf79 cf2bc67b65a1555de58bbd0a35b834b8867112a2f7c1951307c9416400ce70d0
lib/codeql/rust/elements/Abi.qll 485a2e79f6f7bfd1c02a6e795a71e62dede3c3e150149d5f8f18b761253b7208 6159ba175e7ead0dd2e3f2788f49516c306ee11b1a443bd4bdc00b7017d559bd
lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be
lib/codeql/rust/elements/Adt.qll c2afed4ac2e17039ccd98f74ea22111f4d765c4e232c50ccd3128da0d26da837 1380bde2eb667c6ec2ef5f8710aa24e926851c9e321ebc72ba514fa92c369dc3
lib/codeql/rust/elements/ArgList.qll 3d2f6f5542340b80a4c6e944ac17aba0d00727588bb66e501453ac0f80c82f83 afd52700bf5a337f19827846667cd0fb1fea5abbbcbc353828e292a727ea58c9
lib/codeql/rust/elements/ArrayExpr.qll e4e7cff3518c50ec908271906dd46c1fbe9098faa1e8cd06a27f0a6e8d165ed1 fe02a4f4197f57ecd1e8e82d6c9384148ec29d8b106d7f696795b2f325e4a71b
lib/codeql/rust/elements/ArrayListExpr.qll 451aedcecb479c385ff497588c7a07fda304fd5b873270223a4f2c804e96b245 a8cb008f6f732215623b5626c84b37b651ca01ccafb2cf4c835df35d5140c6ad
@@ -46,7 +47,7 @@ lib/codeql/rust/elements/ContinueExpr.qll 9f27c5d5c819ad0ebc5bd10967ba8d33a9dc95
lib/codeql/rust/elements/Crate.qll 1426960e6f36195e42ea5ea321405c1a72fccd40cd6c0a33673c321c20302d8d 1571a89f89dab43c5291b71386de7aadf52730755ba10f9d696db9ad2f760aff
lib/codeql/rust/elements/DynTraitTypeRepr.qll e4d27112d27ae93c621defd2c976fd4e90663ab7f6115e83ae4fe8106cb5e015 eb9fde89698588f3b7116f62388c54e937f99559b22c93d11a5596e754560072
lib/codeql/rust/elements/Element.qll 0b62d139fef54ed2cf2e2334806aa9bfbc036c9c2085d558f15a42cc3fa84c48 24b999b93df79383ef27ede46e38da752868c88a07fe35fcff5d526684ba7294
lib/codeql/rust/elements/Enum.qll accb97d0bd8c0f41df873d41886f606b6ae4cd1ffa38b70fe9504cfb89d0bd7d b456103ac992e384165d151eb0f169499be4961c3ec35b94a32201b5e4e22189
lib/codeql/rust/elements/Enum.qll 55d5a4a775f07d9c1d5183af76f9d8de1d700bfe1dea427cc7ff3083f39e13de f00a585596f1d0ab34e6f2b7cdaba6d4a89005820478f810e8685478cf88100e
lib/codeql/rust/elements/Expr.qll e5d65e805ccf440d64d331e55df4c4144ab8c8f63f367382494714087659ffe8 2bbc1e5d3a65f413ec33d9822fa451fbdbe32349158db58cc0bfcfafb0e21bda
lib/codeql/rust/elements/ExprStmt.qll 00ac4c7d0192b9e8b0f28d5ae59c27729ff5a831ca11938ea3e677a262337a64 7cc02aa5346cd7c50d75ca63cd6501097b0a3979eb2ed838adff114fe17d35a3
lib/codeql/rust/elements/ExternBlock.qll 96c70d0761ec385fe17aa7228e15fd1711949d5abba5877a1c2f4c180d202125 38ad458868a368d437b2dda44307d788a85c887f45ea76c99adbfc9a53f14d81
@@ -145,7 +146,7 @@ lib/codeql/rust/elements/SourceFile.qll 0b6a3e58767c07602b19975009a2ad53ecf1fd72
lib/codeql/rust/elements/Static.qll a6d73152ddecb53a127aa3a4139f97007cd77b46203691c287600aa7200b8beb 547197e794803b3ea0c0e220f050980adec815a16fdef600f98ff795aa77f677
lib/codeql/rust/elements/Stmt.qll 532b12973037301246daf7d8c0177f734202f43d9261c7a4ca6f5080eea8ca64 b838643c4f2b4623d2c816cddad0e68ca3e11f2879ab7beaece46f489ec4b1f3
lib/codeql/rust/elements/StmtList.qll e874859ce03672d0085e47e0ca5e571b92b539b31bf0d5a8802f9727bef0c6b0 e5fe83237f713cdb57c446a6e1c20f645c2f49d9f5ef2c984032df83acb3c0de
lib/codeql/rust/elements/Struct.qll c1f607aa4b039fc24bbbedc5992e49bd13e9851731296645c7ec2669425f19ad d7720c76a5a50284bd62df707cb113dfb19104226e9ee7578e75eb207da0655c
lib/codeql/rust/elements/Struct.qll 6ae1ce11044a1f6bf3150ddce947c1be17e462613edf7ea4fe7d861aa3dbe0d1 043ef682d71f31e8808962032c05ab3045e7cbc8663ec7e06dc9255e12e53c12
lib/codeql/rust/elements/StructExpr.qll af9059c01a97755e94f1a8b60c66d9c7663ed0705b2845b086b8953f16019fab 2d33d86b035a15c1b31c3e07e0e74c4bbe57a71c5a55d60e720827814e73b7ba
lib/codeql/rust/elements/StructExprField.qll 3eb9f17ecd1ad38679689eb4ecc169d3a0b5b7a3fc597ae5a957a7aea2f74e4f 8fcd26f266f203004899a60447ba16e7eae4e3a654fbec7f54e26857730ede93
lib/codeql/rust/elements/StructExprFieldList.qll 6efb2ec4889b38556dc679bb89bbd4bd76ed6a60014c41f8e232288fc23b2d52 dc867a0a4710621e04b36bbec7d317d6f360e0d6ac68b79168c8b714babde31d
@@ -174,7 +175,7 @@ lib/codeql/rust/elements/TypeRepr.qll ea41b05ef0aaac71da460f9a6a8331cf98166f2c38
lib/codeql/rust/elements/UnderscoreExpr.qll 233661b82b87c8cda16d8f2e17965658c3dc6b69efb23cb8eb9c4f50c68521e0 8edff8e80aac2ecf83a6b58f310cab688cbaeea0a0e68a298b644e565960cc74
lib/codeql/rust/elements/Unextracted.qll 12e60c79ef5b94d72b579b19970622e7b73822ebc13fbcfedfe953527ab1ac36 ec015db2eb12c3c82693ddc71d32d9ab9ef7a958e741e2510681bb707ceca23e
lib/codeql/rust/elements/Unimplemented.qll bf624d28163e5c99accda16c0c99f938bec4a3b1b920a463e86fc8529ff5ff02 013bc7777298d250338f835cd494b5a8accea2d6a4f9561851f283ac129a446b
lib/codeql/rust/elements/Union.qll f035871f9d265a002f8a4535da11d6191f04337c1d22dc54f545e3b527067e20 fdb86022a4f4f7e323899aaf47741d0a4c4e6a987fe1b4e8fea24e28b1377177
lib/codeql/rust/elements/Union.qll 3e277155fc7ea77f645cb5c5b227efd1474aa745b12a8be228eab694536c49dc a4bf9b54b8262517371000a842e5fdcdaabd324e52afd7919bbf76bc887b18b6
lib/codeql/rust/elements/Use.qll fdcf70574403c2f219353211b6930f2f9bc79f41c2594e07548de5a8c6cbb24d e41f2b689fcbeb7b84c7ba8d09592f7561626559318642b73574bbac83f74546
lib/codeql/rust/elements/UseBoundGenericArg.qll f16903f8fff676d3700eaad5490804624391141472ecc3166ccb1f70c794c120 5efda98088d096b42f53ceccae78c05f15c6953525b514d849681cb2cf65b147
lib/codeql/rust/elements/UseBoundGenericArgs.qll d9821a82a1d57e609fdc5e79d65e9a88b0088f51d03927e09f41b6931d3484ab 181483a95e22622c7cee07cce87e9476053f824a82e67e2bdecabf5a39f672ad
@@ -192,6 +193,7 @@ lib/codeql/rust/elements/YeetExpr.qll 4172bf70de31cab17639da6eed4a12a7afcefd7aa9
lib/codeql/rust/elements/YieldExpr.qll de2dc096a077f6c57bba9d1c2b2dcdbecce501333753b866d77c3ffbe06aa516 1f3e8949689c09ed356ff4777394fe39f2ed2b1e6c381fd391790da4f5d5c76a
lib/codeql/rust/elements/internal/AbiConstructor.qll 4484538db49d7c1d31c139f0f21879fceb48d00416e24499a1d4b1337b4141ac 460818e397f2a1a8f2e5466d9551698b0e569d4640fcb87de6c4268a519b3da1
lib/codeql/rust/elements/internal/AbiImpl.qll 28a2b6bdb38fd626e5d7d1ed29b839b95976c3a03717d840669eb17c4d6f0c7a 8e83877855abe760f3be8f45c2cf91c1f6e810ec0301313910b8104b2474d9cf
lib/codeql/rust/elements/internal/AdtImpl.qll 2dc727a14a0fc775512d35e224eab7955884ec143dbd7dbf4cada9a1f5516df4 f3991cea544c5537b0a810492979a317b47685e1c0e58b948df2a957c7a18fdc
lib/codeql/rust/elements/internal/ArgListConstructor.qll a73685c8792ae23a2d628e7357658efb3f6e34006ff6e9661863ef116ec0b015 0bee572a046e8dfc031b1216d729843991519d94ae66280f5e795d20aea07a22
lib/codeql/rust/elements/internal/ArgListImpl.qll 0903b2ca31b3e5439f631582d12f17d77721d63fdb54dc41372d19b742881ce4 2c71c153ccca4b4988e6a25c37e58dc8ecb5a7483273afff563a8542f33e7949
lib/codeql/rust/elements/internal/ArrayExprInternal.qll 07a219b3d3fba3ff8b18e77686b2f58ab01acd99e0f5d5cad5d91af937e228f5 7528fc0e2064c481f0d6cbff3835950a044e429a2cd00c4d8442d2e132560d37
@@ -459,6 +461,7 @@ lib/codeql/rust/elements/internal/YieldExprConstructor.qll 8cbfa6405acb151ee31cc
lib/codeql/rust/elements/internal/YieldExprImpl.qll af184649a348ddd0be16dee9daae307240bf123ace09243950342e9d71ededd9 17df90f67dd51623e8a5715b344ccd8740c8fc415af092469f801b99caacb70d
lib/codeql/rust/elements/internal/generated/Abi.qll f5a22afe5596c261b4409395056ce3227b25d67602d51d0b72734d870f614df3 06d1c242ccd31f1cc90212823077e1a7a9e93cd3771a14ebe2f0659c979f3dd1
lib/codeql/rust/elements/internal/generated/Addressable.qll 96a8b45166dd035b8d2c6d36b8b67019f2d4d0b4ccff6d492677c0c87197613e d8f1ce29feafc8ff7179399fc7eac5db031a7e1a8bc6b2cd75cfce1da3132e9b
lib/codeql/rust/elements/internal/generated/Adt.qll 155f4025a26c3d2d5d3c42dfce9274a10f0862ea0574843c5d276179de421569 17138b271eea81d3ee2697c82cccfd7af752cd18cd925dd5fa20d7fce0e2432f
lib/codeql/rust/elements/internal/generated/ArgList.qll e41f48258082876a8ceac9107209d94fdd00a62d2e4c632987a01a8394c4aff6 bf1982d14f8cd55fa0c3da2c6aab56fc73b15a3572ffc72d9a94f2c860f8f3b7
lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 73806a0de8168b38a9436fa6b8c6d68c92eeab3d64a1ae7edfff82f871929992 7ad998cdd8f4fed226473517ad7a5765cb35608033047aad53bf8aa3969fd03b
lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll 67a7b0fae04b11cf771727ff39a123fb2d5ce6e2d650d32478fcb33a26ed5688 15833405fa85f6abe0e5146dac283cb5a142a07f08300ccc15a1dae30ed88942
@@ -505,7 +508,7 @@ lib/codeql/rust/elements/internal/generated/ContinueExpr.qll e2010feb14fb6edeb83
lib/codeql/rust/elements/internal/generated/Crate.qll 37f3760d7c0c1c3ca809d07daf7215a8eae6053eda05e88ed7db6e07f4db0781 649a3d7cd7ee99f95f8a4d3d3c41ea2fa848ce7d8415ccbac62977dfc9a49d35
lib/codeql/rust/elements/internal/generated/DynTraitTypeRepr.qll b2e0e728b6708923b862d9d8d6104d13f572da17e393ec1485b8465e4bfdc206 4a87ea9669c55c4905ce4e781b680f674989591b0cb56af1e9fa1058c13300b3
lib/codeql/rust/elements/internal/generated/Element.qll d56d22c060fa929464f837b1e16475a4a2a2e42d68235a014f7369bcb48431db 0e48426ca72179f675ac29aa49bbaadb8b1d27b08ad5cbc72ec5a005c291848e
lib/codeql/rust/elements/internal/generated/Enum.qll ad2a79ae52665f88a41ee045adce4e60beb43483547d958f8230b9917824f0a1 cb12e304d04dffb4d8fb838eb9dbecf00fa8ac18fbf3edc37ee049ad248a4f67
lib/codeql/rust/elements/internal/generated/Enum.qll 477eaa102c1268f0fa7603ecd88f1b83db1388c17c25e3719d4113ea980256f7 2d60db61ba4a385218f0a01e366e04ba1e7dad386b7e6a027c31f32fb730cca2
lib/codeql/rust/elements/internal/generated/Expr.qll 5fa34f2ed21829a1509417440dae42d416234ff43433002974328e7aabb8f30f 46f3972c7413b7db28a3ea8acb5a50a74b6dd9b658e8725f6953a8829ac912f8
lib/codeql/rust/elements/internal/generated/ExprStmt.qll d1112230015fbeb216b43407a268dc2ccd0f9e0836ab2dca4800c51b38fa1d7d 4a80562dcc55efa5e72c6c3b1d6747ab44fe494e76faff2b8f6e9f10a4b08b5b
lib/codeql/rust/elements/internal/generated/ExternBlock.qll e7faac92297a53ac6e0420eec36255a54f360eeb962bf663a00da709407832dd 5ff32c54ec7097d43cc3311492090b9b90f411eead3bc849f258858f29405e81
@@ -577,7 +580,7 @@ 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 5278b74de04d54708f078fd813d83ae5f934fa12d420b188c1334e3a7c3b8324 61cf70eb649f241e2fcd5e0ba34df63f3a14f07032811b9ae151721783a0fd20
lib/codeql/rust/elements/internal/generated/ParentChild.qll b58a01c0d2cca085a77ed7a98a0318cfc20450e48c64124f8a875ae45416ac25 92e9b6434629508868a5cf69c1236729409dcab4c4cda63af537d591a840127a
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
@@ -592,7 +595,7 @@ 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 b6e439cc24f8c02fe73301cd2bc16d59dfd28e2a8a201388d8318c43937309e2 62139c3df2f6c4dca1c897b1384233ff0151b7e5fb1c41a178c5e8e41b5e7f05
lib/codeql/rust/elements/internal/generated/Raw.qll f9370ca510d47144f7a22255341dc0f45407fcc8c22d42a74dbc423a68a36635 2301eb8a7b4d59c05413e07f95fe9ac2d0f42d3673d9b7e809bd49a6c1bee506
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
@@ -609,7 +612,7 @@ lib/codeql/rust/elements/internal/generated/SourceFile.qll 4bc95c88b49868d1da1a8
lib/codeql/rust/elements/internal/generated/Static.qll 34a4cdb9f4a93414499a30aeeaad1b3388f2341c982af5688815c3b0a0e9c57b 3c8354336eff68d580b804600df9abf49ee5ee10ec076722089087820cefe731
lib/codeql/rust/elements/internal/generated/Stmt.qll 8473ff532dd5cc9d7decaddcd174b94d610f6ca0aec8e473cc051dad9f3db917 6ef7d2b5237c2dbdcacbf7d8b39109d4dc100229f2b28b5c9e3e4fbf673ba72b
lib/codeql/rust/elements/internal/generated/StmtList.qll 816aebf8f56e179f5f0ba03e80d257ee85459ea757392356a0af6dbd0cd9ef5e 6aa51cdcdc8d93427555fa93f0e84afdfbbd4ffc8b8d378ae4a22b5b6f94f48b
lib/codeql/rust/elements/internal/generated/Struct.qll 955c7e1e6453685fbc392e32514cf26a9aec948cecf9e62705ddc5c56c9dc97d cf47a9c53eebc0c7165985cd6120530b8a0fe965895d2293d01f7b95013c0102
lib/codeql/rust/elements/internal/generated/Struct.qll ce40dd64d61f6ca0a8425019dd8368ca3d79d3a238d7afb9b3f1c86c2c95c1b5 214946f9cdbf134a181d98b02bb630504ad524541febc4c0b8490a9a6fab8750
lib/codeql/rust/elements/internal/generated/StructExpr.qll c6d861eaa0123b103fd9ffd2485423419ef9b7e0b4af9ed2a2090d8ec534f65d 50da99ee44771e1239ed8919f711991dd3ec98589fbe49b49b68c88074a07d74
lib/codeql/rust/elements/internal/generated/StructExprField.qll 6bdc52ed325fd014495410c619536079b8c404e2247bd2435aa7685dd56c3833 501a30650cf813176ff325a1553da6030f78d14be3f84fea6d38032f4262c6b0
lib/codeql/rust/elements/internal/generated/StructExprFieldList.qll 298d33442d1054922d2f97133a436ee559f1f35b7708523284d1f7eee7ebf443 7febe38a79fadf3dcb53fb8f8caf4c2780f5df55a1f8336269c7b674d53c6272
@@ -618,7 +621,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 eb248f4e57985ec8eabf9ed5cfb8ba8f5ebd6ca17fb712c992811bced0e342d4 bbcbdba484d3b977a0d6b9158c5fa506f59ced2ad3ae8239d536bf826bfb7e31
lib/codeql/rust/elements/internal/generated/Synth.qll ef45765a8e077bc0168ec226b3b84902acd8d774cd7af637e0b1b1b16ff1deaf 58dd7076517e5d680c6d8b0489530bd8e1d15d629a233f1742cca3f028d5ec81
lib/codeql/rust/elements/internal/generated/SynthConstructors.qll bcc7f617b775ac0c7f04b1cc333ed7cc0bd91f1fabc8baa03c824d1df03f6076 bcc7f617b775ac0c7f04b1cc333ed7cc0bd91f1fabc8baa03c824d1df03f6076
lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b
lib/codeql/rust/elements/internal/generated/TokenTree.qll 1a3c4f5f30659738641abdd28cb793dab3cfde484196b59656fc0a2767e53511 de2ebb210c7759ef7a6f7ee9f805e1cac879221287281775fc80ba34a5492edf
@@ -640,7 +643,7 @@ lib/codeql/rust/elements/internal/generated/TypeRepr.qll 1e7b9d2ddab86e35dad7c31
lib/codeql/rust/elements/internal/generated/UnderscoreExpr.qll b3780c99c5d57159bef4c6bd2fd8ec44ebd1854c892c1ca776c740f71249e58c 2fd451cbf0a779e8042e439882e7d9cadc19d1e596df3bbb086d16f2596407c7
lib/codeql/rust/elements/internal/generated/Unextracted.qll 01563dfd769d6dc3c6b8a40d9a4dc0d99a3b6a0c6725c180d2bf4d7633929a17 a93ce90f8c03f4305e59de9c63f089fc7935298fc9a73d091d76933cf63e790c
lib/codeql/rust/elements/internal/generated/Unimplemented.qll a3eb304781991bff1227de1e4422b68bf91e7b344e4f6c9e874b324e82a35e60 6bc4839fda3850a56dc993b79ef9ba921008395c8432b184e14438fba4566f21
lib/codeql/rust/elements/internal/generated/Union.qll 0d5528d9331cc7599f0c7bc4d2b17908a9f90037bc94b8b7cd8bed058df98e45 986b33efddc36ff34acaf3d38bd3f90055aa14ec018432f5d4510037fc8ee59f
lib/codeql/rust/elements/internal/generated/Union.qll 328d714dba5b19f8bf94c17efee21c9ca9e693a3a568a2afed3dc0d03fcc3f50 9be7039ce837a3217e97f64c8667d78e4d69e19c8fe7c19198389acb83a15957
lib/codeql/rust/elements/internal/generated/Use.qll cf95b5c4756b25bee74113207786e37464ffbc0fb5f776a04c651300afc53753 1fe26b3904db510184cb688cb0eeb0a8dbac7ac15e27a3b572d839743c738393
lib/codeql/rust/elements/internal/generated/UseBoundGenericArg.qll 69162794e871291545ea04f61259b2d000671a96f7ca129f7dd9ed6e984067c4 31de9ebc0634b38e2347e0608b4ea888892f1f2732a2892464078cd8a07b4ee8
lib/codeql/rust/elements/internal/generated/UseBoundGenericArgs.qll 2cc8ab0068b7bf44ca17a62b32a8dd1d89cd743532c8a96b262b164fd81b0c36 347e7709a0f5ace197beb6827f6cf04a31ff68ff2dff3707914c6b910658d00a
@@ -656,7 +659,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 da721d51bc659921998521579df5bff6172d9079d8e243c2b65a5b9eb441b52e da721d51bc659921998521579df5bff6172d9079d8e243c2b65a5b9eb441b52e
lib/codeql/rust/elements.qll 34c5c8e6e25cce86f0617d552f788eb30ad8bb24fbc43723af962ce9cdc7d177 34c5c8e6e25cce86f0617d552f788eb30ad8bb24fbc43723af962ce9cdc7d177
test/extractor-tests/generated/Abi/Abi.ql 7f6e7dc4af86eca3ebdc79b10373988cd0871bd78b51997d3cffd969105e5fdd 2f936b6ca005c6157c755121584410c03e4a3949c23bee302fbe05ee10ce118f
test/extractor-tests/generated/Abi/Abi_getAbiString.ql a496762fcec5a0887b87023bbf93e9b650f02e20113e25c44d6e4281ae8f5335 14109c7ce11ba25e3cd6e7f1b3fcb4cb00622f2a4eac91bfe43145c5f366bc52
test/extractor-tests/generated/ArgList/ArgList.ql e412927756e72165d0e7c5c9bd3fca89d08197bbf760db8fb7683c64bb2229bc 043dba8506946fbb87753e22c387987d7eded6ddb963aa067f9e60ef9024d684
@@ -772,10 +775,11 @@ test/extractor-tests/generated/ContinueExpr/ContinueExpr_getLifetime.ql 39dae987
test/extractor-tests/generated/Crate/MISSING_SOURCE.txt b6cf5771fdbbe981aeb3f443ec7a40517b6e99ffc9817fd8872c2e344240dae1 b6cf5771fdbbe981aeb3f443ec7a40517b6e99ffc9817fd8872c2e344240dae1
test/extractor-tests/generated/DynTraitTypeRepr/DynTraitTypeRepr.ql 513d64b564f359e1022ae6f3d6d4a8ad637f595f01f29a6c2a167d1c2e8f1f99 0c7a7af6ee1005126b9ab77b2a7732821f85f1d2d426312c98206cbbedc19bb2
test/extractor-tests/generated/DynTraitTypeRepr/DynTraitTypeRepr_getTypeBoundList.ql b20720ff0b147d55cea6f2de44d5bf297e79991eaf103938ccd7ab9d129e9656 eb8c9db2581cea00c29d7772de0b0a125be02c37092217a419f1a2b6a9711a6c
test/extractor-tests/generated/Enum/Enum.ql eebc780aef77b87e6062724dd8ddb8f3ad33021061c95924c2c2439798ffbb87 0d19552872a2254f66a78b999a488ce2becdb0b0611b858e0bee2b119ee08eae
test/extractor-tests/generated/Enum/Enum.ql 7c96c17f4adae679a7a8b097c5bfb26978263398b77dfa6e5b0e7f547d8bbd64 18375fad5a3d574c627b563529fa9c03f7d140e872ce7db81895fcb8da87f001
test/extractor-tests/generated/Enum/Enum_getAttr.ql 8109ef2495f4a154e3bb408d549a16c6085e28de3aa9b40b51043af3d007afa7 868cf275a582266ffa8da556d99247bc8af0fdf3b43026c49e250cf0cac64687
test/extractor-tests/generated/Enum/Enum_getAttributeMacroExpansion.ql 571ec6396fb7fc703b23aab651b3c6c05c9b5cd9d69a9ae8f5e36d69a18c89d3 c04025992f76bce7638728847f1ef835d3a48d3dc3368a4d3b73b778f1334618
test/extractor-tests/generated/Enum/Enum_getCrateOrigin.ql 76d32838b7800ed8e5cab895c9dbea76129f96afab949598bebec2b0cb34b7ff 226d099377c9d499cc614b45aa7e26756124d82f07b797863ad2ac6a6b2f5acb
test/extractor-tests/generated/Enum/Enum_getDeriveMacroExpansion.ql c7d3c2f1661a0a39bacf7f4977bd484133d9ee3934956d33f77ae1c83145b027 f5e374a3b620d3ef69bcc23123598179bcb4f1167dd29c18c84ad05c94c7957b
test/extractor-tests/generated/Enum/Enum_getExtendedCanonicalPath.ql 001bb634adc4b20afb241bff41194bc91ba8544d1edd55958a01975e2ac428e1 c7c3fe3dc22a1887981a895a1e5262b1d0ad18f5052c67aa73094586de5212f6
test/extractor-tests/generated/Enum/Enum_getGenericParamList.ql 2a858a07195a4b26b8c92e28519995bd6eba64889bddd126e161038f4a8d78e0 db188f238db915c67b084bc85aa0784c6a20b97b5a5f1966b3530c4c945b5527
test/extractor-tests/generated/Enum/Enum_getName.ql 32a8638534f37bfd416a6906114a3bcaf985af118a165b78f2c8fffd9f1841b8 c9ca8030622932dd6ceab7d41e05f86b923f77067b457fb7ec196fe4f4155397
@@ -1091,10 +1095,11 @@ test/extractor-tests/generated/StmtList/StmtList.ql 0010df0d5e30f7bed3bd5d916faf
test/extractor-tests/generated/StmtList/StmtList_getAttr.ql 78d4bf65273498f04238706330b03d0b61dd03b001531f05fcb2230f24ceab64 6e02cee05c0b9f104ddea72b20097034edb76e985188b3f10f079bb03163b830
test/extractor-tests/generated/StmtList/StmtList_getStatement.ql abbc3bcf98aab395fc851d5cc58c9c8a13fe1bdd531723bec1bc1b8ddbec6614 e302a26079986fa055306a1f641533dfde36c9bc0dd7958d21e2518b59e808c2
test/extractor-tests/generated/StmtList/StmtList_getTailExpr.ql 578d7c944ef42bdb822fc6ce52fe3d49a0012cf7854cfddbb3d5117133700587 64ea407455a3b4dfbb86202e71a72b5abbff885479367b2834c0dd16d1f9d0ee
test/extractor-tests/generated/Struct/Struct.ql a4e5d3fe4f994bdf911ebed54a65d237cd5a00510337e911bd5286637bc8ea80 a335224605f3cc35635bf5fd0bebcb50800429c0a82a5aa86a37cb9f6eb3f651
test/extractor-tests/generated/Struct/Struct.ql ffaaa49314c26bd0a206b692d480254acc6e87233f679fbe936094c81c071de2 cae27f50c3bf787aead37077c9fe32e66c1a247a8a8c1f6f9b241493b1b793fc
test/extractor-tests/generated/Struct/Struct_getAttr.ql 028d90ddc5189b82cfc8de20f9e05d98e8a12cc185705481f91dd209f2cb1f87 760780a48c12be4581c1675c46aae054a6198196a55b6b989402cc29b7caf245
test/extractor-tests/generated/Struct/Struct_getAttributeMacroExpansion.ql a17504527a307615d26c2c4b6c21fe9b508f5a77a741d68ca605d2e69668e385 f755d8965c10568a57ff44432a795a0a36b86007fc7470bc652d555946e19231
test/extractor-tests/generated/Struct/Struct_getCrateOrigin.ql 289622244a1333277d3b1507c5cea7c7dd29a7905774f974d8c2100cea50b35f d32941a2d08d7830b42c263ee336bf54de5240bfc22082341b4420a20a1886c7
test/extractor-tests/generated/Struct/Struct_getDeriveMacroExpansion.ql e4849a63be9f413426dd0f183d1229fa4dd1c521e87479622a80c52179e3bb03 5ae88d61ffa7b0a52a62fd16ba5cc5816c2b7b2c0db726e3125e525bbbc10a18
test/extractor-tests/generated/Struct/Struct_getExtendedCanonicalPath.ql 866a5893bd0869224fb8aadd071fba35b5386183bb476f5de45c9de7ab88c583 267aedc228d69e31ca8e95dcab6bcb1aa30f9ebaea43896a55016b7d68e3c441
test/extractor-tests/generated/Struct/Struct_getFieldList.ql f45d6d5d953741e52aca67129994b80f6904b2e6b43c519d6d42c29c7b663c42 77a7d07e8462fa608efc58af97ce8f17c5369f9573f9d200191136607cb0e600
test/extractor-tests/generated/Struct/Struct_getGenericParamList.ql cd72452713004690b77086163541fa319f8ab5faf503bb4a6a20bcaf2f790d38 4d72e891c5fac6e491d9e18b87ecf680dc423787d6b419da8f700fe1a14bc26f
@@ -1206,10 +1211,11 @@ test/extractor-tests/generated/TypeParam/TypeParam_getName.ql 9d5b6d6a9f2a5793e2
test/extractor-tests/generated/TypeParam/TypeParam_getTypeBoundList.ql 080a6b370ad460bf128fdfd632aa443af2ad91c3483e192ad756eb234dbfa4d8 8b048d282963f670db357f1eef9b8339f83d03adf57489a22b441d5c782aff62
test/extractor-tests/generated/UnderscoreExpr/UnderscoreExpr.ql 4ad6ed0c803fb4f58094a55b866940b947b16259756c674200172551ee6546e0 d3270bdcc4c026325159bd2a59848eb51d96298b2bf21402ea0a83ac1ea6d291
test/extractor-tests/generated/UnderscoreExpr/UnderscoreExpr_getAttr.ql d8502be88bcd97465f387c410b5078a4709e32b2baa556a4918ea5e609c40dd7 b238dc37404254e3e7806d50a7b1453e17e71da122931331b16a55853d3a843f
test/extractor-tests/generated/Union/Union.ql 2795c83d4511fadf24cc66a762adbabca084bc6ac48501715f666979d2ea9ea5 7efae5209ae3ee8c73cd1c9e9e05f01b3fdda65d9a553c2ac5216351b6f15e5c
test/extractor-tests/generated/Union/Union.ql 4974339feb10ab65bef60ba713058cb73ba7dcf5e451ddf6c919e94f96f56a80 f0f0025666940e4b0f72ef2e64b28e96b1a410f25f56c98cbebdd019ceece7b6
test/extractor-tests/generated/Union/Union_getAttr.ql 42fa0878a6566208863b1d884baf7b68b46089827fdb1dbbfacbfccf5966a9a2 54aa94f0281ca80d1a4bdb0e2240f4384af2ab8d50f251875d1877d0964579fc
test/extractor-tests/generated/Union/Union_getAttributeMacroExpansion.ql ddd0133a497dc057a353b86acc8ed991fefeaefa335d8ad9fe95109a90e39e54 fcaed4287815226843157c007674b1f1405cae31856fed1113d569bab5608d9b
test/extractor-tests/generated/Union/Union_getCrateOrigin.ql c218308cf17b1490550229a725542d248617661b1a5fa14e9b0e18d29c5ecc00 e0489242c8ff7aa4dbfdebcd46a5e0d9bea0aa618eb0617e76b9b6f863a2907a
test/extractor-tests/generated/Union/Union_getDeriveMacroExpansion.ql 82ee99ea42d6de9a45289a4b8e750cba887ac9daa2f6387b8c2a9062224da45c 1f18cd80f93ca2e19d3ac8ce733f264522ba785078f541342c816e16194748d6
test/extractor-tests/generated/Union/Union_getExtendedCanonicalPath.ql 6268ddb68c3e05906e3fc85e40635925b84e5c7290746ded9c6814d362033068 04473b3b9891012e95733463018db8da0e96659ea0b10458b33dc857c091d278
test/extractor-tests/generated/Union/Union_getGenericParamList.ql c55156ae26b766e385be7d21e67f8c3c45c29274201c93d660077fcc47e1ceee 4c4d338e17c32876ef6e51fd19cff67d125dd89c10e939dfaadbac824bef6a68
test/extractor-tests/generated/Union/Union_getName.ql 17247183e1a8c8bbb15e67120f65ca323630bddeb614fa8a48e1e74319f8ed37 e21c2a0205bc991ba86f3e508451ef31398bdf5441f6d2a3f72113aaae9e152b

6
rust/ql/.gitattributes generated vendored
View File

@@ -3,6 +3,7 @@
/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll linguist-generated
/lib/codeql/rust/elements/Abi.qll linguist-generated
/lib/codeql/rust/elements/Addressable.qll linguist-generated
/lib/codeql/rust/elements/Adt.qll linguist-generated
/lib/codeql/rust/elements/ArgList.qll linguist-generated
/lib/codeql/rust/elements/ArrayExpr.qll linguist-generated
/lib/codeql/rust/elements/ArrayListExpr.qll linguist-generated
@@ -194,6 +195,7 @@
/lib/codeql/rust/elements/YieldExpr.qll linguist-generated
/lib/codeql/rust/elements/internal/AbiConstructor.qll linguist-generated
/lib/codeql/rust/elements/internal/AbiImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/AdtImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/ArgListConstructor.qll linguist-generated
/lib/codeql/rust/elements/internal/ArgListImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/ArrayExprInternal.qll linguist-generated
@@ -461,6 +463,7 @@
/lib/codeql/rust/elements/internal/YieldExprImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/Abi.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/Addressable.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/Adt.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/ArgList.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll linguist-generated
@@ -778,6 +781,7 @@
/test/extractor-tests/generated/Enum/Enum_getAttr.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getAttributeMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getCrateOrigin.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getDeriveMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getExtendedCanonicalPath.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getGenericParamList.ql linguist-generated
/test/extractor-tests/generated/Enum/Enum_getName.ql linguist-generated
@@ -1097,6 +1101,7 @@
/test/extractor-tests/generated/Struct/Struct_getAttr.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getAttributeMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getCrateOrigin.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getDeriveMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getExtendedCanonicalPath.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getFieldList.ql linguist-generated
/test/extractor-tests/generated/Struct/Struct_getGenericParamList.ql linguist-generated
@@ -1212,6 +1217,7 @@
/test/extractor-tests/generated/Union/Union_getAttr.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getAttributeMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getCrateOrigin.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getDeriveMacroExpansion.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getExtendedCanonicalPath.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getGenericParamList.ql linguist-generated
/test/extractor-tests/generated/Union/Union_getName.ql linguist-generated

View File

@@ -6,6 +6,7 @@
import codeql.files.FileSystem
import codeql.rust.elements.Abi
import codeql.rust.elements.Addressable
import codeql.rust.elements.Adt
import codeql.rust.elements.ArgList
import codeql.rust.elements.ArrayExpr
import codeql.rust.elements.ArrayListExpr

13
rust/ql/lib/codeql/rust/elements/Adt.qll generated Normal file
View File

@@ -0,0 +1,13 @@
// generated by codegen, do not edit
/**
* This module provides the public class `Adt`.
*/
private import internal.AdtImpl
import codeql.rust.elements.Item
import codeql.rust.elements.MacroItems
/**
* An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
*/
final class Adt = Impl::Adt;

View File

@@ -4,9 +4,9 @@
*/
private import internal.EnumImpl
import codeql.rust.elements.Adt
import codeql.rust.elements.Attr
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.Item
import codeql.rust.elements.Name
import codeql.rust.elements.VariantList
import codeql.rust.elements.Visibility

View File

@@ -4,10 +4,10 @@
*/
private import internal.StructImpl
import codeql.rust.elements.Adt
import codeql.rust.elements.Attr
import codeql.rust.elements.FieldList
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.Item
import codeql.rust.elements.Name
import codeql.rust.elements.VariantDef
import codeql.rust.elements.Visibility

View File

@@ -4,9 +4,9 @@
*/
private import internal.UnionImpl
import codeql.rust.elements.Adt
import codeql.rust.elements.Attr
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.Item
import codeql.rust.elements.Name
import codeql.rust.elements.StructFieldList
import codeql.rust.elements.VariantDef

View File

@@ -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 `Adt`.
*
* INTERNAL: Do not use.
*/
private import codeql.rust.elements.internal.generated.Adt
/**
* INTERNAL: This module contains the customizable definition of `Adt` and should not
* be referenced directly.
*/
module Impl {
/**
* An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
*/
class Adt extends Generated::Adt { }
}

View File

@@ -0,0 +1,45 @@
// generated by codegen, do not edit
/**
* This module provides the generated definition of `Adt`.
* 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.ItemImpl::Impl as ItemImpl
import codeql.rust.elements.MacroItems
/**
* INTERNAL: This module contains the fully generated definition of `Adt` and should not
* be referenced directly.
*/
module Generated {
/**
* An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
* INTERNAL: Do not reference the `Generated::Adt` class directly.
* Use the subclass `Adt`, where the following predicates are available.
*/
class Adt extends Synth::TAdt, ItemImpl::Item {
/**
* Gets the `index`th derive macro expansion of this adt (0-based).
*/
MacroItems getDeriveMacroExpansion(int index) {
result =
Synth::convertMacroItemsFromRaw(Synth::convertAdtToRaw(this)
.(Raw::Adt)
.getDeriveMacroExpansion(index))
}
/**
* Gets any of the derive macro expansions of this adt.
*/
final MacroItems getADeriveMacroExpansion() { result = this.getDeriveMacroExpansion(_) }
/**
* Gets the number of derive macro expansions of this adt.
*/
final int getNumberOfDeriveMacroExpansions() {
result = count(int i | exists(this.getDeriveMacroExpansion(i)))
}
}
}

View File

@@ -6,9 +6,9 @@
private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AdtImpl::Impl as AdtImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.internal.ItemImpl::Impl as ItemImpl
import codeql.rust.elements.Name
import codeql.rust.elements.VariantList
import codeql.rust.elements.Visibility
@@ -29,7 +29,7 @@ module Generated {
* INTERNAL: Do not reference the `Generated::Enum` class directly.
* Use the subclass `Enum`, where the following predicates are available.
*/
class Enum extends Synth::TEnum, ItemImpl::Item {
class Enum extends Synth::TEnum, AdtImpl::Adt {
override string getAPrimaryQlClass() { result = "Enum" }
/**

View File

@@ -3164,6 +3164,24 @@ private module Impl {
)
}
private Element getImmediateChildOfAdt(Adt e, int index, string partialPredicateCall) {
exists(int b, int bItem, int n, int nDeriveMacroExpansion |
b = 0 and
bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and
n = bItem and
nDeriveMacroExpansion =
n + 1 + max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and
(
none()
or
result = getImmediateChildOfItem(e, index - b, partialPredicateCall)
or
result = e.getDeriveMacroExpansion(index - n) and
partialPredicateCall = "DeriveMacroExpansion(" + (index - n).toString() + ")"
)
)
}
private Element getImmediateChildOfArrayListExpr(
ArrayListExpr e, int index, string partialPredicateCall
) {
@@ -3275,47 +3293,6 @@ private module Impl {
)
}
private Element getImmediateChildOfEnum(Enum e, int index, string partialPredicateCall) {
exists(
int b, int bItem, int n, int nAttr, int nGenericParamList, int nName, int nVariantList,
int nVisibility, int nWhereClause
|
b = 0 and
bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and
n = bItem and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nGenericParamList = nAttr + 1 and
nName = nGenericParamList + 1 and
nVariantList = nName + 1 and
nVisibility = nVariantList + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfItem(e, index - b, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and result = e.getVariantList() and partialPredicateCall = "VariantList()"
or
index = nVariantList and
result = e.getVisibility() and
partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfExternBlock(
ExternBlock e, int index, string partialPredicateCall
) {
@@ -3730,49 +3707,6 @@ private module Impl {
)
}
private Element getImmediateChildOfStruct(Struct e, int index, string partialPredicateCall) {
exists(
int b, int bItem, int bVariantDef, int n, int nAttr, int nFieldList, int nGenericParamList,
int nName, int nVisibility, int nWhereClause
|
b = 0 and
bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and
bVariantDef =
bItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfVariantDef(e, i, _)) | i) and
n = bVariantDef and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nFieldList = nAttr + 1 and
nGenericParamList = nFieldList + 1 and
nName = nGenericParamList + 1 and
nVisibility = nName + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfItem(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfVariantDef(e, index - bItem, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and result = e.getFieldList() and partialPredicateCall = "FieldList()"
or
index = nFieldList and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and result = e.getVisibility() and partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfStructExpr(StructExpr e, int index, string partialPredicateCall) {
exists(int b, int bExpr, int bPathAstNode, int n, int nStructExprFieldList |
b = 0 and
@@ -3978,53 +3912,6 @@ private module Impl {
)
}
private Element getImmediateChildOfUnion(Union e, int index, string partialPredicateCall) {
exists(
int b, int bItem, int bVariantDef, int n, int nAttr, int nGenericParamList, int nName,
int nStructFieldList, int nVisibility, int nWhereClause
|
b = 0 and
bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and
bVariantDef =
bItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfVariantDef(e, i, _)) | i) and
n = bVariantDef and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nGenericParamList = nAttr + 1 and
nName = nGenericParamList + 1 and
nStructFieldList = nName + 1 and
nVisibility = nStructFieldList + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfItem(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfVariantDef(e, index - bItem, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and
result = e.getStructFieldList() and
partialPredicateCall = "StructFieldList()"
or
index = nStructFieldList and
result = e.getVisibility() and
partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfUse(Use e, int index, string partialPredicateCall) {
exists(int b, int bItem, int n, int nAttr, int nUseTree, int nVisibility |
b = 0 and
@@ -4048,6 +3935,47 @@ private module Impl {
)
}
private Element getImmediateChildOfEnum(Enum e, int index, string partialPredicateCall) {
exists(
int b, int bAdt, int n, int nAttr, int nGenericParamList, int nName, int nVariantList,
int nVisibility, int nWhereClause
|
b = 0 and
bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and
n = bAdt and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nGenericParamList = nAttr + 1 and
nName = nGenericParamList + 1 and
nVariantList = nName + 1 and
nVisibility = nVariantList + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfAdt(e, index - b, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and result = e.getVariantList() and partialPredicateCall = "VariantList()"
or
index = nVariantList and
result = e.getVisibility() and
partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfForExpr(ForExpr e, int index, string partialPredicateCall) {
exists(int b, int bLoopingExpr, int n, int nAttr, int nIterable, int nPat |
b = 0 and
@@ -4090,6 +4018,96 @@ private module Impl {
)
}
private Element getImmediateChildOfStruct(Struct e, int index, string partialPredicateCall) {
exists(
int b, int bAdt, int bVariantDef, int n, int nAttr, int nFieldList, int nGenericParamList,
int nName, int nVisibility, int nWhereClause
|
b = 0 and
bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and
bVariantDef =
bAdt + 1 + max(int i | i = -1 or exists(getImmediateChildOfVariantDef(e, i, _)) | i) and
n = bVariantDef and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nFieldList = nAttr + 1 and
nGenericParamList = nFieldList + 1 and
nName = nGenericParamList + 1 and
nVisibility = nName + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfAdt(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfVariantDef(e, index - bAdt, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and result = e.getFieldList() and partialPredicateCall = "FieldList()"
or
index = nFieldList and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and result = e.getVisibility() and partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfUnion(Union e, int index, string partialPredicateCall) {
exists(
int b, int bAdt, int bVariantDef, int n, int nAttr, int nGenericParamList, int nName,
int nStructFieldList, int nVisibility, int nWhereClause
|
b = 0 and
bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and
bVariantDef =
bAdt + 1 + max(int i | i = -1 or exists(getImmediateChildOfVariantDef(e, i, _)) | i) and
n = bVariantDef and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nGenericParamList = nAttr + 1 and
nName = nGenericParamList + 1 and
nStructFieldList = nName + 1 and
nVisibility = nStructFieldList + 1 and
nWhereClause = nVisibility + 1 and
(
none()
or
result = getImmediateChildOfAdt(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfVariantDef(e, index - bAdt, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
or
index = nAttr and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and
result = e.getStructFieldList() and
partialPredicateCall = "StructFieldList()"
or
index = nStructFieldList and
result = e.getVisibility() and
partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and
partialPredicateCall = "WhereClause()"
)
)
}
private Element getImmediateChildOfWhileExpr(WhileExpr e, int index, string partialPredicateCall) {
exists(int b, int bLoopingExpr, int n, int nAttr, int nCondition |
b = 0 and
@@ -4395,8 +4413,6 @@ private module Impl {
or
result = getImmediateChildOfConst(e, index, partialAccessor)
or
result = getImmediateChildOfEnum(e, index, partialAccessor)
or
result = getImmediateChildOfExternBlock(e, index, partialAccessor)
or
result = getImmediateChildOfExternCrate(e, index, partialAccessor)
@@ -4423,8 +4439,6 @@ private module Impl {
or
result = getImmediateChildOfStatic(e, index, partialAccessor)
or
result = getImmediateChildOfStruct(e, index, partialAccessor)
or
result = getImmediateChildOfStructExpr(e, index, partialAccessor)
or
result = getImmediateChildOfStructPat(e, index, partialAccessor)
@@ -4437,14 +4451,18 @@ private module Impl {
or
result = getImmediateChildOfTypeAlias(e, index, partialAccessor)
or
result = getImmediateChildOfUnion(e, index, partialAccessor)
or
result = getImmediateChildOfUse(e, index, partialAccessor)
or
result = getImmediateChildOfEnum(e, index, partialAccessor)
or
result = getImmediateChildOfForExpr(e, index, partialAccessor)
or
result = getImmediateChildOfLoopExpr(e, index, partialAccessor)
or
result = getImmediateChildOfStruct(e, index, partialAccessor)
or
result = getImmediateChildOfUnion(e, index, partialAccessor)
or
result = getImmediateChildOfWhileExpr(e, index, partialAccessor)
}
}

View File

@@ -3610,6 +3610,19 @@ module Raw {
Expr getExpr() { yield_expr_exprs(this, result) }
}
/**
* INTERNAL: Do not use.
* An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
*/
class Adt extends @adt, Item {
/**
* Gets the `index`th derive macro expansion of this adt (0-based).
*/
MacroItems getDeriveMacroExpansion(int index) {
adt_derive_macro_expansions(this, index, result)
}
}
/**
* INTERNAL: Do not use.
* A block expression. For example:
@@ -3744,49 +3757,6 @@ module Raw {
predicate hasImplementation() { const_has_implementation(this) }
}
/**
* INTERNAL: Do not use.
* An enum declaration.
*
* For example:
* ```rust
* enum E {A, B(i32), C {x: i32}}
* ```
*/
class Enum extends @enum, Item {
override string toString() { result = "Enum" }
/**
* Gets the `index`th attr of this enum (0-based).
*/
Attr getAttr(int index) { enum_attrs(this, index, result) }
/**
* Gets the generic parameter list of this enum, if it exists.
*/
GenericParamList getGenericParamList() { enum_generic_param_lists(this, result) }
/**
* Gets the name of this enum, if it exists.
*/
Name getName() { enum_names(this, result) }
/**
* Gets the variant list of this enum, if it exists.
*/
VariantList getVariantList() { enum_variant_lists(this, result) }
/**
* Gets the visibility of this enum, if it exists.
*/
Visibility getVisibility() { enum_visibilities(this, result) }
/**
* Gets the where clause of this enum, if it exists.
*/
WhereClause getWhereClause() { enum_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* An extern block containing foreign function declarations.
@@ -4273,50 +4243,6 @@ module Raw {
Visibility getVisibility() { static_visibilities(this, result) }
}
/**
* INTERNAL: Do not use.
* A Struct. For example:
* ```rust
* struct Point {
* x: i32,
* y: i32,
* }
* ```
*/
class Struct extends @struct, Item, VariantDef {
override string toString() { result = "Struct" }
/**
* Gets the `index`th attr of this struct (0-based).
*/
Attr getAttr(int index) { struct_attrs(this, index, result) }
/**
* Gets the field list of this struct, if it exists.
*/
FieldList getFieldList() { struct_field_lists_(this, result) }
/**
* Gets the generic parameter list of this struct, if it exists.
*/
GenericParamList getGenericParamList() { struct_generic_param_lists(this, result) }
/**
* Gets the name of this struct, if it exists.
*/
Name getName() { struct_names(this, result) }
/**
* Gets the visibility of this struct, if it exists.
*/
Visibility getVisibility() { struct_visibilities(this, result) }
/**
* Gets the where clause of this struct, if it exists.
*/
WhereClause getWhereClause() { struct_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A struct expression. For example:
@@ -4538,49 +4464,6 @@ module Raw {
WhereClause getWhereClause() { type_alias_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A union declaration.
*
* For example:
* ```rust
* union U { f1: u32, f2: f32 }
* ```
*/
class Union extends @union, Item, VariantDef {
override string toString() { result = "Union" }
/**
* Gets the `index`th attr of this union (0-based).
*/
Attr getAttr(int index) { union_attrs(this, index, result) }
/**
* Gets the generic parameter list of this union, if it exists.
*/
GenericParamList getGenericParamList() { union_generic_param_lists(this, result) }
/**
* Gets the name of this union, if it exists.
*/
Name getName() { union_names(this, result) }
/**
* Gets the struct field list of this union, if it exists.
*/
StructFieldList getStructFieldList() { union_struct_field_lists(this, result) }
/**
* Gets the visibility of this union, if it exists.
*/
Visibility getVisibility() { union_visibilities(this, result) }
/**
* Gets the where clause of this union, if it exists.
*/
WhereClause getWhereClause() { union_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A `use` statement. For example:
@@ -4607,6 +4490,49 @@ module Raw {
Visibility getVisibility() { use_visibilities(this, result) }
}
/**
* INTERNAL: Do not use.
* An enum declaration.
*
* For example:
* ```rust
* enum E {A, B(i32), C {x: i32}}
* ```
*/
class Enum extends @enum, Adt {
override string toString() { result = "Enum" }
/**
* Gets the `index`th attr of this enum (0-based).
*/
Attr getAttr(int index) { enum_attrs(this, index, result) }
/**
* Gets the generic parameter list of this enum, if it exists.
*/
GenericParamList getGenericParamList() { enum_generic_param_lists(this, result) }
/**
* Gets the name of this enum, if it exists.
*/
Name getName() { enum_names(this, result) }
/**
* Gets the variant list of this enum, if it exists.
*/
VariantList getVariantList() { enum_variant_lists(this, result) }
/**
* Gets the visibility of this enum, if it exists.
*/
Visibility getVisibility() { enum_visibilities(this, result) }
/**
* Gets the where clause of this enum, if it exists.
*/
WhereClause getWhereClause() { enum_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A for loop expression.
@@ -4671,6 +4597,93 @@ module Raw {
Attr getAttr(int index) { loop_expr_attrs(this, index, result) }
}
/**
* INTERNAL: Do not use.
* A Struct. For example:
* ```rust
* struct Point {
* x: i32,
* y: i32,
* }
* ```
*/
class Struct extends @struct, Adt, VariantDef {
override string toString() { result = "Struct" }
/**
* Gets the `index`th attr of this struct (0-based).
*/
Attr getAttr(int index) { struct_attrs(this, index, result) }
/**
* Gets the field list of this struct, if it exists.
*/
FieldList getFieldList() { struct_field_lists_(this, result) }
/**
* Gets the generic parameter list of this struct, if it exists.
*/
GenericParamList getGenericParamList() { struct_generic_param_lists(this, result) }
/**
* Gets the name of this struct, if it exists.
*/
Name getName() { struct_names(this, result) }
/**
* Gets the visibility of this struct, if it exists.
*/
Visibility getVisibility() { struct_visibilities(this, result) }
/**
* Gets the where clause of this struct, if it exists.
*/
WhereClause getWhereClause() { struct_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A union declaration.
*
* For example:
* ```rust
* union U { f1: u32, f2: f32 }
* ```
*/
class Union extends @union, Adt, VariantDef {
override string toString() { result = "Union" }
/**
* Gets the `index`th attr of this union (0-based).
*/
Attr getAttr(int index) { union_attrs(this, index, result) }
/**
* Gets the generic parameter list of this union, if it exists.
*/
GenericParamList getGenericParamList() { union_generic_param_lists(this, result) }
/**
* Gets the name of this union, if it exists.
*/
Name getName() { union_names(this, result) }
/**
* Gets the struct field list of this union, if it exists.
*/
StructFieldList getStructFieldList() { union_struct_field_lists(this, result) }
/**
* Gets the visibility of this union, if it exists.
*/
Visibility getVisibility() { union_visibilities(this, result) }
/**
* Gets the where clause of this union, if it exists.
*/
WhereClause getWhereClause() { union_where_clauses(this, result) }
}
/**
* INTERNAL: Do not use.
* A while loop expression.

View File

@@ -6,10 +6,10 @@
private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AdtImpl::Impl as AdtImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.FieldList
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.internal.ItemImpl::Impl as ItemImpl
import codeql.rust.elements.Name
import codeql.rust.elements.internal.VariantDefImpl::Impl as VariantDefImpl
import codeql.rust.elements.Visibility
@@ -31,7 +31,7 @@ module Generated {
* INTERNAL: Do not reference the `Generated::Struct` class directly.
* Use the subclass `Struct`, where the following predicates are available.
*/
class Struct extends Synth::TStruct, ItemImpl::Item, VariantDefImpl::VariantDef {
class Struct extends Synth::TStruct, AdtImpl::Adt, VariantDefImpl::VariantDef {
override string getAPrimaryQlClass() { result = "Struct" }
/**

View File

@@ -688,6 +688,11 @@ module Synth {
*/
class TAddressable = TItem or TVariant;
/**
* INTERNAL: Do not use.
*/
class TAdt = TEnum or TStruct or TUnion;
/**
* INTERNAL: Do not use.
*/
@@ -770,9 +775,9 @@ module Synth {
* INTERNAL: Do not use.
*/
class TItem =
TConst or TEnum or TExternBlock or TExternCrate or TFunction or TImpl or TMacroCall or
TMacroDef or TMacroRules or TModule or TStatic or TStruct or TTrait or TTraitAlias or
TTypeAlias or TUnion or TUse;
TAdt or TConst or TExternBlock or TExternCrate or TFunction or TImpl or TMacroCall or
TMacroDef or TMacroRules or TModule or TStatic or TTrait or TTraitAlias or TTypeAlias or
TUse;
/**
* INTERNAL: Do not use.
@@ -1864,6 +1869,18 @@ module Synth {
result = convertVariantFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `TAdt`, if possible.
*/
TAdt convertAdtFromRaw(Raw::Element e) {
result = convertEnumFromRaw(e)
or
result = convertStructFromRaw(e)
or
result = convertUnionFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `TArrayExpr`, if possible.
@@ -2213,9 +2230,9 @@ module Synth {
* Converts a raw DB element to a synthesized `TItem`, if possible.
*/
TItem convertItemFromRaw(Raw::Element e) {
result = convertConstFromRaw(e)
result = convertAdtFromRaw(e)
or
result = convertEnumFromRaw(e)
result = convertConstFromRaw(e)
or
result = convertExternBlockFromRaw(e)
or
@@ -2235,16 +2252,12 @@ module Synth {
or
result = convertStaticFromRaw(e)
or
result = convertStructFromRaw(e)
or
result = convertTraitFromRaw(e)
or
result = convertTraitAliasFromRaw(e)
or
result = convertTypeAliasFromRaw(e)
or
result = convertUnionFromRaw(e)
or
result = convertUseFromRaw(e)
}
@@ -3464,6 +3477,18 @@ module Synth {
result = convertVariantToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TAdt` to a raw DB element, if possible.
*/
Raw::Element convertAdtToRaw(TAdt e) {
result = convertEnumToRaw(e)
or
result = convertStructToRaw(e)
or
result = convertUnionToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TArrayExpr` to a raw DB element, if possible.
@@ -3813,9 +3838,9 @@ module Synth {
* Converts a synthesized `TItem` to a raw DB element, if possible.
*/
Raw::Element convertItemToRaw(TItem e) {
result = convertConstToRaw(e)
result = convertAdtToRaw(e)
or
result = convertEnumToRaw(e)
result = convertConstToRaw(e)
or
result = convertExternBlockToRaw(e)
or
@@ -3835,16 +3860,12 @@ module Synth {
or
result = convertStaticToRaw(e)
or
result = convertStructToRaw(e)
or
result = convertTraitToRaw(e)
or
result = convertTraitAliasToRaw(e)
or
result = convertTypeAliasToRaw(e)
or
result = convertUnionToRaw(e)
or
result = convertUseToRaw(e)
}

View File

@@ -6,9 +6,9 @@
private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AdtImpl::Impl as AdtImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.internal.ItemImpl::Impl as ItemImpl
import codeql.rust.elements.Name
import codeql.rust.elements.StructFieldList
import codeql.rust.elements.internal.VariantDefImpl::Impl as VariantDefImpl
@@ -30,7 +30,7 @@ module Generated {
* INTERNAL: Do not reference the `Generated::Union` class directly.
* Use the subclass `Union`, where the following predicates are available.
*/
class Union extends Synth::TUnion, ItemImpl::Item, VariantDefImpl::VariantDef {
class Union extends Synth::TUnion, AdtImpl::Adt, VariantDefImpl::VariantDef {
override string getAPrimaryQlClass() { result = "Union" }
/**

View File

@@ -1917,8 +1917,8 @@ infer_type_reprs(
);
@item =
@const
| @enum
@adt
| @const
| @extern_block
| @extern_crate
| @function
@@ -1928,11 +1928,9 @@ infer_type_reprs(
| @macro_rules
| @module
| @static
| @struct
| @trait
| @trait_alias
| @type_alias
| @union
| @use
;
@@ -2714,6 +2712,19 @@ yield_expr_exprs(
int expr: @expr ref
);
@adt =
@enum
| @struct
| @union
;
#keyset[id, index]
adt_derive_macro_expansions(
int id: @adt ref,
int index: int ref,
int derive_macro_expansion: @macro_items ref
);
block_exprs(
unique int id: @block_expr
);
@@ -2821,47 +2832,6 @@ const_has_implementation(
int id: @const ref
);
enums(
unique int id: @enum
);
#keyset[id, index]
enum_attrs(
int id: @enum ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
enum_generic_param_lists(
int id: @enum ref,
int generic_param_list: @generic_param_list ref
);
#keyset[id]
enum_names(
int id: @enum ref,
int name: @name ref
);
#keyset[id]
enum_variant_lists(
int id: @enum ref,
int variant_list: @variant_list ref
);
#keyset[id]
enum_visibilities(
int id: @enum ref,
int visibility: @visibility ref
);
#keyset[id]
enum_where_clauses(
int id: @enum ref,
int where_clause: @where_clause ref
);
extern_blocks(
unique int id: @extern_block
);
@@ -3278,47 +3248,6 @@ static_visibilities(
int visibility: @visibility ref
);
structs(
unique int id: @struct
);
#keyset[id, index]
struct_attrs(
int id: @struct ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
struct_field_lists_(
int id: @struct ref,
int field_list: @field_list ref
);
#keyset[id]
struct_generic_param_lists(
int id: @struct ref,
int generic_param_list: @generic_param_list ref
);
#keyset[id]
struct_names(
int id: @struct ref,
int name: @name ref
);
#keyset[id]
struct_visibilities(
int id: @struct ref,
int visibility: @visibility ref
);
#keyset[id]
struct_where_clauses(
int id: @struct ref,
int where_clause: @where_clause ref
);
struct_exprs(
unique int id: @struct_expr
);
@@ -3500,6 +3429,145 @@ type_alias_where_clauses(
int where_clause: @where_clause ref
);
uses(
unique int id: @use
);
#keyset[id, index]
use_attrs(
int id: @use ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
use_use_trees(
int id: @use ref,
int use_tree: @use_tree ref
);
#keyset[id]
use_visibilities(
int id: @use ref,
int visibility: @visibility ref
);
enums(
unique int id: @enum
);
#keyset[id, index]
enum_attrs(
int id: @enum ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
enum_generic_param_lists(
int id: @enum ref,
int generic_param_list: @generic_param_list ref
);
#keyset[id]
enum_names(
int id: @enum ref,
int name: @name ref
);
#keyset[id]
enum_variant_lists(
int id: @enum ref,
int variant_list: @variant_list ref
);
#keyset[id]
enum_visibilities(
int id: @enum ref,
int visibility: @visibility ref
);
#keyset[id]
enum_where_clauses(
int id: @enum ref,
int where_clause: @where_clause ref
);
for_exprs(
unique int id: @for_expr
);
#keyset[id, index]
for_expr_attrs(
int id: @for_expr ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
for_expr_iterables(
int id: @for_expr ref,
int iterable: @expr ref
);
#keyset[id]
for_expr_pats(
int id: @for_expr ref,
int pat: @pat ref
);
loop_exprs(
unique int id: @loop_expr
);
#keyset[id, index]
loop_expr_attrs(
int id: @loop_expr ref,
int index: int ref,
int attr: @attr ref
);
structs(
unique int id: @struct
);
#keyset[id, index]
struct_attrs(
int id: @struct ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
struct_field_lists_(
int id: @struct ref,
int field_list: @field_list ref
);
#keyset[id]
struct_generic_param_lists(
int id: @struct ref,
int generic_param_list: @generic_param_list ref
);
#keyset[id]
struct_names(
int id: @struct ref,
int name: @name ref
);
#keyset[id]
struct_visibilities(
int id: @struct ref,
int visibility: @visibility ref
);
#keyset[id]
struct_where_clauses(
int id: @struct ref,
int where_clause: @where_clause ref
);
unions(
unique int id: @union
);
@@ -3541,63 +3609,6 @@ union_where_clauses(
int where_clause: @where_clause ref
);
uses(
unique int id: @use
);
#keyset[id, index]
use_attrs(
int id: @use ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
use_use_trees(
int id: @use ref,
int use_tree: @use_tree ref
);
#keyset[id]
use_visibilities(
int id: @use ref,
int visibility: @visibility ref
);
for_exprs(
unique int id: @for_expr
);
#keyset[id, index]
for_expr_attrs(
int id: @for_expr ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
for_expr_iterables(
int id: @for_expr ref,
int iterable: @expr ref
);
#keyset[id]
for_expr_pats(
int id: @for_expr ref,
int pat: @pat ref
);
loop_exprs(
unique int id: @loop_expr
);
#keyset[id, index]
loop_expr_attrs(
int id: @loop_expr ref,
int index: int ref,
int attr: @attr ref
);
while_exprs(
unique int id: @while_expr
);

View File

@@ -4,8 +4,8 @@ import TestUtils
from
Enum x, string hasExtendedCanonicalPath, string hasCrateOrigin, string hasAttributeMacroExpansion,
int getNumberOfAttrs, string hasGenericParamList, string hasName, string hasVariantList,
string hasVisibility, string hasWhereClause
int getNumberOfDeriveMacroExpansions, int getNumberOfAttrs, string hasGenericParamList,
string hasName, string hasVariantList, string hasVisibility, string hasWhereClause
where
toBeTested(x) and
not x.isUnknown() and
@@ -20,6 +20,7 @@ where
then hasAttributeMacroExpansion = "yes"
else hasAttributeMacroExpansion = "no"
) and
getNumberOfDeriveMacroExpansions = x.getNumberOfDeriveMacroExpansions() and
getNumberOfAttrs = x.getNumberOfAttrs() and
(if x.hasGenericParamList() then hasGenericParamList = "yes" else hasGenericParamList = "no") and
(if x.hasName() then hasName = "yes" else hasName = "no") and
@@ -27,6 +28,7 @@ where
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no"
select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin,
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfAttrs:", getNumberOfAttrs,
"hasGenericParamList:", hasGenericParamList, "hasName:", hasName, "hasVariantList:",
hasVariantList, "hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfDeriveMacroExpansions:",
getNumberOfDeriveMacroExpansions, "getNumberOfAttrs:", getNumberOfAttrs, "hasGenericParamList:",
hasGenericParamList, "hasName:", hasName, "hasVariantList:", hasVariantList, "hasVisibility:",
hasVisibility, "hasWhereClause:", hasWhereClause

View File

@@ -0,0 +1,7 @@
// generated by codegen, do not edit
import codeql.rust.elements
import TestUtils
from Enum x, int index
where toBeTested(x) and not x.isUnknown()
select x, index, x.getDeriveMacroExpansion(index)

View File

@@ -4,8 +4,9 @@ import TestUtils
from
Struct x, string hasExtendedCanonicalPath, string hasCrateOrigin,
string hasAttributeMacroExpansion, int getNumberOfAttrs, string hasFieldList,
string hasGenericParamList, string hasName, string hasVisibility, string hasWhereClause
string hasAttributeMacroExpansion, int getNumberOfDeriveMacroExpansions, int getNumberOfAttrs,
string hasFieldList, string hasGenericParamList, string hasName, string hasVisibility,
string hasWhereClause
where
toBeTested(x) and
not x.isUnknown() and
@@ -20,6 +21,7 @@ where
then hasAttributeMacroExpansion = "yes"
else hasAttributeMacroExpansion = "no"
) and
getNumberOfDeriveMacroExpansions = x.getNumberOfDeriveMacroExpansions() and
getNumberOfAttrs = x.getNumberOfAttrs() and
(if x.hasFieldList() then hasFieldList = "yes" else hasFieldList = "no") and
(if x.hasGenericParamList() then hasGenericParamList = "yes" else hasGenericParamList = "no") and
@@ -27,6 +29,7 @@ where
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no"
select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin,
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfAttrs:", getNumberOfAttrs,
"hasFieldList:", hasFieldList, "hasGenericParamList:", hasGenericParamList, "hasName:", hasName,
"hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfDeriveMacroExpansions:",
getNumberOfDeriveMacroExpansions, "getNumberOfAttrs:", getNumberOfAttrs, "hasFieldList:",
hasFieldList, "hasGenericParamList:", hasGenericParamList, "hasName:", hasName, "hasVisibility:",
hasVisibility, "hasWhereClause:", hasWhereClause

View File

@@ -0,0 +1,7 @@
// generated by codegen, do not edit
import codeql.rust.elements
import TestUtils
from Struct x, int index
where toBeTested(x) and not x.isUnknown()
select x, index, x.getDeriveMacroExpansion(index)

View File

@@ -4,8 +4,9 @@ import TestUtils
from
Union x, string hasExtendedCanonicalPath, string hasCrateOrigin,
string hasAttributeMacroExpansion, int getNumberOfAttrs, string hasGenericParamList,
string hasName, string hasStructFieldList, string hasVisibility, string hasWhereClause
string hasAttributeMacroExpansion, int getNumberOfDeriveMacroExpansions, int getNumberOfAttrs,
string hasGenericParamList, string hasName, string hasStructFieldList, string hasVisibility,
string hasWhereClause
where
toBeTested(x) and
not x.isUnknown() and
@@ -20,6 +21,7 @@ where
then hasAttributeMacroExpansion = "yes"
else hasAttributeMacroExpansion = "no"
) and
getNumberOfDeriveMacroExpansions = x.getNumberOfDeriveMacroExpansions() and
getNumberOfAttrs = x.getNumberOfAttrs() and
(if x.hasGenericParamList() then hasGenericParamList = "yes" else hasGenericParamList = "no") and
(if x.hasName() then hasName = "yes" else hasName = "no") and
@@ -27,6 +29,7 @@ where
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no"
select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin,
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfAttrs:", getNumberOfAttrs,
"hasGenericParamList:", hasGenericParamList, "hasName:", hasName, "hasStructFieldList:",
hasStructFieldList, "hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfDeriveMacroExpansions:",
getNumberOfDeriveMacroExpansions, "getNumberOfAttrs:", getNumberOfAttrs, "hasGenericParamList:",
hasGenericParamList, "hasName:", hasName, "hasStructFieldList:", hasStructFieldList,
"hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause

View File

@@ -0,0 +1,7 @@
// generated by codegen, do not edit
import codeql.rust.elements
import TestUtils
from Union x, int index
where toBeTested(x) and not x.isUnknown()
select x, index, x.getDeriveMacroExpansion(index)

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
use proc_macro::{repeat, add_one, erase};
use proc_macro::{repeat, add_one, erase, MyTrait};
#[add_one]
pub fn foo() {
@@ -78,3 +78,25 @@ type MyInt = my_int!(); // this didn't expand in 0.0.274..0.0.287
struct MyStruct {
field: my_int!(), // this didn't expand in 0.0.274..0.0.287
}
#[derive(Debug)]
struct MyDerive {
field: usize,
}
#[derive(PartialEq, Eq)]
enum MyDeriveEnum {
Variant1,
Variant2,
}
trait MyTrait {
fn my_method() -> u32;
}
#[derive(MyTrait)]
union MyDeriveUnion {
field1: usize,
field2: f64,
}

View File

@@ -32,3 +32,20 @@ pub fn add_one(_attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn erase(_attr: TokenStream, _item: TokenStream) -> TokenStream {
TokenStream::new()
}
#[proc_macro_derive(MyTrait)]
pub fn my_trait_derive(input: TokenStream) -> TokenStream {
let ast = syn::parse_macro_input!(input as syn::DeriveInput);
let name = &ast.ident;
let const_ident = syn::Ident::new(&format!("CONST_{}", name), name.span());
quote! {
const #const_ident: u32 = 42;
impl MyTrait for #name {
fn my_method() -> u32 {
#const_ident
}
}
}.into()
}

View File

@@ -11,6 +11,12 @@ attribute_macros
| macro_expansion.rs:15:1:16:14 | fn bar_0 | 1 | macro_expansion.rs:16:1:16:14 | fn bar_0_new |
| macro_expansion.rs:15:1:16:14 | fn bar_1 | 0 | macro_expansion.rs:16:1:16:14 | fn bar_1 |
| macro_expansion.rs:15:1:16:14 | fn bar_1 | 1 | macro_expansion.rs:16:1:16:14 | fn bar_1_new |
derive_macros
| macro_expansion.rs:83:1:86:1 | struct MyDerive | 0 | 0 | macro_expansion.rs:84:8:85:9 | impl ...::Debug for MyDerive::<...> { ... } |
| macro_expansion.rs:88:1:92:1 | enum MyDeriveEnum | 0 | 0 | macro_expansion.rs:89:6:91:12 | impl ...::PartialEq for MyDeriveEnum::<...> { ... } |
| macro_expansion.rs:88:1:92:1 | enum MyDeriveEnum | 1 | 0 | macro_expansion.rs:89:6:89:17 | impl ...::Eq for MyDeriveEnum::<...> { ... } |
| macro_expansion.rs:98:1:102:1 | union MyDeriveUnion | 0 | 0 | macro_expansion.rs:99:7:99:19 | Const |
| macro_expansion.rs:98:1:102:1 | union MyDeriveUnion | 0 | 1 | macro_expansion.rs:99:7:99:19 | impl MyTrait for MyDeriveUnion { ... } |
macro_calls
| included/included.rs:2:9:2:39 | concat!... | included/included.rs:2:17:2:38 | "Hello world!" |
| macro_expansion.rs:5:9:5:34 | concat!... | macro_expansion.rs:5:17:5:34 | "Hello world!" |

View File

@@ -5,6 +5,10 @@ query predicate attribute_macros(Item i, int index, Item expanded) {
i.fromSource() and expanded = i.getAttributeMacroExpansion().getItem(index)
}
query predicate derive_macros(Adt i, int index, int subIndex, Item expanded) {
i.fromSource() and expanded = i.getDeriveMacroExpansion(index).getItem(subIndex)
}
query predicate macro_calls(MacroCall c, AstNode expansion) {
c.fromSource() and
not c.getLocation().getFile().getAbsolutePath().matches("%proc_macro.rs") and

View File

@@ -16,6 +16,13 @@ class LoopingExpr(LabelableExpr):
loop_body: optional["BlockExpr"] | child
class Adt(Item):
"""
An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
"""
derive_macro_expansions: list[MacroItems] | child | rust.detach
@annotate(Module)
@rust.doc_test_signature(None)
class _:
@@ -1032,7 +1039,7 @@ class _:
"""
@annotate(Enum)
@annotate(Enum, replace_bases={Item: Adt})
class _:
"""
An enum declaration.
@@ -1827,7 +1834,7 @@ class _:
"""
@annotate(Struct)
@annotate(Struct, replace_bases={Item: Adt})
class _:
"""
A Struct. For example:
@@ -2006,7 +2013,7 @@ class _:
"""
@annotate(Union)
@annotate(Union, replace_bases={Item: Adt})
class _:
"""
A union declaration.