Skip to content

Commit

Permalink
fix a couple of stylistic clippy warnings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthiaskrgr committed Sep 15, 2020
1 parent a874956 commit 73d4171
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 12 deletions.
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Expand Up @@ -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))
}
}
}
Expand Down
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/instcombine.rs
Expand Up @@ -126,7 +126,7 @@ impl OptimizationFinder<'b, 'tcx> {
}
}

return None;
None
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/coherence.rs
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/_match.rs
Expand Up @@ -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,
};
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/expr.rs
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/pat.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 73d4171

Please sign in to comment.