Rollup merge of #118981 - krtab:onelessalloc, r=compiler-errors

Remove an unneeded allocation

This removes an unneeded allocation in `<&[hir::GenericParam<'_>] as NextTypeParamName>::next_type_param_name`
This commit is contained in:
Jubilee 2023-12-15 14:08:17 -08:00 committed by GitHub
commit 3d94fc9dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4665,7 +4665,7 @@ pub trait NextTypeParamName {
impl NextTypeParamName for &[hir::GenericParam<'_>] { impl NextTypeParamName for &[hir::GenericParam<'_>] {
fn next_type_param_name(&self, name: Option<&str>) -> String { fn next_type_param_name(&self, name: Option<&str>) -> String {
// This is the list of possible parameter names that we might suggest. // This is the list of possible parameter names that we might suggest.
let name = name.and_then(|n| n.chars().next()).map(|c| c.to_string().to_uppercase()); let name = name.and_then(|n| n.chars().next()).map(|c| c.to_uppercase().to_string());
let name = name.as_deref(); let name = name.as_deref();
let possible_names = [name.unwrap_or("T"), "T", "U", "V", "X", "Y", "Z", "A", "B", "C"]; let possible_names = [name.unwrap_or("T"), "T", "U", "V", "X", "Y", "Z", "A", "B", "C"];
let used_names = self let used_names = self