Use r# to escape strings which may be rust keywords.
This is a minor simplification, replacing a hardcoded list of keywords.
This commit is contained in:
@@ -129,8 +129,8 @@ mod wasm_tests {
|
|||||||
}
|
}
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
" fn {}() -> anyhow::Result<()> {{",
|
" fn r#{}() -> anyhow::Result<()> {{",
|
||||||
avoid_keywords(&stemstr.replace("-", "_"))
|
&stemstr.replace("-", "_")
|
||||||
)?;
|
)?;
|
||||||
writeln!(out, " setup_log();")?;
|
writeln!(out, " setup_log();")?;
|
||||||
write!(
|
write!(
|
||||||
@@ -162,18 +162,6 @@ mod wasm_tests {
|
|||||||
Ok(())
|
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! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(not(windows))] {
|
if #[cfg(not(windows))] {
|
||||||
/// Ignore tests that aren't supported yet.
|
/// Ignore tests that aren't supported yet.
|
||||||
|
|||||||
Reference in New Issue
Block a user