X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_borrowck%2Fsrc%2Fdiagnostics%2Foutlives_suggestion.rs;h=1eaf0a2f15ce8ffe2468e25a387ec111cd2fe84a;hb=d0cf7e3bf59ecf7666820b9f2fba9760c6b7beec;hp=35c3df768995a0d2907db1cb174122666596a9cc;hpb=69e705564d54ffed9ab36ec9f0d3183daab72039;p=rust.git diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index 35c3df76899..1eaf0a2f15c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -209,14 +209,14 @@ pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_>) { let mut diag = if suggested.len() == 1 { mbcx.infcx.tcx.sess.diagnostic().struct_help(&match suggested.last().unwrap() { SuggestedConstraint::Outlives(a, bs) => { - let bs: SmallVec<[String; 2]> = bs.iter().map(|r| format!("{}", r)).collect(); - format!("add bound `{}: {}`", a, bs.join(" + ")) + let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect(); + format!("add bound `{a}: {}`", bs.join(" + ")) } SuggestedConstraint::Equal(a, b) => { - format!("`{}` and `{}` must be the same: replace one with the other", a, b) + format!("`{a}` and `{b}` must be the same: replace one with the other") } - SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a), + SuggestedConstraint::Static(a) => format!("replace `{a}` with `'static`"), }) } else { // Create a new diagnostic. @@ -231,18 +231,16 @@ pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_>) { for constraint in suggested { match constraint { SuggestedConstraint::Outlives(a, bs) => { - let bs: SmallVec<[String; 2]> = - bs.iter().map(|r| format!("{}", r)).collect(); - diag.help(&format!("add bound `{}: {}`", a, bs.join(" + "))); + let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect(); + diag.help(&format!("add bound `{a}: {}`", bs.join(" + "))); } SuggestedConstraint::Equal(a, b) => { diag.help(&format!( - "`{}` and `{}` must be the same: replace one with the other", - a, b + "`{a}` and `{b}` must be the same: replace one with the other", )); } SuggestedConstraint::Static(a) => { - diag.help(&format!("replace `{}` with `'static`", a)); + diag.help(&format!("replace `{a}` with `'static`")); } } }