about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-11 09:10:30 +0000
committerbors <bors@rust-lang.org>2020-11-11 09:10:30 +0000
commitd4ea0b3e46a0303d5802b632e88ba1ba84d9d16f (patch)
tree052eab1b6fa0810f260cef027039442e5a27fd0d /src
parent38030ffb4e735b26260848b744c0910a5641e1db (diff)
parent261ca04c925e1844bbd3525168d129055637e60e (diff)
downloadrust-d4ea0b3e46a0303d5802b632e88ba1ba84d9d16f.tar.gz
rust-d4ea0b3e46a0303d5802b632e88ba1ba84d9d16f.zip
Auto merge of #78825 - Nicholas-Baron:unwrap_or_corrected, r=lcnr
`unwrap_or` lint corrected

https://github.com/rust-lang/rust/issues/78814#issuecomment-723305713

This pull request fixes the lint from clippy where `unwrap_or` could be better done as a `unwrap_or_else` or a `unwrap_or_default`.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs3
-rw-r--r--src/librustdoc/html/render/cache.rs2
2 files changed, 2 insertions, 3 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index ec7932d8bbf..366548d5b5f 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -935,8 +935,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], &'a [Ident]) {
                 .iter()
                 .enumerate()
                 .map(|(i, ty)| {
-                    let mut name =
-                        self.1.get(i).map(|ident| ident.to_string()).unwrap_or(String::new());
+                    let mut name = self.1.get(i).map(|ident| ident.to_string()).unwrap_or_default();
                     if name.is_empty() {
                         name = "_".to_string();
                     }
diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs
index cf785d362cd..add28de17ed 100644
--- a/src/librustdoc/html/render/cache.rs
+++ b/src/librustdoc/html/render/cache.rs
@@ -128,7 +128,7 @@ pub fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
         .module
         .as_ref()
         .map(|module| shorten(plain_text_summary(module.doc_value())))
-        .unwrap_or(String::new());
+        .unwrap_or_default();
 
     #[derive(Serialize)]
     struct CrateData<'a> {