Skip to content

Commit b481190

Browse files
author
Paolo Tranquilli
committed
Rust: address review
1 parent ce2877d commit b481190

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

rust/ast-generator/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{fs, path::PathBuf};
44
pub mod codegen;
55
mod flags;
66
use codegen::grammar::ast_src::{AstNodeSrc, AstSrc, Field};
7-
use itertools::Itertools;
87
use std::collections::{BTreeMap, BTreeSet};
98
use std::env;
109
use ungrammar::Grammar;

rust/extractor/src/translate/base.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,12 @@ impl<'a> Translator<'a> {
560560
}
561561

562562
pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool {
563-
let Some(sema) = self.semantics else {
564-
return false;
565-
};
566-
for attr in item.attrs() {
567-
if let Some((name, tokens)) = attr.as_simple_call() {
568-
if name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false) {
569-
return true;
570-
}
571-
}
572-
}
573-
false
563+
self.semantics.is_some_and(|sema| {
564+
item.attrs().any(|attr| {
565+
attr.as_simple_call().is_some_and(|(name, tokens)| {
566+
name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false)
567+
})
568+
})
569+
})
574570
}
575571
}

0 commit comments

Comments
 (0)