Improve code for codeblock invalid attributes

This commit is contained in:
Guillaume Gomez 2024-09-27 21:28:15 +02:00
parent cdf2a8ffc5
commit 35f24d0d14

View File

@ -1298,35 +1298,28 @@ impl LangString {
} }
LangStringToken::LangToken(x) if extra.is_some() => { LangStringToken::LangToken(x) if extra.is_some() => {
let s = x.to_lowercase(); let s = x.to_lowercase();
if let Some((flag, help)) = if s == "compile-fail" if let Some((flag, help)) = match s.as_str() {
|| s == "compile_fail" "compile-fail" | "compile_fail" | "compilefail" => Some((
|| s == "compilefail"
{
Some((
"compile_fail", "compile_fail",
"the code block will either not be tested if not marked as a rust one \ "the code block will either not be tested if not marked as a rust \
or won't fail if it compiles successfully", one or won't fail if it compiles successfully",
)) )),
} else if s == "should-panic" || s == "should_panic" || s == "shouldpanic" { "should-panic" | "should_panic" | "shouldpanic" => Some((
Some((
"should_panic", "should_panic",
"the code block will either not be tested if not marked as a rust one \ "the code block will either not be tested if not marked as a rust \
or won't fail if it doesn't panic when running", one or won't fail if it doesn't panic when running",
)) )),
} else if s == "no-run" || s == "no_run" || s == "norun" { "no-run" | "no_run" | "norun" => Some((
Some((
"no_run", "no_run",
"the code block will either not be tested if not marked as a rust one \ "the code block will either not be tested if not marked as a rust \
or will be run (which you might not want)", one or will be run (which you might not want)",
)) )),
} else if s == "test-harness" || s == "test_harness" || s == "testharness" { "test-harness" | "test_harness" | "testharness" => Some((
Some((
"test_harness", "test_harness",
"the code block will either not be tested if not marked as a rust one \ "the code block will either not be tested if not marked as a rust \
or the code will be wrapped inside a main function", one or the code will be wrapped inside a main function",
)) )),
} else { _ => None,
None
} { } {
if let Some(extra) = extra { if let Some(extra) = extra {
extra.error_invalid_codeblock_attr_with_help( extra.error_invalid_codeblock_attr_with_help(