Skip to content

some low hanging clippy::perf fixes #88516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_resolve/src/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
7 changes: 3 additions & 4 deletions src/librustdoc/html/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down