Use r# to escape strings which may be rust keywords. (#379)
This is a minor simplification, replacing a hardcoded list of keywords.
This commit is contained in:
committed by
Yury Delendik
parent
4288f33440
commit
86142f2e94
18
build.rs
18
build.rs
@@ -76,11 +76,7 @@ fn write_testsuite_tests(out: &mut File, dir_entry: DirEntry, testsuite: &str) -
|
|||||||
if ignore(testsuite, stemstr) {
|
if ignore(testsuite, stemstr) {
|
||||||
writeln!(out, " #[ignore]")?;
|
writeln!(out, " #[ignore]")?;
|
||||||
}
|
}
|
||||||
writeln!(
|
writeln!(out, " fn r#{}() {{", &stemstr.replace("-", "_"))?;
|
||||||
out,
|
|
||||||
" fn {}() {{",
|
|
||||||
avoid_keywords(&stemstr.replace("-", "_"))
|
|
||||||
)?;
|
|
||||||
writeln!(out, " let isa = native_isa();")?;
|
writeln!(out, " let isa = native_isa();")?;
|
||||||
writeln!(out, " let compiler = Compiler::new(isa);")?;
|
writeln!(out, " let compiler = Compiler::new(isa);")?;
|
||||||
writeln!(
|
writeln!(
|
||||||
@@ -107,18 +103,6 @@ fn write_testsuite_tests(out: &mut File, dir_entry: DirEntry, testsuite: &str) -
|
|||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ignore tests that aren't supported yet.
|
/// Ignore tests that aren't supported yet.
|
||||||
fn ignore(testsuite: &str, name: &str) -> bool {
|
fn ignore(testsuite: &str, name: &str) -> bool {
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
|
|||||||
Reference in New Issue
Block a user