Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5308733

Browse files
authoredDec 13, 2023
Rollup merge of #118885 - matthiaskrgr:compl_2023, r=compiler-errors
clippy::complexity fixes filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2 parents 89d4a9b + d707461 commit 5308733

File tree

9 files changed

+14
-33
lines changed

9 files changed

+14
-33
lines changed
 

‎compiler/rustc_const_eval/src/interpret/visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
2121
/// `read_discriminant` can be hooked for better error messages.
2222
#[inline(always)]
2323
fn read_discriminant(&mut self, v: &Self::V) -> InterpResult<'tcx, VariantIdx> {
24-
Ok(self.ecx().read_discriminant(&v.to_op(self.ecx())?)?)
24+
self.ecx().read_discriminant(&v.to_op(self.ecx())?)
2525
}
2626

2727
/// This function provides the chance to reorder the order in which fields are visited for

‎compiler/rustc_driver_impl/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,8 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
587587
let mut print_formatted = if pager_name == "less" {
588588
cmd.arg("-r");
589589
true
590-
} else if ["bat", "catbat", "delta"].iter().any(|v| *v == pager_name) {
591-
true
592590
} else {
593-
false
591+
["bat", "catbat", "delta"].iter().any(|v| *v == pager_name)
594592
};
595593

596594
if color == ColorConfig::Never {

‎compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ fn associated_type_bounds<'tcx>(
3434
let trait_def_id = tcx.local_parent(assoc_item_def_id);
3535
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
3636

37-
let bounds_from_parent = trait_predicates
38-
.predicates
39-
.iter()
40-
.copied()
41-
.filter(|(pred, _)| match pred.kind().skip_binder() {
37+
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
38+
match pred.kind().skip_binder() {
4239
ty::ClauseKind::Trait(tr) => tr.self_ty() == item_ty,
4340
ty::ClauseKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
4441
ty::ClauseKind::TypeOutlives(outlives) => outlives.0 == item_ty,
4542
_ => false,
46-
})
47-
.map(|(clause, span)| (clause, span));
43+
}
44+
});
4845

4946
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
5047
debug!(

‎compiler/rustc_hir_typeck/src/upvar.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
let final_tupled_upvars_type = Ty::new_tup(self.tcx, &final_upvar_tys);
316316
self.demand_suptype(span, args.tupled_upvars_ty(), final_tupled_upvars_type);
317317

318-
let fake_reads = delegate
319-
.fake_reads
320-
.into_iter()
321-
.map(|(place, cause, hir_id)| (place, cause, hir_id))
322-
.collect();
318+
let fake_reads = delegate.fake_reads;
319+
323320
self.typeck_results.borrow_mut().closure_fake_reads.insert(closure_def_id, fake_reads);
324321

325322
if self.tcx.sess.opts.unstable_opts.profile_closures {

‎compiler/rustc_mir_transform/src/jump_threading.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ impl OpportunitySet {
649649

650650
// `succ` must be a successor of `current`. If it is not, this means this TO is not
651651
// satisfiable and a previous TO erased this edge, so we bail out.
652-
if basic_blocks[current].terminator().successors().find(|s| *s == succ).is_none() {
652+
if !basic_blocks[current].terminator().successors().any(|s| s == succ) {
653653
debug!("impossible");
654654
return;
655655
}

‎compiler/rustc_query_system/src/dep_graph/serialized.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const DEP_NODE_PAD: usize = DEP_NODE_SIZE - 1;
7070
const DEP_NODE_WIDTH_BITS: usize = DEP_NODE_SIZE / 2;
7171

7272
/// Data for use when recompiling the **current crate**.
73-
#[derive(Debug)]
73+
#[derive(Debug, Default)]
7474
pub struct SerializedDepGraph {
7575
/// The set of all DepNodes in the graph
7676
nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
@@ -89,18 +89,6 @@ pub struct SerializedDepGraph {
8989
index: Vec<UnhashMap<PackedFingerprint, SerializedDepNodeIndex>>,
9090
}
9191

92-
impl Default for SerializedDepGraph {
93-
fn default() -> Self {
94-
SerializedDepGraph {
95-
nodes: Default::default(),
96-
fingerprints: Default::default(),
97-
edge_list_indices: Default::default(),
98-
edge_list_data: Default::default(),
99-
index: Default::default(),
100-
}
101-
}
102-
}
103-
10492
impl SerializedDepGraph {
10593
#[inline]
10694
pub fn edge_targets_from(

‎compiler/rustc_smir/src/rustc_smir/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
157157
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
158158
})
159159
.into_iter()
160-
.filter_map(|c| c)
160+
.flatten()
161161
.collect();
162162
crates
163163
}

‎compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10691069
if !self.tcx.is_diagnostic_item(sym::Result, def.did()) {
10701070
return None;
10711071
}
1072-
Some(arg.as_type()?)
1072+
arg.as_type()
10731073
};
10741074

10751075
let mut suggested = false;

‎src/librustdoc/html/render/type_layout.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub(crate) fn document_type_layout<'a, 'cx: 'a>(
7979
TypeLayoutSize { is_unsized, is_uninhabited, size }
8080
});
8181

82-
Ok(TypeLayout { variants, type_layout_size }.render_into(f).unwrap())
82+
TypeLayout { variants, type_layout_size }.render_into(f).unwrap();
83+
Ok(())
8384
})
8485
}

0 commit comments

Comments
 (0)
Failed to load comments.