@@ -299,52 +299,52 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
299
299
IsAssign::No => {
300
300
let (message, missing_trait, use_output) = match op.node {
301
301
hir::BinOpKind::Add => (
302
- format!("cannot add `{}` to `{}`", rhs_ty, lhs_ty ),
302
+ format!("cannot add `{rhs_ty }` to `{lhs_ty }`"),
303
303
Some("std::ops::Add"),
304
304
true,
305
305
),
306
306
hir::BinOpKind::Sub => (
307
- format!("cannot subtract `{}` from `{}`", rhs_ty, lhs_ty ),
307
+ format!("cannot subtract `{rhs_ty }` from `{lhs_ty }`"),
308
308
Some("std::ops::Sub"),
309
309
true,
310
310
),
311
311
hir::BinOpKind::Mul => (
312
- format!("cannot multiply `{}` by `{}`", lhs_ty, rhs_ty ),
312
+ format!("cannot multiply `{lhs_ty }` by `{rhs_ty }`"),
313
313
Some("std::ops::Mul"),
314
314
true,
315
315
),
316
316
hir::BinOpKind::Div => (
317
- format!("cannot divide `{}` by `{}`", lhs_ty, rhs_ty ),
317
+ format!("cannot divide `{lhs_ty }` by `{rhs_ty }`"),
318
318
Some("std::ops::Div"),
319
319
true,
320
320
),
321
321
hir::BinOpKind::Rem => (
322
- format!("cannot mod `{}` by `{}`", lhs_ty, rhs_ty ),
322
+ format!("cannot mod `{lhs_ty }` by `{rhs_ty }`"),
323
323
Some("std::ops::Rem"),
324
324
true,
325
325
),
326
326
hir::BinOpKind::BitAnd => (
327
- format!("no implementation for `{} & {}`", lhs_ty, rhs_ty ),
327
+ format!("no implementation for `{lhs_ty } & {rhs_ty }`"),
328
328
Some("std::ops::BitAnd"),
329
329
true,
330
330
),
331
331
hir::BinOpKind::BitXor => (
332
- format!("no implementation for `{} ^ {}`", lhs_ty, rhs_ty ),
332
+ format!("no implementation for `{lhs_ty } ^ {rhs_ty }`"),
333
333
Some("std::ops::BitXor"),
334
334
true,
335
335
),
336
336
hir::BinOpKind::BitOr => (
337
- format!("no implementation for `{} | {}`", lhs_ty, rhs_ty ),
337
+ format!("no implementation for `{lhs_ty } | {rhs_ty }`"),
338
338
Some("std::ops::BitOr"),
339
339
true,
340
340
),
341
341
hir::BinOpKind::Shl => (
342
- format!("no implementation for `{} << {}`", lhs_ty, rhs_ty ),
342
+ format!("no implementation for `{lhs_ty } << {rhs_ty }`"),
343
343
Some("std::ops::Shl"),
344
344
true,
345
345
),
346
346
hir::BinOpKind::Shr => (
347
- format!("no implementation for `{} >> {}`", lhs_ty, rhs_ty ),
347
+ format!("no implementation for `{lhs_ty } >> {rhs_ty }`"),
348
348
Some("std::ops::Shr"),
349
349
true,
350
350
),
@@ -477,8 +477,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
477
477
// When we know that a missing bound is responsible, we don't show
478
478
// this note as it is redundant.
479
479
err.note(&format!(
480
- "the trait `{}` is not implemented for `{}`",
481
- missing_trait, lhs_ty
480
+ "the trait `{missing_trait}` is not implemented for `{lhs_ty}`"
482
481
));
483
482
}
484
483
} else {
@@ -679,19 +678,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
679
678
};
680
679
let mut visitor = TypeParamVisitor(vec![]);
681
680
visitor.visit_ty(operand_ty);
682
- if let [ty] = &visitor.0[..] {
683
- if let ty::Param(p) = *operand_ty.kind() {
684
- suggest_constraining_param(
685
- self.tcx,
686
- self.body_id,
687
- &mut err,
688
- *ty,
689
- operand_ty,
690
- missing_trait,
691
- p,
692
- true,
693
- );
694
- }
681
+ if let [ty] = &visitor.0[..] && let ty::Param(p) = *operand_ty.kind() {
682
+ suggest_constraining_param(
683
+ self.tcx,
684
+ self.body_id,
685
+ &mut err,
686
+ *ty,
687
+ operand_ty,
688
+ missing_trait,
689
+ p,
690
+ true,
691
+ );
695
692
}
696
693
697
694
let sp = self.tcx.sess.source_map().start_point(ex.span);
@@ -722,10 +719,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
722
719
err.span_suggestion(
723
720
ex.span,
724
721
&format!(
725
- "you may have meant the maximum value of `{}`",
726
- actual
722
+ "you may have meant the maximum value of `{actual}`",
727
723
),
728
- format!("{}::MAX", actual ),
724
+ format!("{actual }::MAX"),
729
725
Applicability::MaybeIncorrect,
730
726
);
731
727
}
@@ -988,7 +984,7 @@ fn suggest_constraining_param(
988
984
set_output: bool,
989
985
) {
990
986
let hir = tcx.hir();
991
- let msg = &format!("`{}` might need a bound for `{}`", lhs_ty, missing_trait );
987
+ let msg = &format!("`{lhs_ty }` might need a bound for `{missing_trait }`");
992
988
// Try to find the def-id and details for the parameter p. We have only the index,
993
989
// so we have to find the enclosing function's def-id, then look through its declared
994
990
// generic parameters to get the declaration.
@@ -1002,13 +998,13 @@ fn suggest_constraining_param(
1002
998
.as_ref()
1003
999
.and_then(|node| node.generics())
1004
1000
{
1005
- let output = if set_output { format!("<Output = {}>", rhs_ty ) } else { String::new() };
1001
+ let output = if set_output { format!("<Output = {rhs_ty }>") } else { String::new() };
1006
1002
suggest_constraining_type_param(
1007
1003
tcx,
1008
1004
generics,
1009
1005
&mut err,
1010
- &format!("{}", lhs_ty),
1011
- &format!("{}{}", missing_trait, output ),
1006
+ &lhs_ty.to_string( ),
1007
+ &format!("{missing_trait}{output}" ),
1012
1008
None,
1013
1009
);
1014
1010
} else {
0 commit comments