From 7415af997a6577e10eecdfd553575e324d3d19e8 Mon Sep 17 00:00:00 2001 From: Iain McGinniss <309153+iainmcgin@users.noreply.github.com> Date: Mon, 20 Apr 2026 22:28:30 +0800 Subject: [PATCH] refactor: deduplicate Rust keyword list in buffa-build buffa-build maintained its own copy of the Rust keyword list for module name escaping, duplicating the canonical list in buffa-codegen::idents. This creates a maintenance hazard: if a new keyword is added to one list but not the other, generated module names could become invalid. Replace the inline keyword list and escaping logic with a call to the existing buffa_codegen::idents::escape_mod_ident function, which is already a public dependency. Co-authored-by: Qiaochu Hu <110803307+hobostay@users.noreply.github.com> --- buffa-build/src/lib.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/buffa-build/src/lib.rs b/buffa-build/src/lib.rs index 8b081e0..fde11e4 100644 --- a/buffa-build/src/lib.rs +++ b/buffa-build/src/lib.rs @@ -829,23 +829,7 @@ fn generate_include_file(entries: &[(String, String)], relative: bool) -> String use std::fmt::Write; fn escape_mod_name(name: &str) -> String { - const KEYWORDS: &[&str] = &[ - "as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", - "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", - "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", - "unsafe", "use", "where", "while", "async", "await", "dyn", "gen", "abstract", - "become", "box", "do", "final", "macro", "override", "priv", "try", "typeof", - "unsized", "virtual", "yield", - ]; - if KEYWORDS.contains(&name) { - if matches!(name, "self" | "super" | "Self" | "crate") { - format!("{name}_") - } else { - format!("r#{name}") - } - } else { - name.to_string() - } + buffa_codegen::idents::escape_mod_ident(name) } #[derive(Default)]