Top level attributes

This commit is contained in:
2026-05-05 15:08:38 +02:00
parent ce50247895
commit 8793c5d69a
5 changed files with 28 additions and 7 deletions
+12 -2
View File
@@ -228,8 +228,17 @@ impl ToRust for Block {
impl ToRust for TopLevel {
fn to_rust(&self, cg: &mut RustCodegen) {
for attr in &self.1 {
cg.addln(&format!("#[{}]", attr.get_rust()));
match &self.0 {
TopLevelKind::ModAttribute => {
for attr in &self.1 {
cg.addln(&format!("#![{}]", attr.get_rust()));
}
}
_ => {
for attr in &self.1 {
cg.addln(&format!("#[{}]", attr.get_rust()));
}
}
}
self.0.to_rust(cg);
@@ -261,6 +270,7 @@ impl GetRust for Attribute {
impl ToRust for TopLevelKind {
fn to_rust(&self, cg: &mut RustCodegen) {
match self {
Self::ModAttribute => {}
Self::Include(path) => {
cg.addln(&format!("use {};", path.get_rust()));
}