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
This commit is contained in:
Matthias Krüger 2020-09-15 22:36:43 +02:00
parent a874956d94
commit 73d4171ea6
9 changed files with 10 additions and 12 deletions

View File

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

View File

@ -273,10 +273,10 @@ pub trait PrettyPrinter<'tcx>:
}
match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
None => return Ok((self, false)),
None => Ok((self, false)),
Some(symbol) => {
self.write_str(&symbol.as_str())?;
return Ok((self, true));
Ok((self, true))
}
}
}

View File

@ -387,7 +387,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let ReturnConstraint::ClosureUpvar(upvar) = kind {
let def_id = match self.regioncx.universal_regions().defining_ty {
DefiningTy::Closure(def_id, _) => def_id,
ty @ _ => bug!("unexpected DefiningTy {:?}", ty),
ty => bug!("unexpected DefiningTy {:?}", ty),
};
let upvar_def_span = self.infcx.tcx.hir().span(upvar);

View File

@ -126,7 +126,7 @@ impl OptimizationFinder<'b, 'tcx> {
}
}
return None;
None
}
}

View File

@ -1534,7 +1534,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}
};
let lifetime_names: Vec<_> = lifetime_names.into_iter().collect();
let lifetime_names: Vec<_> = lifetime_names.iter().collect();
match (&lifetime_names[..], snippet.as_deref()) {
([name], Some("&")) => {
suggest_existing(err, &name.as_str()[..], &|name| format!("&{} ", name));

View File

@ -182,7 +182,7 @@ fn overlap_within_probe(
}
if !skip_leak_check.is_yes() {
if let Err(_) = infcx.leak_check(true, snapshot) {
if infcx.leak_check(true, snapshot).is_err() {
debug!("overlap: leak check failed");
return None;
}

View File

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

View File

@ -1243,10 +1243,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
let no_accessible_remaining_fields = remaining_fields
.iter()
.filter(|(_, (_, field))| {
.find(|(_, (_, field))| {
field.vis.is_accessible_from(tcx.parent_module(expr_id).to_def_id(), tcx)
})
.next()
.is_none();
if no_accessible_remaining_fields {

View File

@ -1141,10 +1141,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if !etc && !unmentioned_fields.is_empty() {
let no_accessible_unmentioned_fields = unmentioned_fields
.iter()
.filter(|(field, _)| {
.find(|(field, _)| {
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
})
.next()
.is_none();
if no_accessible_unmentioned_fields {