From 86142f2e94cbcd89719e77c088e1c99f69604f2d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 26 Sep 2019 13:44:43 -0700 Subject: [PATCH] Use `r#` to escape strings which may be rust keywords. (#379) This is a minor simplification, replacing a hardcoded list of keywords. --- build.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/build.rs b/build.rs index 8acbdfb85c..eec184afb3 100644 --- a/build.rs +++ b/build.rs @@ -76,11 +76,7 @@ fn write_testsuite_tests(out: &mut File, dir_entry: DirEntry, testsuite: &str) - if ignore(testsuite, stemstr) { writeln!(out, " #[ignore]")?; } - writeln!( - out, - " fn {}() {{", - avoid_keywords(&stemstr.replace("-", "_")) - )?; + writeln!(out, " fn r#{}() {{", &stemstr.replace("-", "_"))?; writeln!(out, " let isa = native_isa();")?; writeln!(out, " let compiler = Compiler::new(isa);")?; writeln!( @@ -107,18 +103,6 @@ fn write_testsuite_tests(out: &mut File, dir_entry: DirEntry, testsuite: &str) - Ok(()) } -/// Rename tests which have the same name as Rust keywords. -fn avoid_keywords(name: &str) -> &str { - match name { - "if" => "if_", - "loop" => "loop_", - "type" => "type_", - "const" => "const_", - "return" => "return_", - other => other, - } -} - /// Ignore tests that aren't supported yet. fn ignore(testsuite: &str, name: &str) -> bool { if cfg!(windows) {