Rollup merge of #115001 - matthiaskrgr:perf_clippy, r=cjgillot

clippy::perf stuff
This commit is contained in:
Matthias Krüger
2023-08-20 00:28:34 +02:00
committed by GitHub
3 changed files with 18 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
//! Diagnostics related methods for `Ty`.
use std::borrow::Cow;
use std::fmt::Write;
use std::ops::ControlFlow;
use crate::ty::{
@@ -335,10 +336,10 @@ pub fn suggest_constraining_type_params<'a>(
// - insert: `, X: Bar`
suggestions.push((
generics.tail_span_for_predicate_suggestion(),
constraints
.iter()
.map(|&(constraint, _)| format!(", {param_name}: {constraint}"))
.collect::<String>(),
constraints.iter().fold(String::new(), |mut string, &(constraint, _)| {
write!(string, ", {param_name}: {constraint}").unwrap();
string
}),
SuggestChangingConstraintsMessage::RestrictTypeFurther { ty: param_name },
));
continue;