Skip to content

Commit 6492931

Browse files
committed
Auto merge of #88516 - matthiaskrgr:clippy_perf_end_august, r=jyn514,GuillaumeGomez
some low hanging clippy::perf fixes
2 parents b27ccbc + 7f2df9a commit 6492931

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
20902090
self.is_unnamed(),
20912091
self.is_underscore(),
20922092
self.is_named(),
2093-
sugg.starts_with("&"),
2093+
sugg.starts_with('&'),
20942094
) {
20952095
(true, _, _, false) => (self.span_unnamed_borrow(), sugg),
20962096
(true, _, _, true) => {

compiler/rustc_resolve/src/late/lifetimes.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2605,8 +2605,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
26052605
binding.ident,
26062606
);
26072607
self.with(scope, |_, this| {
2608-
let scope =
2609-
Scope::Supertrait { lifetimes: lifetimes.unwrap_or(vec![]), s: this.scope };
2608+
let scope = Scope::Supertrait {
2609+
lifetimes: lifetimes.unwrap_or_default(),
2610+
s: this.scope,
2611+
};
26102612
this.with(scope, |_, this| this.visit_assoc_type_binding(binding));
26112613
});
26122614
} else {

compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl ToJson for SanitizerSet {
664664
self.into_iter()
665665
.map(|v| Some(v.as_str()?.to_json()))
666666
.collect::<Option<Vec<_>>>()
667-
.unwrap_or(Vec::new())
667+
.unwrap_or_default()
668668
.to_json()
669669
}
670670
}

compiler/rustc_typeck/src/check/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
165165
if self.tcx().sess.verbose() {
166166
// make this code only run with -Zverbose because it is probably slow
167167
if let Ok(lint_str) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
168-
if !lint_str.contains("\n") {
168+
if !lint_str.contains('\n') {
169169
debug!("expr text: {}", lint_str);
170170
} else {
171171
let mut lines = lint_str.lines();

compiler/rustc_typeck/src/check/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10081008

10091009
let mut err = struct_span_err!(
10101010
self.tcx.sess,
1011-
MultiSpan::from_spans(subpat_spans.clone()),
1011+
MultiSpan::from_spans(subpat_spans),
10121012
E0023,
10131013
"this pattern has {} field{}, but the corresponding {} has {} field{}",
10141014
subpats.len(),

src/librustdoc/html/sources.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ impl LocalSourcesCollector<'_, '_> {
7272
href.push('/');
7373
});
7474

75-
let src_fname = p.file_name().expect("source has no filename").to_os_string();
76-
let mut fname = src_fname.clone();
77-
fname.push(".html");
78-
href.push_str(&fname.to_string_lossy());
75+
let mut src_fname = p.file_name().expect("source has no filename").to_os_string();
76+
src_fname.push(".html");
77+
href.push_str(&src_fname.to_string_lossy());
7978
self.local_sources.insert(p, href);
8079
}
8180
}

0 commit comments

Comments
 (0)