Skip to content

Commit 5d1f283

Browse files
project-model: Fix warnings about clippy str_to_string rule
1 parent d00f1c1 commit 5d1f283

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

crates/project-model/src/build_scripts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl WorkspaceBuildScripts {
322322
let mut deserializer = serde_json::Deserializer::from_str(line);
323323
deserializer.disable_recursion_limit();
324324
let message = Message::deserialize(&mut deserializer)
325-
.unwrap_or_else(|_| Message::TextLine(line.to_string()));
325+
.unwrap_or_else(|_| Message::TextLine(line.to_owned()));
326326

327327
match message {
328328
Message::BuildScriptExecuted(mut message) => {
@@ -356,7 +356,7 @@ impl WorkspaceBuildScripts {
356356
if let Some(out_dir) =
357357
out_dir.as_os_str().to_str().map(|s| s.to_owned())
358358
{
359-
data.envs.push(("OUT_DIR".to_string(), out_dir));
359+
data.envs.push(("OUT_DIR".to_owned(), out_dir));
360360
}
361361
data.out_dir = Some(out_dir);
362362
data.cfgs = cfgs;
@@ -396,7 +396,7 @@ impl WorkspaceBuildScripts {
396396

397397
let errors = if !output.status.success() {
398398
let errors = errors.into_inner();
399-
Some(if errors.is_empty() { "cargo check failed".to_string() } else { errors })
399+
Some(if errors.is_empty() { "cargo check failed".to_owned() } else { errors })
400400
} else {
401401
None
402402
};
@@ -490,7 +490,7 @@ impl WorkspaceBuildScripts {
490490

491491
// FIXME: Find a better way to know if it is a dylib.
492492
fn is_dylib(path: &Utf8Path) -> bool {
493-
match path.extension().map(|e| e.to_string().to_lowercase()) {
493+
match path.extension().map(|e| e.to_owned().to_lowercase()) {
494494
None => false,
495495
Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"),
496496
}

crates/project-model/src/cargo_workspace.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl CargoWorkspace {
285285
// FIXME: Fetching metadata is a slow process, as it might require
286286
// calling crates.io. We should be reporting progress here, but it's
287287
// unclear whether cargo itself supports it.
288-
progress("metadata".to_string());
288+
progress("metadata".to_owned());
289289

290290
(|| -> Result<cargo_metadata::Metadata, cargo_metadata::Error> {
291291
let mut command = meta.cargo_command();
@@ -502,7 +502,7 @@ fn rustc_discover_host_triple(
502502
let field = "host: ";
503503
let target = stdout.lines().find_map(|l| l.strip_prefix(field));
504504
if let Some(target) = target {
505-
Some(target.to_string())
505+
Some(target.to_owned())
506506
} else {
507507
// If we fail to resolve the host platform, it's not the end of the world.
508508
tracing::info!("rustc -vV did not report host platform, got:\n{}", stdout);
@@ -536,7 +536,7 @@ fn parse_output_cargo_config_build_target(stdout: String) -> Vec<String> {
536536
let trimmed = stdout.trim_start_matches("build.target = ").trim_matches('"');
537537

538538
if !trimmed.starts_with('[') {
539-
return [trimmed.to_string()].to_vec();
539+
return [trimmed.to_owned()].to_vec();
540540
}
541541

542542
let res = serde_json::from_str(trimmed);

crates/project-model/src/cfg_flag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl FromStr for CfgFlag {
1919
if !(value.starts_with('"') && value.ends_with('"')) {
2020
return Err(format!("Invalid cfg ({s:?}), value should be in quotes"));
2121
}
22-
let key = key.to_string();
22+
let key = key.to_owned();
2323
let value = value[1..value.len() - 1].to_string();
2424
CfgFlag::KeyValue { key, value }
2525
}

crates/project-model/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn utf8_stdout(mut cmd: Command) -> anyhow::Result<String> {
167167
}
168168
}
169169
let stdout = String::from_utf8(output.stdout)?;
170-
Ok(stdout.trim().to_string())
170+
Ok(stdout.trim().to_owned())
171171
}
172172

173173
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]

crates/project-model/src/rustc_cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) fn get(
3333
res.push(CfgFlag::Atom("target_thread_local".into()));
3434
for ty in ["8", "16", "32", "64", "cas", "ptr"] {
3535
for key in ["target_has_atomic", "target_has_atomic_load_store"] {
36-
res.push(CfgFlag::KeyValue { key: key.to_string(), value: ty.into() });
36+
res.push(CfgFlag::KeyValue { key: key.to_owned(), value: ty.into() });
3737
}
3838
}
3939

crates/project-model/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn get_fake_sysroot() -> Sysroot {
129129
}
130130

131131
fn rooted_project_json(data: ProjectJsonData) -> ProjectJson {
132-
let mut root = "$ROOT$".to_string();
132+
let mut root = "$ROOT$".to_owned();
133133
replace_root(&mut root, true);
134134
let path = Path::new(&root);
135135
let base = AbsPath::assert(path);

crates/project-model/src/workspace.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl ProjectWorkspace {
241241
.map_err(|p| Some(format!("rustc source path is not absolute: {p}"))),
242242
Some(RustLibSource::Discover) => {
243243
sysroot.as_ref().ok().and_then(Sysroot::discover_rustc_src).ok_or_else(
244-
|| Some("Failed to discover rustc source for sysroot.".to_string()),
244+
|| Some("Failed to discover rustc source for sysroot.".to_owned()),
245245
)
246246
}
247247
None => Err(None),
@@ -840,7 +840,7 @@ fn project_json_to_crate_graph(
840840
if let Some(name) = display_name.clone() {
841841
CrateOrigin::Local {
842842
repo: repository.clone(),
843-
name: Some(name.canonical_name().to_string()),
843+
name: Some(name.canonical_name().to_owned()),
844844
}
845845
} else {
846846
CrateOrigin::Local { repo: None, name: None }
@@ -1117,7 +1117,7 @@ fn detached_files_to_crate_graph(
11171117
let display_name = detached_file
11181118
.file_stem()
11191119
.and_then(|os_str| os_str.to_str())
1120-
.map(|file_stem| CrateDisplayName::from_canonical_name(file_stem.to_string()));
1120+
.map(|file_stem| CrateDisplayName::from_canonical_name(file_stem.to_owned()));
11211121
let detached_file_crate = crate_graph.add_crate_root(
11221122
file_id,
11231123
Edition::CURRENT,
@@ -1129,7 +1129,7 @@ fn detached_files_to_crate_graph(
11291129
false,
11301130
CrateOrigin::Local {
11311131
repo: None,
1132-
name: display_name.map(|n| n.canonical_name().to_string()),
1132+
name: display_name.map(|n| n.canonical_name().to_owned()),
11331133
},
11341134
target_layout.clone(),
11351135
None,
@@ -1323,7 +1323,7 @@ fn add_target_crate_root(
13231323
}
13241324
}
13251325

1326-
let display_name = CrateDisplayName::from_canonical_name(cargo_name.to_string());
1326+
let display_name = CrateDisplayName::from_canonical_name(cargo_name.to_owned());
13271327
let crate_id = crate_graph.add_crate_root(
13281328
file_id,
13291329
edition,

0 commit comments

Comments
 (0)