diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 22096203d4ce6..82982a1b43ec0 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -204,7 +204,7 @@ impl<'a, I: Iterator- >> Iterator for CodeBlocks<'_, 'a, I> {
CodeBlockKind::Fenced(ref lang) => {
LangString::parse_without_check(&lang, self.check_error_codes, false)
}
- CodeBlockKind::Indented => LangString::all_false(),
+ CodeBlockKind::Indented => Default::default(),
};
if !parse_result.rust {
return Some(Event::Start(Tag::CodeBlock(kind)));
@@ -665,7 +665,7 @@ crate fn find_testable_code(
let block_info = match kind {
CodeBlockKind::Fenced(ref lang) => {
if lang.is_empty() {
- LangString::all_false()
+ Default::default()
} else {
LangString::parse(
lang,
@@ -675,7 +675,7 @@ crate fn find_testable_code(
)
}
}
- CodeBlockKind::Indented => LangString::all_false(),
+ CodeBlockKind::Indented => Default::default(),
};
if !block_info.rust {
continue;
@@ -778,14 +778,14 @@ crate enum Ignore {
Some(Vec),
}
-impl LangString {
- fn all_false() -> LangString {
- LangString {
+impl Default for LangString {
+ fn default() -> Self {
+ Self {
original: String::new(),
should_panic: false,
no_run: false,
ignore: Ignore::None,
- rust: true, // NB This used to be `notrust = false`
+ rust: true,
test_harness: false,
compile_fail: false,
error_codes: Vec::new(),
@@ -793,7 +793,9 @@ impl LangString {
edition: None,
}
}
+}
+impl LangString {
fn parse_without_check(
string: &str,
allow_error_code_check: ErrorCodes,
@@ -811,7 +813,7 @@ impl LangString {
let allow_error_code_check = allow_error_code_check.as_bool();
let mut seen_rust_tags = false;
let mut seen_other_tags = false;
- let mut data = LangString::all_false();
+ let mut data = LangString::default();
let mut ignores = vec![];
data.original = string.to_owned();
@@ -1233,7 +1235,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec {
let syntax = syntax.as_ref();
let lang_string = if syntax.is_empty() {
- LangString::all_false()
+ Default::default()
} else {
LangString::parse(&*syntax, ErrorCodes::Yes, false, Some(extra_info))
};
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index 75ff3c5af2fd2..9da3072ec282f 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -56,71 +56,59 @@ fn test_lang_string_parse() {
assert_eq!(LangString::parse(s, ErrorCodes::Yes, true, None), lg)
}
- t(LangString::all_false());
- t(LangString { original: "rust".into(), ..LangString::all_false() });
- t(LangString { original: "sh".into(), rust: false, ..LangString::all_false() });
- t(LangString { original: "ignore".into(), ignore: Ignore::All, ..LangString::all_false() });
+ t(Default::default());
+ t(LangString { original: "rust".into(), ..Default::default() });
+ t(LangString { original: "sh".into(), rust: false, ..Default::default() });
+ t(LangString { original: "ignore".into(), ignore: Ignore::All, ..Default::default() });
t(LangString {
original: "ignore-foo".into(),
ignore: Ignore::Some(vec!["foo".to_string()]),
- ..LangString::all_false()
- });
- t(LangString {
- original: "should_panic".into(),
- should_panic: true,
- ..LangString::all_false()
- });
- t(LangString { original: "no_run".into(), no_run: true, ..LangString::all_false() });
- t(LangString {
- original: "test_harness".into(),
- test_harness: true,
- ..LangString::all_false()
+ ..Default::default()
});
+ t(LangString { original: "should_panic".into(), should_panic: true, ..Default::default() });
+ t(LangString { original: "no_run".into(), no_run: true, ..Default::default() });
+ t(LangString { original: "test_harness".into(), test_harness: true, ..Default::default() });
t(LangString {
original: "compile_fail".into(),
no_run: true,
compile_fail: true,
- ..LangString::all_false()
- });
- t(LangString { original: "allow_fail".into(), allow_fail: true, ..LangString::all_false() });
- t(LangString {
- original: "{.no_run .example}".into(),
- no_run: true,
- ..LangString::all_false()
+ ..Default::default()
});
+ t(LangString { original: "allow_fail".into(), allow_fail: true, ..Default::default() });
+ t(LangString { original: "{.no_run .example}".into(), no_run: true, ..Default::default() });
t(LangString {
original: "{.sh .should_panic}".into(),
should_panic: true,
rust: false,
- ..LangString::all_false()
+ ..Default::default()
});
- t(LangString { original: "{.example .rust}".into(), ..LangString::all_false() });
+ t(LangString { original: "{.example .rust}".into(), ..Default::default() });
t(LangString {
original: "{.test_harness .rust}".into(),
test_harness: true,
- ..LangString::all_false()
+ ..Default::default()
});
t(LangString {
original: "text, no_run".into(),
no_run: true,
rust: false,
- ..LangString::all_false()
+ ..Default::default()
});
t(LangString {
original: "text,no_run".into(),
no_run: true,
rust: false,
- ..LangString::all_false()
+ ..Default::default()
});
t(LangString {
original: "edition2015".into(),
edition: Some(Edition::Edition2015),
- ..LangString::all_false()
+ ..Default::default()
});
t(LangString {
original: "edition2018".into(),
edition: Some(Edition::Edition2018),
- ..LangString::all_false()
+ ..Default::default()
});
}