Skip to content

Commit ed4c5fe

Browse files
committed
fix some clippy::style findings
comparison_to_empty iter_nth_zero for_kv_map manual_next_back redundant_pattern
1 parent 8771282 commit ed4c5fe

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
621621
// is in a different line, so we point at both.
622622
err.span_label(secondary_span, "expected due to the type of this binding");
623623
err.span_label(primary_span, format!("expected due to this{post_message}"));
624-
} else if post_message == "" {
624+
} else if post_message.is_empty() {
625625
// We are pointing at either the assignment lhs or the binding def pattern.
626626
err.span_label(primary_span, "expected due to the type of this binding");
627627
} else {

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ impl<'tcx> MiniGraph<'tcx> {
425425
}
426426
}
427427
} else {
428-
for (constraint, _origin) in &region_constraints.data().constraints {
429-
each_constraint(constraint)
430-
}
428+
region_constraints
429+
.data()
430+
.constraints
431+
.keys()
432+
.for_each(|constraint| each_constraint(constraint));
431433
}
432434
}
433435

compiler/rustc_lexer/src/unescape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ where
372372
callback(start..end, EscapeError::MultipleSkippedLinesWarning);
373373
}
374374
let tail = &tail[first_non_space..];
375-
if let Some(c) = tail.chars().nth(0) {
375+
if let Some(c) = tail.chars().next() {
376376
if c.is_whitespace() {
377377
// For error reporting, we would like the span to contain the character that was not
378378
// skipped. The +1 is necessary to account for the leading \ that started the escape.

compiler/rustc_monomorphize/src/partitioning.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1229,12 +1229,13 @@ fn dump_mono_items_stats<'tcx>(
12291229
// Gather instantiated mono items grouped by def_id
12301230
let mut items_per_def_id: FxHashMap<_, Vec<_>> = Default::default();
12311231
for cgu in codegen_units {
1232-
for (&mono_item, _) in cgu.items() {
1232+
cgu.items()
1233+
.keys()
12331234
// Avoid variable-sized compiler-generated shims
1234-
if mono_item.is_user_defined() {
1235+
.filter(|mono_item| mono_item.is_user_defined())
1236+
.for_each(|mono_item| {
12351237
items_per_def_id.entry(mono_item.def_id()).or_default().push(mono_item);
1236-
}
1237-
}
1238+
});
12381239
}
12391240

12401241
#[derive(serde::Serialize)]
@@ -1287,7 +1288,7 @@ fn codegened_and_inlined_items(tcx: TyCtxt<'_>, (): ()) -> &DefIdSet {
12871288
let mut result = items.clone();
12881289

12891290
for cgu in cgus {
1290-
for (item, _) in cgu.items() {
1291+
for item in cgu.items().keys() {
12911292
if let MonoItem::Fn(ref instance) = item {
12921293
let did = instance.def_id();
12931294
if !visited.insert(did) {

compiler/rustc_parse/src/lexer/unescape_error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn emit_unescape_error(
2727
lit, span_with_quotes, mode, range, error
2828
);
2929
let last_char = || {
30-
let c = lit[range.clone()].chars().rev().next().unwrap();
30+
let c = lit[range.clone()].chars().next_back().unwrap();
3131
let span = span.with_lo(span.hi() - BytePos(c.len_utf8() as u32));
3232
(c, span)
3333
};

compiler/rustc_ty_utils/src/implied_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
5151
// assumed_wf_types should include those of `Opaque<T>`, `Opaque<T>` itself
5252
// and `&'static T`.
5353
DefKind::OpaqueTy => bug!("unimplemented implied bounds for nested opaque types"),
54-
def_kind @ _ => {
54+
def_kind => {
5555
bug!("unimplemented implied bounds for opaque types with parent {def_kind:?}")
5656
}
5757
},

0 commit comments

Comments
 (0)