about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-02 10:27:44 +0000
committerbors <bors@rust-lang.org>2021-09-02 10:27:44 +0000
commit64929313f53181636e4dd37e25836973205477e4 (patch)
treee519116350f0fa70340277087f46949eda1afa10
parentb27ccbc7e1e6a04d749e244a3c13f72ca38e80e7 (diff)
parent7f2df9ad65f49b916a979d819595cd1b6385bc71 (diff)
downloadrust-64929313f53181636e4dd37e25836973205477e4.tar.gz
rust-64929313f53181636e4dd37e25836973205477e4.zip
Auto merge of #88516 - matthiaskrgr:clippy_perf_end_august, r=jyn514,GuillaumeGomez
some low hanging clippy::perf fixes
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs2
-rw-r--r--compiler/rustc_resolve/src/late/lifetimes.rs6
-rw-r--r--compiler/rustc_target/src/spec/mod.rs2
-rw-r--r--compiler/rustc_typeck/src/check/expr.rs2
-rw-r--r--compiler/rustc_typeck/src/check/pat.rs2
-rw-r--r--src/librustdoc/html/sources.rs7
6 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index 45657f2d0f2..d7cd34c5922 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -2090,7 +2090,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                                 self.is_unnamed(),
                                 self.is_underscore(),
                                 self.is_named(),
-                                sugg.starts_with("&"),
+                                sugg.starts_with('&'),
                             ) {
                                 (true, _, _, false) => (self.span_unnamed_borrow(), sugg),
                                 (true, _, _, true) => {
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs
index e901d4c00ab..4c1d537d55f 100644
--- a/compiler/rustc_resolve/src/late/lifetimes.rs
+++ b/compiler/rustc_resolve/src/late/lifetimes.rs
@@ -2605,8 +2605,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
                     binding.ident,
                 );
                 self.with(scope, |_, this| {
-                    let scope =
-                        Scope::Supertrait { lifetimes: lifetimes.unwrap_or(vec![]), s: this.scope };
+                    let scope = Scope::Supertrait {
+                        lifetimes: lifetimes.unwrap_or_default(),
+                        s: this.scope,
+                    };
                     this.with(scope, |_, this| this.visit_assoc_type_binding(binding));
                 });
             } else {
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 4d0cad80764..273221360b8 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -664,7 +664,7 @@ impl ToJson for SanitizerSet {
         self.into_iter()
             .map(|v| Some(v.as_str()?.to_json()))
             .collect::<Option<Vec<_>>>()
-            .unwrap_or(Vec::new())
+            .unwrap_or_default()
             .to_json()
     }
 }
diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs
index 10f5b000aca..64594a82ec0 100644
--- a/compiler/rustc_typeck/src/check/expr.rs
+++ b/compiler/rustc_typeck/src/check/expr.rs
@@ -165,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         if self.tcx().sess.verbose() {
             // make this code only run with -Zverbose because it is probably slow
             if let Ok(lint_str) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
-                if !lint_str.contains("\n") {
+                if !lint_str.contains('\n') {
                     debug!("expr text: {}", lint_str);
                 } else {
                     let mut lines = lint_str.lines();
diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs
index 016b3f7a87c..140a9d1126d 100644
--- a/compiler/rustc_typeck/src/check/pat.rs
+++ b/compiler/rustc_typeck/src/check/pat.rs
@@ -1008,7 +1008,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         let mut err = struct_span_err!(
             self.tcx.sess,
-            MultiSpan::from_spans(subpat_spans.clone()),
+            MultiSpan::from_spans(subpat_spans),
             E0023,
             "this pattern has {} field{}, but the corresponding {} has {} field{}",
             subpats.len(),
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index 73916e204d9..bb90b195ddd 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -72,10 +72,9 @@ impl LocalSourcesCollector<'_, '_> {
             href.push('/');
         });
 
-        let src_fname = p.file_name().expect("source has no filename").to_os_string();
-        let mut fname = src_fname.clone();
-        fname.push(".html");
-        href.push_str(&fname.to_string_lossy());
+        let mut src_fname = p.file_name().expect("source has no filename").to_os_string();
+        src_fname.push(".html");
+        href.push_str(&src_fname.to_string_lossy());
         self.local_sources.insert(p, href);
     }
 }