Skip to content

Commit df3f97e

Browse files
committed
codeql-cli-2.22.3/rust import
1 parent 8bf1a48 commit df3f97e

File tree

528 files changed

+37768
-7203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

528 files changed

+37768
-7203
lines changed

rust/ast-generator/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ struct ExtractorEnumInfo {
363363
snake_case_name: String,
364364
ast_name: String,
365365
variants: Vec<EnumVariantInfo>,
366+
has_special_emission: bool,
366367
}
367368

368369
#[derive(Serialize, Default)]
@@ -384,6 +385,7 @@ struct ExtractorNodeInfo {
384385
ast_name: String,
385386
fields: Vec<ExtractorNodeFieldInfo>,
386387
has_attrs: bool,
388+
has_special_emission: bool,
387389
}
388390

389391
#[derive(Serialize)]
@@ -465,6 +467,7 @@ fn node_to_extractor_info(node: &AstNodeSrc) -> ExtractorNodeInfo {
465467
ast_name: node.name.clone(),
466468
fields,
467469
has_attrs,
470+
has_special_emission: has_special_emission(&node.name),
468471
}
469472
}
470473

rust/ast-generator/templates/extractor.mustache

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Generated by `ast-generator`, do not edit by hand.
22

33
use super::base::Translator;
4-
use super::mappings::TextValue;
5-
use crate::{pre_emit,post_emit};
4+
use super::mappings::{TextValue, HasTrapClass, Emission};
65
use crate::generated;
76
use crate::trap::{Label, TrapId};
87
use ra_ap_syntax::ast::{
@@ -13,29 +12,23 @@ use ra_ap_syntax::ast::{
1312
use ra_ap_syntax::{AstNode, ast};
1413

1514
impl Translator<'_> {
16-
fn emit_else_branch(&mut self, node: &ast::ElseBranch) -> Option<Label<generated::Expr>> {
17-
match node {
18-
ast::ElseBranch::IfExpr(inner) => self.emit_if_expr(inner).map(Into::into),
19-
ast::ElseBranch::Block(inner) => self.emit_block_expr(inner).map(Into::into),
20-
}
21-
}
2215
{{#enums}}
2316

2417
pub(crate) fn emit_{{snake_case_name}}(&mut self, node: &ast::{{ast_name}}) -> Option<Label<generated::{{name}}>> {
25-
pre_emit!({{name}}, self, node);
18+
{{>pre_emission}}
2619
let label = match node {
2720
{{#variants}}
2821
ast::{{ast_name}}::{{variant_ast_name}}(inner) => self.emit_{{snake_case_name}}(inner).map(Into::into),
2922
{{/variants}}
3023
}?;
31-
post_emit!({{name}}, self, node, label);
24+
{{>post_emission}}
3225
Some(label)
3326
}
3427
{{/enums}}
3528
{{#nodes}}
3629

3730
pub(crate) fn emit_{{snake_case_name}}(&mut self, node: &ast::{{ast_name}}) -> Option<Label<generated::{{name}}>> {
38-
pre_emit!({{name}}, self, node);
31+
{{>pre_emission}}
3932
{{#has_attrs}}
4033
if self.should_be_excluded(node) { return None; }
4134
{{/has_attrs}}
@@ -65,9 +58,15 @@ impl Translator<'_> {
6558
{{/fields}}
6659
});
6760
self.emit_location(label, node);
68-
post_emit!({{name}}, self, node, label);
61+
{{>post_emission}}
6962
self.emit_tokens(node, label.into(), node.syntax().children_with_tokens());
7063
Some(label)
7164
}
7265
{{/nodes}}
7366
}
67+
{{#enums}}
68+
{{>trap_class_mapping}}
69+
{{/enums}}
70+
{{#nodes}}
71+
{{>trap_class_mapping}}
72+
{{/nodes}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#has_special_emission}}
2+
self.post_emit(node, label);
3+
{{/has_special_emission}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{#has_special_emission}}
2+
if let Some(label) = self.pre_emit(node) {
3+
return Some(label);
4+
}
5+
{{/has_special_emission}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{#has_special_emission}}
2+
3+
impl HasTrapClass for ast::{{ast_name}} {
4+
type TrapClass = generated::{{name}};
5+
}
6+
{{/has_special_emission}}

0 commit comments

Comments
 (0)