fix clippy::useless_format
This commit is contained in:
parent
adf759bf6a
commit
b594798ae3
6 changed files with 12 additions and 16 deletions
|
@ -264,11 +264,11 @@ fn msg_span_from_named_region<'tcx>(
|
|||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(Some(span)), .. },
|
||||
..
|
||||
}) => (format!("the anonymous lifetime defined here"), Some(span)),
|
||||
}) => ("the anonymous lifetime defined here".to_owned(), Some(span)),
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(None), .. },
|
||||
..
|
||||
}) => (format!("an anonymous lifetime"), None),
|
||||
}) => ("an anonymous lifetime".to_owned(), None),
|
||||
_ => bug!("{:?}", region),
|
||||
}
|
||||
}
|
||||
|
@ -2354,7 +2354,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
if let Ok(snip) = self.tcx.sess.source_map().span_to_next_source(p.span)
|
||||
&& snip.starts_with(' ')
|
||||
{
|
||||
format!("{new_lt}")
|
||||
new_lt.to_string()
|
||||
} else {
|
||||
format!("{new_lt} ")
|
||||
}
|
||||
|
|
|
@ -333,11 +333,7 @@ pub fn suggest_new_region_bound(
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let name = if let Some(name) = &existing_lt_name {
|
||||
format!("{}", name)
|
||||
} else {
|
||||
format!("'a")
|
||||
};
|
||||
let name = if let Some(name) = &existing_lt_name { name } else { "'a" };
|
||||
// if there are more than one elided lifetimes in inputs, the explicit `'_` lifetime cannot be used.
|
||||
// introducing a new lifetime `'a` or making use of one from existing named lifetimes if any
|
||||
if let Some(id) = scope_def_id
|
||||
|
@ -350,7 +346,7 @@ pub fn suggest_new_region_bound(
|
|||
if p.span.hi() - p.span.lo() == rustc_span::BytePos(1) { // Ampersand (elided without '_)
|
||||
(p.span.shrink_to_hi(),format!("{name} "))
|
||||
} else { // Underscore (elided with '_)
|
||||
(p.span, format!("{name}"))
|
||||
(p.span, name.to_string())
|
||||
}
|
||||
)
|
||||
.collect::<Vec<_>>()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue