Skip to content

Commit a6c4d30

Browse files
authored
Rollup merge of #76756 - matthiaskrgr:cl123ppy, r=Dylan-DPC
fix a couple of stylistic clippy warnings namely: clippy::redundant_pattern_matching clippy::redundant_pattern clippy::search_is_some clippy::filter_next clippy::into_iter_on_ref clippy::clone_on_copy clippy::needless_return
2 parents ab78ca9 + 73d4171 commit a6c4d30

File tree

9 files changed

+10
-12
lines changed

9 files changed

+10
-12
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8585

8686
debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
8787
if sub == &ty::ReStatic
88-
&& v.0.into_iter().find(|t| t.span.desugaring_kind().is_none()).is_some()
88+
&& v.0.into_iter().any(|t| t.span.desugaring_kind().is_none())
8989
{
9090
// If the failure is due to a `'static` requirement coming from a `dyn` or
9191
// `impl` Trait that *isn't* caused by `async fn` desugaring, handle this case

compiler/rustc_middle/src/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ pub trait PrettyPrinter<'tcx>:
273273
}
274274

275275
match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
276-
None => return Ok((self, false)),
276+
None => Ok((self, false)),
277277
Some(symbol) => {
278278
self.write_str(&symbol.as_str())?;
279-
return Ok((self, true));
279+
Ok((self, true))
280280
}
281281
}
282282
}

compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
387387
if let ReturnConstraint::ClosureUpvar(upvar) = kind {
388388
let def_id = match self.regioncx.universal_regions().defining_ty {
389389
DefiningTy::Closure(def_id, _) => def_id,
390-
ty @ _ => bug!("unexpected DefiningTy {:?}", ty),
390+
ty => bug!("unexpected DefiningTy {:?}", ty),
391391
};
392392

393393
let upvar_def_span = self.infcx.tcx.hir().span(upvar);

compiler/rustc_mir/src/transform/instcombine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl OptimizationFinder<'b, 'tcx> {
126126
}
127127
}
128128

129-
return None;
129+
None
130130
}
131131
}
132132

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
15341534
}
15351535
};
15361536

1537-
let lifetime_names: Vec<_> = lifetime_names.into_iter().collect();
1537+
let lifetime_names: Vec<_> = lifetime_names.iter().collect();
15381538
match (&lifetime_names[..], snippet.as_deref()) {
15391539
([name], Some("&")) => {
15401540
suggest_existing(err, &name.as_str()[..], &|name| format!("&{} ", name));

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn overlap_within_probe(
182182
}
183183

184184
if !skip_leak_check.is_yes() {
185-
if let Err(_) = infcx.leak_check(true, snapshot) {
185+
if infcx.leak_check(true, snapshot).is_err() {
186186
debug!("overlap: leak check failed");
187187
return None;
188188
}

compiler/rustc_typeck/src/check/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
164164
}
165165
// If all the obligations hold (or there are no obligations) the tail expression
166166
// we can suggest to return a boxed trait object instead of an opaque type.
167-
if suggest_box { self.ret_type_span.clone() } else { None }
167+
if suggest_box { self.ret_type_span } else { None }
168168
}
169169
_ => None,
170170
};

compiler/rustc_typeck/src/check/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1243,10 +1243,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12431243
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
12441244
let no_accessible_remaining_fields = remaining_fields
12451245
.iter()
1246-
.filter(|(_, (_, field))| {
1246+
.find(|(_, (_, field))| {
12471247
field.vis.is_accessible_from(tcx.parent_module(expr_id).to_def_id(), tcx)
12481248
})
1249-
.next()
12501249
.is_none();
12511250

12521251
if no_accessible_remaining_fields {

compiler/rustc_typeck/src/check/pat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11411141
} else if !etc && !unmentioned_fields.is_empty() {
11421142
let no_accessible_unmentioned_fields = unmentioned_fields
11431143
.iter()
1144-
.filter(|(field, _)| {
1144+
.find(|(field, _)| {
11451145
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
11461146
})
1147-
.next()
11481147
.is_none();
11491148

11501149
if no_accessible_unmentioned_fields {

0 commit comments

Comments
 (0)