Skip to content

Commit

Permalink
Use r# to escape strings which may be rust keywords.
Browse files Browse the repository at this point in the history
This is a minor simplification, replacing a hardcoded list of keywords.
  • Loading branch information
sunfishcode authored and kubkon committed Nov 8, 2019
1 parent c6bd737 commit 0f4f9d7
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions crates/wasi-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0f4f9d7

Please sign in to comment.