mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Rust: rename MacroStmts to MacroBlockExpr
This commit is contained in:
2
rust/extractor/src/generated/.generated.list
generated
2
rust/extractor/src/generated/.generated.list
generated
@@ -1,2 +1,2 @@
|
||||
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
|
||||
top.rs f7c07bc5a6ad3e1a3af05d16b5b448509f9f8403a510bfca1db42348d3c7038b f7c07bc5a6ad3e1a3af05d16b5b448509f9f8403a510bfca1db42348d3c7038b
|
||||
top.rs 47c9cc0e39e81a89bf62497e7b3e45c9cd585c425aaac7fc5d07113e8ef9861d 47c9cc0e39e81a89bf62497e7b3e45c9cd585c425aaac7fc5d07113e8ef9861d
|
||||
|
||||
126
rust/extractor/src/generated/top.rs
generated
126
rust/extractor/src/generated/top.rs
generated
@@ -6307,6 +6307,69 @@ impl From<trap::Label<LiteralPat>> for trap::Label<Element> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MacroBlockExpr {
|
||||
pub id: trap::TrapId<MacroBlockExpr>,
|
||||
pub tail_expr: Option<trap::Label<Expr>>,
|
||||
pub statements: Vec<trap::Label<Stmt>>,
|
||||
}
|
||||
|
||||
impl trap::TrapEntry for MacroBlockExpr {
|
||||
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("macro_block_exprs", vec![id.into()]);
|
||||
if let Some(v) = self.tail_expr {
|
||||
out.add_tuple("macro_block_expr_tail_exprs", vec![id.into(), v.into()]);
|
||||
}
|
||||
for (i, v) in self.statements.into_iter().enumerate() {
|
||||
out.add_tuple("macro_block_expr_statements", vec![id.into(), i.into(), v.into()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl trap::TrapClass for MacroBlockExpr {
|
||||
fn class_name() -> &'static str { "MacroBlockExpr" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroBlockExpr>> for trap::Label<Expr> {
|
||||
fn from(value: trap::Label<MacroBlockExpr>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroBlockExpr is a subclass of Expr
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroBlockExpr>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<MacroBlockExpr>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroBlockExpr is a subclass of AstNode
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroBlockExpr>> for trap::Label<Locatable> {
|
||||
fn from(value: trap::Label<MacroBlockExpr>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroBlockExpr is a subclass of Locatable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroBlockExpr>> for trap::Label<Element> {
|
||||
fn from(value: trap::Label<MacroBlockExpr>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroBlockExpr is a subclass of Element
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MacroExpr {
|
||||
pub id: trap::TrapId<MacroExpr>,
|
||||
@@ -6425,69 +6488,6 @@ impl From<trap::Label<MacroPat>> for trap::Label<Element> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MacroStmts {
|
||||
pub id: trap::TrapId<MacroStmts>,
|
||||
pub expr: Option<trap::Label<Expr>>,
|
||||
pub statements: Vec<trap::Label<Stmt>>,
|
||||
}
|
||||
|
||||
impl trap::TrapEntry for MacroStmts {
|
||||
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("macro_stmts", vec![id.into()]);
|
||||
if let Some(v) = self.expr {
|
||||
out.add_tuple("macro_stmts_exprs", vec![id.into(), v.into()]);
|
||||
}
|
||||
for (i, v) in self.statements.into_iter().enumerate() {
|
||||
out.add_tuple("macro_stmts_statements", vec![id.into(), i.into(), v.into()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl trap::TrapClass for MacroStmts {
|
||||
fn class_name() -> &'static str { "MacroStmts" }
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroStmts>> for trap::Label<Expr> {
|
||||
fn from(value: trap::Label<MacroStmts>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of Expr
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroStmts>> for trap::Label<AstNode> {
|
||||
fn from(value: trap::Label<MacroStmts>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of AstNode
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroStmts>> for trap::Label<Locatable> {
|
||||
fn from(value: trap::Label<MacroStmts>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of Locatable
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<trap::Label<MacroStmts>> for trap::Label<Element> {
|
||||
fn from(value: trap::Label<MacroStmts>) -> Self {
|
||||
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of Element
|
||||
unsafe {
|
||||
Self::from_untyped(value.as_untyped())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MacroTypeRepr {
|
||||
pub id: trap::TrapId<MacroTypeRepr>,
|
||||
|
||||
10
rust/extractor/src/translate/generated.rs
generated
10
rust/extractor/src/translate/generated.rs
generated
@@ -1365,16 +1365,16 @@ impl Translator<'_> {
|
||||
Some(label)
|
||||
}
|
||||
|
||||
pub(crate) fn emit_macro_stmts(&mut self, node: ast::MacroStmts) -> Option<Label<generated::MacroStmts>> {
|
||||
let expr = node.expr().and_then(|x| self.emit_expr(x));
|
||||
pub(crate) fn emit_macro_stmts(&mut self, node: ast::MacroStmts) -> Option<Label<generated::MacroBlockExpr>> {
|
||||
let tail_expr = node.expr().and_then(|x| self.emit_expr(x));
|
||||
let statements = node.statements().filter_map(|x| self.emit_stmt(x)).collect();
|
||||
let label = self.trap.emit(generated::MacroStmts {
|
||||
let label = self.trap.emit(generated::MacroBlockExpr {
|
||||
id: TrapId::Star,
|
||||
expr,
|
||||
tail_expr,
|
||||
statements,
|
||||
});
|
||||
self.emit_location(label, &node);
|
||||
emit_detached!(MacroStmts, self, node, label);
|
||||
emit_detached!(MacroBlockExpr, self, node, label);
|
||||
self.emit_tokens(&node, label.into(), node.syntax().children_with_tokens());
|
||||
Some(label)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user