Use into_owned over to_string for Cow<str> (#39024)

This removes unnecessary allocations when the `Cow` is already owned


Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-09-27 14:50:10 +00:00
committed by GitHub
parent a063a70cfb
commit 72948e14ee
84 changed files with 169 additions and 161 deletions
+1 -1
View File
@@ -528,7 +528,7 @@ impl ContextProvider for GoContextProvider {
let module_dir = buffer_dir
.ancestors()
.find(|dir| dir.join("go.mod").is_file())
.map(|dir| dir.to_string_lossy().to_string())
.map(|dir| dir.to_string_lossy().into_owned())
.unwrap_or_else(|| ".".to_string());
(GO_MODULE_ROOT_TASK_VARIABLE.clone(), module_dir)
+1 -1
View File
@@ -1029,7 +1029,7 @@ fn test_fragment(variables: &TaskVariables, path: &Path, stem: &str) -> String {
// filter out just that module.
Some("--lib".to_owned())
} else if stem == "mod" {
maybe!({ Some(path.parent()?.file_name()?.to_string_lossy().to_string()) })
maybe!({ Some(path.parent()?.file_name()?.to_string_lossy().into_owned()) })
} else if stem == "main" {
if let (Some(bin_name), Some(bin_kind)) = (
variables.get(&RUST_BIN_NAME_TASK_VARIABLE),