Skip to content

Commit d7e9f76

Browse files
authored
Unrolled build for #146776
Rollup merge of #146776 - hkBst:clippy-fix-12, r=jdonszelmann fixes for numerous clippy warnings
2 parents 0be8e16 + e500dd8 commit d7e9f76

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21942194
fn suggest_associated_call_syntax(
21952195
&self,
21962196
err: &mut Diag<'_>,
2197-
static_candidates: &Vec<CandidateSource>,
2197+
static_candidates: &[CandidateSource],
21982198
rcvr_ty: Ty<'tcx>,
21992199
source: SelfSource<'tcx>,
22002200
item_name: Ident,
@@ -2422,7 +2422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24222422

24232423
let span_included = match parent_expr.kind {
24242424
hir::ExprKind::Struct(_, eps, _) => {
2425-
eps.len() > 0 && eps.last().is_some_and(|ep| ep.span.contains(span))
2425+
eps.last().is_some_and(|ep| ep.span.contains(span))
24262426
}
24272427
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
24282428
hir::ExprKind::Call(func, ..) => func.span.contains(span),
@@ -2484,7 +2484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24842484
simplify_type(tcx, ty, TreatParams::InstantiateWithInfer)
24852485
.and_then(|simp| {
24862486
tcx.incoherent_impls(simp)
2487-
.into_iter()
2487+
.iter()
24882488
.find_map(|&id| self.associated_value(id, item_name))
24892489
})
24902490
.is_some()
@@ -2617,7 +2617,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26172617

26182618
if let Node::Expr(call_expr) = self.tcx.parent_hir_node(seg1.hir_id)
26192619
&& let ControlFlow::Break(Some(expr)) =
2620-
(LetVisitor { ident_name: seg1.ident.name }).visit_body(&body)
2620+
(LetVisitor { ident_name: seg1.ident.name }).visit_body(body)
26212621
&& let Some(self_ty) = self.node_ty_opt(expr.hir_id)
26222622
{
26232623
let probe = self.lookup_probe_for_diagnostic(
@@ -2960,14 +2960,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29602960
.collect::<Vec<_>>()
29612961
.into();
29622962
for pred in &local_preds {
2963-
match pred.self_ty().kind() {
2964-
ty::Adt(def, _) => {
2965-
local_spans.push_span_label(
2966-
self.tcx.def_span(def.did()),
2967-
format!("must implement `{}`", pred.trait_ref.print_trait_sugared()),
2968-
);
2969-
}
2970-
_ => {}
2963+
if let ty::Adt(def, _) = pred.self_ty().kind() {
2964+
local_spans.push_span_label(
2965+
self.tcx.def_span(def.did()),
2966+
format!("must implement `{}`", pred.trait_ref.print_trait_sugared()),
2967+
);
29712968
}
29722969
}
29732970
if local_spans.primary_span().is_some() {
@@ -3006,14 +3003,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30063003
.collect::<Vec<_>>()
30073004
.into();
30083005
for pred in &foreign_preds {
3009-
match pred.self_ty().kind() {
3010-
ty::Adt(def, _) => {
3011-
foreign_spans.push_span_label(
3012-
self.tcx.def_span(def.did()),
3013-
format!("not implement `{}`", pred.trait_ref.print_trait_sugared()),
3014-
);
3015-
}
3016-
_ => {}
3006+
if let ty::Adt(def, _) = pred.self_ty().kind() {
3007+
foreign_spans.push_span_label(
3008+
self.tcx.def_span(def.did()),
3009+
format!("not implement `{}`", pred.trait_ref.print_trait_sugared()),
3010+
);
30173011
}
30183012
}
30193013
if foreign_spans.primary_span().is_some() {
@@ -3595,7 +3589,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35953589
// would take care of them.
35963590
&& !skippable.contains(&Some(pick.item.container_id(self.tcx)))
35973591
// Do not suggest pinning when the method is directly on `Pin`.
3598-
&& pick.item.impl_container(self.tcx).map_or(true, |did| {
3592+
&& pick.item.impl_container(self.tcx).is_none_or(|did| {
35993593
match self.tcx.type_of(did).skip_binder().kind() {
36003594
ty::Adt(def, _) => Some(def.did()) != self.tcx.lang_items().pin_type(),
36013595
_ => true,
@@ -3653,7 +3647,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
36533647
vec![
36543648
(
36553649
rcvr.span.shrink_to_lo(),
3656-
format!("let mut pinned = std::pin::pin!("),
3650+
"let mut pinned = std::pin::pin!(".to_string(),
36573651
),
36583652
(
36593653
rcvr.span.shrink_to_hi(),
@@ -4128,7 +4122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41284122
);
41294123
let trait_span = self.tcx.def_span(trait_def_id);
41304124
let mut multi_span: MultiSpan = trait_span.into();
4131-
multi_span.push_span_label(trait_span, format!("this is the trait that is needed"));
4125+
multi_span.push_span_label(trait_span, "this is the trait that is needed".to_string());
41324126
let descr = self.tcx.associated_item(item_def_id).descr();
41334127
let rcvr_ty =
41344128
rcvr_ty.map(|t| format!("`{t}`")).unwrap_or_else(|| "the receiver".to_string());
@@ -4146,7 +4140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41464140
}
41474141
multi_span.push_span_label(
41484142
self.tcx.def_span(def_id),
4149-
format!("this is the trait that was imported"),
4143+
"this is the trait that was imported".to_string(),
41504144
);
41514145
}
41524146
err.span_note(multi_span, msg);

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
566566
rhs_ty,
567567
lhs_expr,
568568
lhs_ty,
569-
|lhs_ty, rhs_ty| is_compatible_after_call(lhs_ty, rhs_ty),
569+
is_compatible_after_call,
570570
) {
571571
// Cool
572572
}
@@ -1170,8 +1170,8 @@ fn deref_ty_if_possible(ty: Ty<'_>) -> Ty<'_> {
11701170
}
11711171
}
11721172

1173-
/// Returns `true` if this is a built-in arithmetic operation (e.g., u32
1174-
/// + u32, i16x4 == i16x4) and false if these types would have to be
1173+
/// Returns `true` if this is a built-in arithmetic operation (e.g.,
1174+
/// u32 + u32, i16x4 == i16x4) and false if these types would have to be
11751175
/// overloaded to be legal. There are two reasons that we distinguish
11761176
/// builtin operations from overloaded ones (vs trying to drive
11771177
/// everything uniformly through the trait system and intrinsics or
@@ -1191,7 +1191,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, category: BinOpCategory)
11911191
// (See https://github.com/rust-lang/rust/issues/57447.)
11921192
let (lhs, rhs) = (deref_ty_if_possible(lhs), deref_ty_if_possible(rhs));
11931193

1194-
match category.into() {
1194+
match category {
11951195
BinOpCategory::Shortcircuit => true,
11961196
BinOpCategory::Shift => {
11971197
lhs.references_error()

0 commit comments

Comments
 (0)