Rust: address review

This commit is contained in:
Paolo Tranquilli
2025-01-07 13:05:19 +01:00
parent ce2877da5d
commit b4811906ea
2 changed files with 7 additions and 12 deletions

View File

@@ -4,7 +4,6 @@ use std::{fs, path::PathBuf};
pub mod codegen;
mod flags;
use codegen::grammar::ast_src::{AstNodeSrc, AstSrc, Field};
use itertools::Itertools;
use std::collections::{BTreeMap, BTreeSet};
use std::env;
use ungrammar::Grammar;

View File

@@ -560,16 +560,12 @@ impl<'a> Translator<'a> {
}
pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool {
let Some(sema) = self.semantics else {
return false;
};
for attr in item.attrs() {
if let Some((name, tokens)) = attr.as_simple_call() {
if name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false) {
return true;
}
}
}
false
self.semantics.is_some_and(|sema| {
item.attrs().any(|attr| {
attr.as_simple_call().is_some_and(|(name, tokens)| {
name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false)
})
})
})
}
}