diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 61dc4357c41b..db30836b43f1 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -921,7 +921,7 @@ pub(crate) fn new(data: &'a str, extra: Option<&'a ExtraInfo<'tcx>>) -> Self { Self { inner: data.char_indices().peekable(), data, is_in_attribute_block: false, extra } } - fn emit_error(&self, err: &str) { + fn emit_error(&self, err: impl Into) { if let Some(extra) = self.extra { extra.error_invalid_codeblock_attr(err); } @@ -954,7 +954,7 @@ fn parse_class(&mut self, start: usize) -> Option> { } else { let class = &self.data[start + 1..pos]; if class.is_empty() { - self.emit_error(&format!("unexpected `{c}` character after `.`")); + self.emit_error(format!("unexpected `{c}` character after `.`")); return None; } else if self.check_after_token() { return Some(LangStringToken::ClassAttribute(class)); @@ -995,7 +995,7 @@ fn parse_key_value(&mut self, c: char, start: usize) -> Option Option self.parse_string(pos)?, Some((pos, c)) if is_bareword_char(c) => self.parse_token(pos)?, Some((_, c)) => { - self.emit_error(&format!("unexpected `{c}` character after `=`")); + self.emit_error(format!("unexpected `{c}` character after `=`")); return None; } None => { @@ -1033,7 +1033,7 @@ fn check_after_token(&mut self) -> bool { if c == '}' || is_separator(c) || c == '(' { true } else { - self.emit_error(&format!("unexpected `{c}` character")); + self.emit_error(format!("unexpected `{c}` character")); false } } else { @@ -1052,7 +1052,7 @@ fn parse_in_attribute_block(&mut self) -> Option> { } else if c == '"' || is_bareword_char(c) { return self.parse_key_value(c, pos); } else { - self.emit_error(&format!("unexpected character `{c}`")); + self.emit_error(format!("unexpected character `{c}`")); return None; } } @@ -1080,7 +1080,7 @@ fn parse_outside_attribute_block(&mut self, start: usize) -> Option Option(cx: &DocContext<'tcx>, item: &Item) let mut tests = TestsWithCustomClasses { custom_classes_found: vec![] }; - let dox = item.attrs.collapsed_doc_value().unwrap_or_default(); + let dox = item.attrs.doc_value(); find_codes(&dox, &mut tests, ErrorCodes::No, false, None, true); if !tests.custom_classes_found.is_empty() && !cx.tcx.features().custom_code_classes_in_docs { @@ -70,8 +70,7 @@ pub(crate) fn look_for_custom_classes<'tcx>(cx: &DocContext<'tcx>, item: &Item) format!( "found these custom classes: class={}", tests.custom_classes_found.join(",class=") - ) - .as_str(), + ), ) .emit(); }