Skip to content

Commit ada8918

Browse files
Improve code for codeblock invalid attributes
1 parent 4da0340 commit ada8918

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,35 +1298,28 @@ impl LangString {
12981298
}
12991299
LangStringToken::LangToken(x) if extra.is_some() => {
13001300
let s = x.to_lowercase();
1301-
if let Some((flag, help)) = if s == "compile-fail"
1302-
|| s == "compile_fail"
1303-
|| s == "compilefail"
1304-
{
1305-
Some((
1301+
if let Some((flag, help)) = match s.as_str() {
1302+
"compile-fail" | "compile_fail" | "compilefail" => Some((
13061303
"compile_fail",
1307-
"the code block will either not be tested if not marked as a rust one \
1308-
or won't fail if it compiles successfully",
1309-
))
1310-
} else if s == "should-panic" || s == "should_panic" || s == "shouldpanic" {
1311-
Some((
1304+
"the code block will either not be tested if not marked as a rust \
1305+
one or won't fail if it compiles successfully",
1306+
)),
1307+
"should-panic" | "should_panic" | "shouldpanic" => Some((
13121308
"should_panic",
1313-
"the code block will either not be tested if not marked as a rust one \
1314-
or won't fail if it doesn't panic when running",
1315-
))
1316-
} else if s == "no-run" || s == "no_run" || s == "norun" {
1317-
Some((
1309+
"the code block will either not be tested if not marked as a rust \
1310+
one or won't fail if it doesn't panic when running",
1311+
)),
1312+
"no-run" | "no_run" | "norun" => Some((
13181313
"no_run",
1319-
"the code block will either not be tested if not marked as a rust one \
1320-
or will be run (which you might not want)",
1321-
))
1322-
} else if s == "test-harness" || s == "test_harness" || s == "testharness" {
1323-
Some((
1314+
"the code block will either not be tested if not marked as a rust \
1315+
one or will be run (which you might not want)",
1316+
)),
1317+
"test-harness" | "test_harness" | "testharness" => Some((
13241318
"test_harness",
1325-
"the code block will either not be tested if not marked as a rust one \
1326-
or the code will be wrapped inside a main function",
1327-
))
1328-
} else {
1329-
None
1319+
"the code block will either not be tested if not marked as a rust \
1320+
one or the code will be wrapped inside a main function",
1321+
)),
1322+
_ => None,
13301323
} {
13311324
if let Some(extra) = extra {
13321325
extra.error_invalid_codeblock_attr_with_help(

0 commit comments

Comments
 (0)