Remove tt -> ast -> tt round trips in attrs lowering

This commit is contained in:
Lukas Wirth 2024-01-24 22:32:46 +01:00
parent f09020567e
commit e320004dad
7 changed files with 94 additions and 72 deletions

View file

@ -18,28 +18,6 @@ pub enum CfgAtom {
KeyValue { key: SmolStr, value: SmolStr },
}
impl CfgAtom {
/// Returns `true` when the atom comes from the target specification.
///
/// If this returns `true`, then changing this atom requires changing the compilation target. If
/// it returns `false`, the atom might come from a build script or the build system.
pub fn is_target_defined(&self) -> bool {
match self {
CfgAtom::Flag(flag) => matches!(&**flag, "unix" | "windows"),
CfgAtom::KeyValue { key, value: _ } => matches!(
&**key,
"target_arch"
| "target_os"
| "target_env"
| "target_family"
| "target_endian"
| "target_pointer_width"
| "target_vendor" // NOTE: `target_feature` is left out since it can be configured via `-Ctarget-feature`
),
}
}
}
impl fmt::Display for CfgAtom {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {