diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-01-02 11:29:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-02 11:29:07 +0000 |
| commit | 29c1bc97239d364cf63b0d3b59e474ee3d9ba5a9 (patch) | |
| tree | 46b6b98c000f77bee2471cc24947bf302ec414f9 /src/librustdoc/html | |
| parent | 5986dd878f3e432025eb1946149e3241d3998b1b (diff) | |
| parent | a5807ac61c82ca8c6768da0af04d76ceaf760c0a (diff) | |
| download | rust-29c1bc97239d364cf63b0d3b59e474ee3d9ba5a9.tar.gz rust-29c1bc97239d364cf63b0d3b59e474ee3d9ba5a9.zip | |
Rollup merge of #80546 - matthiaskrgr:rustdoclippy, r=LingMan
clippy fixes for librustdoc fixes clippy warnings of type: match_like_matches_macro or_fun_call op_ref needless_return let_and_return single_char_add_str useless_format unnecessary_sort_by match_ref_pats redundant_field_names
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/format.rs | 18 | ||||
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 13 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 16 | ||||
| -rw-r--r-- | src/librustdoc/html/toc.rs | 2 |
4 files changed, 23 insertions, 26 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 9b2fb8582f5..6eeb7ad82c0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -245,7 +245,7 @@ impl<'a> fmt::Display for WhereClause<'a> { } match pred { - &clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => { + clean::WherePredicate::BoundPredicate { ty, bounds } => { let bounds = bounds; if f.alternate() { clause.push_str(&format!( @@ -261,7 +261,7 @@ impl<'a> fmt::Display for WhereClause<'a> { )); } } - &clean::WherePredicate::RegionPredicate { ref lifetime, ref bounds } => { + clean::WherePredicate::RegionPredicate { lifetime, bounds } => { clause.push_str(&format!( "{}: {}", lifetime.print(), @@ -272,7 +272,7 @@ impl<'a> fmt::Display for WhereClause<'a> { .join(" + ") )); } - &clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => { + clean::WherePredicate::EqPredicate { lhs, rhs } => { if f.alternate() { clause.push_str(&format!("{:#} == {:#}", lhs.print(), rhs.print())); } else { @@ -376,8 +376,8 @@ impl clean::GenericBound { impl clean::GenericArgs { fn print(&self) -> impl fmt::Display + '_ { display_fn(move |f| { - match *self { - clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { + match self { + clean::GenericArgs::AngleBracketed { args, bindings } => { if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; @@ -414,7 +414,7 @@ impl clean::GenericArgs { } } } - clean::GenericArgs::Parenthesized { ref inputs, ref output } => { + clean::GenericArgs::Parenthesized { inputs, output } => { f.write_str("(")?; let mut comma = false; for ty in inputs { @@ -501,7 +501,7 @@ crate fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> { }; for component in &fqp[..fqp.len() - 1] { url.push_str(component); - url.push_str("/"); + url.push('/'); } match shortty { ItemType::Module => { @@ -510,7 +510,7 @@ crate fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> { } _ => { url.push_str(shortty.as_str()); - url.push_str("."); + url.push('.'); url.push_str(fqp.last().unwrap()); url.push_str(".html"); } @@ -1021,7 +1021,7 @@ impl Function<'_> { } else { if i > 0 { args.push_str(" <br>"); - args_plain.push_str(" "); + args_plain.push(' '); } if !input.name.is_empty() { args.push_str(&format!("{}: ", input.name)); diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 20cf48915c3..e519c6ee983 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -489,15 +489,10 @@ impl<'a, I: Iterator<Item = Event<'a>>> SummaryLine<'a, I> { } fn check_if_allowed_tag(t: &Tag<'_>) -> bool { - match *t { - Tag::Paragraph - | Tag::Item - | Tag::Emphasis - | Tag::Strong - | Tag::Link(..) - | Tag::BlockQuote => true, - _ => false, - } + matches!( + t, + Tag::Paragraph | Tag::Item | Tag::Emphasis | Tag::Strong | Tag::Link(..) | Tag::BlockQuote + ) } impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> { diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index c19262b72cf..2f5ee4f238d 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -979,7 +979,7 @@ themePicker.onblur = handleThemeButtonsBlur; .iter() .map(|s| format!("\"{}\"", s.to_str().expect("invalid osstring conversion"))) .collect::<Vec<_>>(); - files.sort_unstable_by(|a, b| a.cmp(b)); + files.sort_unstable(); let subs = subs.iter().map(|s| s.to_json_string()).collect::<Vec<_>>().join(","); let dirs = if subs.is_empty() { String::new() } else { format!(",\"dirs\":[{}]", subs) }; @@ -1428,7 +1428,7 @@ impl Setting { .map(|opt| format!( "<option value=\"{}\" {}>{}</option>", opt.0, - if &opt.0 == default_value { "selected" } else { "" }, + if opt.0 == default_value { "selected" } else { "" }, opt.1, )) .collect::<String>(), @@ -1595,7 +1595,7 @@ impl Context<'_> { if let Some(&(ref names, ty)) = cache.paths.get(&it.def_id) { for name in &names[..names.len() - 1] { url.push_str(name); - url.push_str("/"); + url.push('/'); } url.push_str(&item_path(ty, names.last().unwrap())); layout::redirect(&url) @@ -2308,7 +2308,7 @@ fn short_item_info( let since = &since.as_str(); if !stability::deprecation_in_effect(is_since_rustc_version, Some(since)) { if *since == "TBD" { - format!("Deprecating in a future Rust version") + String::from("Deprecating in a future Rust version") } else { format!("Deprecating in {}", Escape(since)) } @@ -4323,9 +4323,11 @@ fn sidebar_assoc_items(it: &clean::Item) -> String { .any(|i| i.inner_impl().trait_.def_id() == c.deref_mut_trait_did); let inner_impl = target .def_id() - .or(target - .primitive_type() - .and_then(|prim| c.primitive_locations.get(&prim).cloned())) + .or_else(|| { + target + .primitive_type() + .and_then(|prim| c.primitive_locations.get(&prim).cloned()) + }) .and_then(|did| c.impls.get(&did)); if let Some(impls) = inner_impl { out.push_str("<a class=\"sidebar-title\" href=\"#deref-methods\">"); diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index b39a4e179cd..c55f2459a9c 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -132,7 +132,7 @@ impl TocBuilder { } Some(entry) => { sec_number = entry.sec_number.clone(); - sec_number.push_str("."); + sec_number.push('.'); (entry.level, &entry.children) } }; |
