From 0f4f9d78326c275b5f801d335f95d8aaa0223335 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 8 Nov 2019 12:28:05 -0800 Subject: [PATCH] Use `r#` to escape strings which may be rust keywords. This is a minor simplification, replacing a hardcoded list of keywords. --- crates/wasi-common/build.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/crates/wasi-common/build.rs b/crates/wasi-common/build.rs index 1858fc5c7f0e..613982022b38 100644 --- a/crates/wasi-common/build.rs +++ b/crates/wasi-common/build.rs @@ -129,8 +129,8 @@ mod wasm_tests { } writeln!( out, - " fn {}() -> anyhow::Result<()> {{", - avoid_keywords(&stemstr.replace("-", "_")) + " fn r#{}() -> anyhow::Result<()> {{", + &stemstr.replace("-", "_") )?; writeln!(out, " setup_log();")?; write!( @@ -162,18 +162,6 @@ mod wasm_tests { 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, - } - } - cfg_if::cfg_if! { if #[cfg(not(windows))] { /// Ignore tests that aren't supported yet.