chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -235,7 +235,7 @@ async fn index_rustdoc(
|
|||
while let Some(item_with_history) = items_to_visit.pop_front() {
|
||||
let item = &item_with_history.item;
|
||||
|
||||
let Some(result) = fetch_page(&package, Some(&item)).await.with_context(|| {
|
||||
let Some(result) = fetch_page(&package, Some(item)).await.with_context(|| {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
format!(
|
||||
|
@ -268,11 +268,8 @@ async fn index_rustdoc(
|
|||
seen_items.insert(item.clone());
|
||||
|
||||
item.path.extend(parent_item.path.clone());
|
||||
match parent_item.kind {
|
||||
RustdocItemKind::Mod => {
|
||||
item.path.push(parent_item.name.clone());
|
||||
}
|
||||
_ => {}
|
||||
if parent_item.kind == RustdocItemKind::Mod {
|
||||
item.path.push(parent_item.name.clone());
|
||||
}
|
||||
|
||||
items_to_visit.push_back(RustdocItemWithHistory {
|
||||
|
|
|
@ -76,10 +76,7 @@ pub struct RustdocCodeHandler;
|
|||
|
||||
impl HandleTag for RustdocCodeHandler {
|
||||
fn should_handle(&self, tag: &str) -> bool {
|
||||
match tag {
|
||||
"pre" | "code" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(tag, "pre" | "code")
|
||||
}
|
||||
|
||||
fn handle_tag_start(
|
||||
|
@ -97,7 +94,7 @@ impl HandleTag for RustdocCodeHandler {
|
|||
let classes = tag.classes();
|
||||
let is_rust = classes.iter().any(|class| class == "rust");
|
||||
let language = is_rust
|
||||
.then(|| "rs")
|
||||
.then_some("rs")
|
||||
.or_else(|| {
|
||||
classes.iter().find_map(|class| {
|
||||
if let Some((_, language)) = class.split_once("language-") {
|
||||
|
@ -131,7 +128,7 @@ impl HandleTag for RustdocCodeHandler {
|
|||
|
||||
fn handle_text(&mut self, text: &str, writer: &mut MarkdownWriter) -> HandlerOutcome {
|
||||
if writer.is_inside("pre") {
|
||||
writer.push_str(&text);
|
||||
writer.push_str(text);
|
||||
return HandlerOutcome::Handled;
|
||||
}
|
||||
|
||||
|
@ -156,10 +153,7 @@ impl RustdocItemHandler {
|
|||
|
||||
impl HandleTag for RustdocItemHandler {
|
||||
fn should_handle(&self, tag: &str) -> bool {
|
||||
match tag {
|
||||
"div" | "span" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(tag, "div" | "span")
|
||||
}
|
||||
|
||||
fn handle_tag_start(
|
||||
|
@ -211,10 +205,10 @@ pub struct RustdocChromeRemover;
|
|||
|
||||
impl HandleTag for RustdocChromeRemover {
|
||||
fn should_handle(&self, tag: &str) -> bool {
|
||||
match tag {
|
||||
"head" | "script" | "nav" | "summary" | "button" | "a" | "div" | "span" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
tag,
|
||||
"head" | "script" | "nav" | "summary" | "button" | "a" | "div" | "span"
|
||||
)
|
||||
}
|
||||
|
||||
fn handle_tag_start(
|
||||
|
@ -310,23 +304,20 @@ impl HandleTag for RustdocItemCollector {
|
|||
tag: &HtmlElement,
|
||||
writer: &mut MarkdownWriter,
|
||||
) -> StartTagOutcome {
|
||||
match tag.tag() {
|
||||
"a" => {
|
||||
let is_reexport = writer.current_element_stack().iter().any(|element| {
|
||||
if let Some(id) = element.attr("id") {
|
||||
id.starts_with("reexport.") || id.starts_with("method.")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
if tag.tag() == "a" {
|
||||
let is_reexport = writer.current_element_stack().iter().any(|element| {
|
||||
if let Some(id) = element.attr("id") {
|
||||
id.starts_with("reexport.") || id.starts_with("method.")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
if !is_reexport {
|
||||
if let Some(item) = Self::parse_item(tag) {
|
||||
self.items.insert(item);
|
||||
}
|
||||
if !is_reexport {
|
||||
if let Some(item) = Self::parse_item(tag) {
|
||||
self.items.insert(item);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
StartTagOutcome::Continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue