clippy::complexity fixes

filter_map_identity
 needless_bool
 search_is_some
 unit_arg
 map_identity
 needless_question_mark
 derivable_impls
This commit is contained in:
Matthias Krüger 2023-12-12 19:28:13 +01:00
parent 27d8a57713
commit d707461a1a
9 changed files with 14 additions and 33 deletions

View file

@ -21,7 +21,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
/// `read_discriminant` can be hooked for better error messages.
#[inline(always)]
fn read_discriminant(&mut self, v: &Self::V) -> InterpResult<'tcx, VariantIdx> {
Ok(self.ecx().read_discriminant(&v.to_op(self.ecx())?)?)
self.ecx().read_discriminant(&v.to_op(self.ecx())?)
}
/// This function provides the chance to reorder the order in which fields are visited for

View file

@ -587,10 +587,8 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
let mut print_formatted = if pager_name == "less" {
cmd.arg("-r");
true
} else if ["bat", "catbat", "delta"].iter().any(|v| *v == pager_name) {
true
} else {
false
["bat", "catbat", "delta"].iter().any(|v| *v == pager_name)
};
if color == ColorConfig::Never {

View file

@ -34,17 +34,14 @@ fn associated_type_bounds<'tcx>(
let trait_def_id = tcx.local_parent(assoc_item_def_id);
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
let bounds_from_parent = trait_predicates
.predicates
.iter()
.copied()
.filter(|(pred, _)| match pred.kind().skip_binder() {
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
match pred.kind().skip_binder() {
ty::ClauseKind::Trait(tr) => tr.self_ty() == item_ty,
ty::ClauseKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
ty::ClauseKind::TypeOutlives(outlives) => outlives.0 == item_ty,
_ => false,
})
.map(|(clause, span)| (clause, span));
}
});
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
debug!(

View file

@ -315,11 +315,8 @@ fn analyze_closure(
let final_tupled_upvars_type = Ty::new_tup(self.tcx, &final_upvar_tys);
self.demand_suptype(span, args.tupled_upvars_ty(), final_tupled_upvars_type);
let fake_reads = delegate
.fake_reads
.into_iter()
.map(|(place, cause, hir_id)| (place, cause, hir_id))
.collect();
let fake_reads = delegate.fake_reads;
self.typeck_results.borrow_mut().closure_fake_reads.insert(closure_def_id, fake_reads);
if self.tcx.sess.opts.unstable_opts.profile_closures {

View file

@ -649,7 +649,7 @@ fn apply_once(&mut self, index: usize, body: &mut Body<'_>) {
// `succ` must be a successor of `current`. If it is not, this means this TO is not
// satisfiable and a previous TO erased this edge, so we bail out.
if basic_blocks[current].terminator().successors().find(|s| *s == succ).is_none() {
if !basic_blocks[current].terminator().successors().any(|s| s == succ) {
debug!("impossible");
return;
}

View file

@ -70,7 +70,7 @@ pub struct SerializedDepNodeIndex {}
const DEP_NODE_WIDTH_BITS: usize = DEP_NODE_SIZE / 2;
/// Data for use when recompiling the **current crate**.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct SerializedDepGraph {
/// The set of all DepNodes in the graph
nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
@ -89,18 +89,6 @@ pub struct SerializedDepGraph {
index: Vec<UnhashMap<PackedFingerprint, SerializedDepNodeIndex>>,
}
impl Default for SerializedDepGraph {
fn default() -> Self {
SerializedDepGraph {
nodes: Default::default(),
fingerprints: Default::default(),
edge_list_indices: Default::default(),
edge_list_data: Default::default(),
index: Default::default(),
}
}
}
impl SerializedDepGraph {
#[inline]
pub fn edge_targets_from(

View file

@ -157,7 +157,7 @@ fn find_crates(&self, name: &str) -> Vec<stable_mir::Crate> {
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
})
.into_iter()
.filter_map(|c| c)
.flatten()
.collect();
crates
}

View file

@ -1069,7 +1069,7 @@ fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
if !self.tcx.is_diagnostic_item(sym::Result, def.did()) {
return None;
}
Some(arg.as_type()?)
arg.as_type()
};
let mut suggested = false;

View file

@ -79,6 +79,7 @@ pub(crate) fn document_type_layout<'a, 'cx: 'a>(
TypeLayoutSize { is_unsized, is_uninhabited, size }
});
Ok(TypeLayout { variants, type_layout_size }.render_into(f).unwrap())
TypeLayout { variants, type_layout_size }.render_into(f).unwrap();
Ok(())
})
}