diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 45657f2d0f22a..d7cd34c5922c7 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 e901d4c00ab79..4c1d537d55fa3 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 911956859b861..c65804e572157 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::>>() - .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 51c646e500ca3..e0838c29a6555 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 016b3f7a87cf3..140a9d1126d32 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 73916e204d942..bb90b195ddd4f 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); } }