Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c3699b9

Browse files
test-utils: Fix warnings about clippy str_to_string rule
1 parent 0a879f7 commit c3699b9

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

crates/test-utils/src/bench_fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn big_struct() -> String {
1212
}
1313

1414
pub fn big_struct_n(n: u32) -> String {
15-
let mut buf = "pub struct RegisterBlock {".to_string();
15+
let mut buf = "pub struct RegisterBlock {".to_owned();
1616
for i in 0..n {
1717
format_to!(buf, " /// Doc comment for {}.\n", i);
1818
format_to!(buf, " pub s{}: S{},\n", i, i);

crates/test-utils/src/fixture.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ impl FixtureWithProjectMeta {
178178

179179
if let Some(meta) = fixture.strip_prefix("//- toolchain:") {
180180
let (meta, remain) = meta.split_once('\n').unwrap();
181-
toolchain = Some(meta.trim().to_string());
181+
toolchain = Some(meta.trim().to_owned());
182182
fixture = remain;
183183
}
184184

185185
if let Some(meta) = fixture.strip_prefix("//- proc_macros:") {
186186
let (meta, remain) = meta.split_once('\n').unwrap();
187-
proc_macro_names = meta.split(',').map(|it| it.trim().to_string()).collect();
187+
proc_macro_names = meta.split(',').map(|it| it.trim().to_owned()).collect();
188188
fixture = remain;
189189
}
190190

@@ -234,7 +234,7 @@ impl FixtureWithProjectMeta {
234234
let meta = meta["//-".len()..].trim();
235235
let mut components = meta.split_ascii_whitespace();
236236

237-
let path = components.next().expect("fixture meta must start with a path").to_string();
237+
let path = components.next().expect("fixture meta must start with a path").to_owned();
238238
assert!(path.starts_with('/'), "fixture path does not start with `/`: {path:?}");
239239

240240
let mut krate = None;
@@ -246,7 +246,7 @@ impl FixtureWithProjectMeta {
246246
let mut introduce_new_source_root = None;
247247
let mut library = false;
248248
let mut target_data_layout = Some(
249-
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128".to_string(),
249+
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128".to_owned(),
250250
);
251251
for component in components {
252252
if component == "library" {
@@ -257,22 +257,22 @@ impl FixtureWithProjectMeta {
257257
let (key, value) =
258258
component.split_once(':').unwrap_or_else(|| panic!("invalid meta line: {meta:?}"));
259259
match key {
260-
"crate" => krate = Some(value.to_string()),
261-
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
260+
"crate" => krate = Some(value.to_owned()),
261+
"deps" => deps = value.split(',').map(|it| it.to_owned()).collect(),
262262
"extern-prelude" => {
263263
if value.is_empty() {
264264
extern_prelude = Some(Vec::new());
265265
} else {
266266
extern_prelude =
267-
Some(value.split(',').map(|it| it.to_string()).collect::<Vec<_>>());
267+
Some(value.split(',').map(|it| it.to_owned()).collect::<Vec<_>>());
268268
}
269269
}
270-
"edition" => edition = Some(value.to_string()),
270+
"edition" => edition = Some(value.to_owned()),
271271
"cfg" => {
272272
for entry in value.split(',') {
273273
match entry.split_once('=') {
274-
Some((k, v)) => cfgs.push((k.to_string(), Some(v.to_string()))),
275-
None => cfgs.push((entry.to_string(), None)),
274+
Some((k, v)) => cfgs.push((k.to_owned(), Some(v.to_owned()))),
275+
None => cfgs.push((entry.to_owned(), None)),
276276
}
277277
}
278278
}
@@ -283,8 +283,8 @@ impl FixtureWithProjectMeta {
283283
}
284284
}
285285
}
286-
"new_source_root" => introduce_new_source_root = Some(value.to_string()),
287-
"target_data_layout" => target_data_layout = Some(value.to_string()),
286+
"new_source_root" => introduce_new_source_root = Some(value.to_owned()),
287+
"target_data_layout" => target_data_layout = Some(value.to_owned()),
288288
_ => panic!("bad component: {component:?}"),
289289
}
290290
}
@@ -381,7 +381,7 @@ impl MiniCore {
381381
let (flag, deps) = line.split_once(':').unwrap();
382382
let flag = flag.trim();
383383

384-
self.valid_flags.push(flag.to_string());
384+
self.valid_flags.push(flag.to_owned());
385385
implications.extend(
386386
iter::repeat(flag)
387387
.zip(deps.split(", ").map(str::trim).filter(|dep| !dep.is_empty())),
@@ -401,7 +401,7 @@ impl MiniCore {
401401
let mut changed = false;
402402
for &(u, v) in &implications {
403403
if self.has_flag(u) && !self.has_flag(v) {
404-
self.activated_flags.push(v.to_string());
404+
self.activated_flags.push(v.to_owned());
405405
changed = true;
406406
}
407407
}
@@ -486,9 +486,9 @@ fn parse_fixture_gets_full_meta() {
486486
mod m;
487487
"#,
488488
);
489-
assert_eq!(toolchain, Some("nightly".to_string()));
490-
assert_eq!(proc_macro_names, vec!["identity".to_string()]);
491-
assert_eq!(mini_core.unwrap().activated_flags, vec!["coerce_unsized".to_string()]);
489+
assert_eq!(toolchain, Some("nightly".to_owned()));
490+
assert_eq!(proc_macro_names, vec!["identity".to_owned()]);
491+
assert_eq!(mini_core.unwrap().activated_flags, vec!["coerce_unsized".to_owned()]);
492492
assert_eq!(1, parsed.len());
493493

494494
let meta = &parsed[0];

crates/test-utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn extract_tags(mut text: &str, tag: &str) -> (Vec<(TextRange, Option<String
164164
if text.starts_with(&open) {
165165
let close_open = text.find('>').unwrap();
166166
let attr = text[open.len()..close_open].trim();
167-
let attr = if attr.is_empty() { None } else { Some(attr.to_string()) };
167+
let attr = if attr.is_empty() { None } else { Some(attr.to_owned()) };
168168
text = &text[close_open + '>'.len_utf8()..];
169169
let from = TextSize::of(&res);
170170
stack.push((from, attr));
@@ -326,7 +326,7 @@ fn extract_line_annotations(mut line: &str) -> Vec<LineAnnotation> {
326326
content = &content["file".len()..];
327327
}
328328

329-
let content = content.trim_start().to_string();
329+
let content = content.trim_start().to_owned();
330330

331331
let annotation = if continuation {
332332
LineAnnotation::Continuation { offset: range.end(), content }

0 commit comments

Comments
 (0)