mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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:
parent
27d8a57713
commit
d707461a1a
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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!(
|
||||
|
@ -315,11 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
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 {
|
||||
|
@ -649,7 +649,7 @@ impl OpportunitySet {
|
||||
|
||||
// `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;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ const DEP_NODE_PAD: usize = DEP_NODE_SIZE - 1;
|
||||
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(
|
||||
|
@ -157,7 +157,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
|
||||
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
|
||||
})
|
||||
.into_iter()
|
||||
.filter_map(|c| c)
|
||||
.flatten()
|
||||
.collect();
|
||||
crates
|
||||
}
|
||||
|
@ -1069,7 +1069,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if !self.tcx.is_diagnostic_item(sym::Result, def.did()) {
|
||||
return None;
|
||||
}
|
||||
Some(arg.as_type()?)
|
||||
arg.as_type()
|
||||
};
|
||||
|
||||
let mut suggested = false;
|
||||
|
@ -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(())
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user