Skip to content

Commit db06c64

Browse files
committed
chore: cleanup inefficient_to_string lint
Apparently this causes a slowdown per [docs](https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string). I used this command and fixed a few remaining manual ones. ```sh __CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --allow-dirty ```
1 parent 931d388 commit db06c64

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ redundant_else = "allow" # 58
645645
map_unwrap_or = "allow" # 54
646646
cast_precision_loss = "allow" # 52
647647
unnested_or_patterns = "allow" # 40
648-
inefficient_to_string = "allow" # 38
649648
unnecessary_wraps = "allow" # 37
650649
cast_lossless = "allow" # 33
651650
ignored_unit_patterns = "allow" # 29

src/uu/head/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ mod tests {
152152
}
153153

154154
fn obsolete_result(src: &[&str]) -> Option<Result<Vec<String>, ParseError>> {
155-
Some(Ok(src.iter().map(|s| s.to_string()).collect()))
155+
Some(Ok(src.iter().map(|s| (*s).to_string()).collect()))
156156
}
157157

158158
#[test]

src/uu/nohup/src/nohup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum NohupError {
3838
#[error("{}", get_message("nohup-error-cannot-detach"))]
3939
CannotDetach,
4040

41-
#[error("{}", get_message_with_args("nohup-error-cannot-replace", HashMap::from([("name".to_string(), _0.to_string()), ("err".to_string(), _1.to_string())])))]
41+
#[error("{}", get_message_with_args("nohup-error-cannot-replace", HashMap::from([("name".to_string(), (*_0).to_string()), ("err".to_string(), _1.to_string())])))]
4242
CannotReplace(&'static str, #[source] Error),
4343

4444
#[error("{}", get_message_with_args("nohup-error-open-failed", HashMap::from([("path".to_string(), NOHUP_OUT.quote().to_string()), ("err".to_string(), _1.to_string())])))]

src/uu/od/src/parse_formats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn parse_type_string(params: &str) -> Result<Vec<ParsedFormatterItemInfo>, Strin
330330

331331
#[cfg(test)]
332332
pub fn parse_format_flags_str(args_str: &[&'static str]) -> Result<Vec<FormatterItemInfo>, String> {
333-
let args: Vec<String> = args_str.iter().map(|s| s.to_string()).collect();
333+
let args: Vec<String> = args_str.iter().map(|s| (*s).to_string()).collect();
334334
parse_format_flags(&args).map(|v| {
335335
// tests using this function assume add_ascii_dump is not set
336336
v.into_iter()

src/uu/ptx/src/ptx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ enum PtxError {
198198
#[error("{}", get_message("ptx-error-dumb-format"))]
199199
DumbFormat,
200200

201-
#[error("{}", get_message_with_args("ptx-error-not-implemented", HashMap::from([("feature".to_string(), .0.to_string())])))]
201+
#[error("{}", get_message_with_args("ptx-error-not-implemented", HashMap::from([("feature".to_string(), (*.0).to_string())])))]
202202
NotImplemented(&'static str),
203203

204204
#[error("{0}")]

src/uu/stty/src/stty.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn stty(opts: &Options) -> UResult<()> {
266266
1,
267267
get_message_with_args(
268268
"stty-error-missing-argument",
269-
HashMap::from([("arg".to_string(), arg.to_string())]),
269+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
270270
),
271271
));
272272
}
@@ -282,8 +282,8 @@ fn stty(opts: &Options) -> UResult<()> {
282282
get_message_with_args(
283283
"stty-error-invalid-speed",
284284
HashMap::from([
285-
("arg".to_string(), arg.to_string()),
286-
("speed".to_string(), speed.to_string()),
285+
("arg".to_string(), (*arg).to_string()),
286+
("speed".to_string(), (*speed).to_string()),
287287
]),
288288
),
289289
));
@@ -294,7 +294,7 @@ fn stty(opts: &Options) -> UResult<()> {
294294
1,
295295
get_message_with_args(
296296
"stty-error-missing-argument",
297-
HashMap::from([("arg".to_string(), arg.to_string())]),
297+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
298298
),
299299
));
300300
}
@@ -316,7 +316,7 @@ fn stty(opts: &Options) -> UResult<()> {
316316
1,
317317
get_message_with_args(
318318
"stty-error-invalid-argument",
319-
HashMap::from([("arg".to_string(), arg.to_string())]),
319+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
320320
),
321321
));
322322
}
@@ -339,7 +339,7 @@ fn stty(opts: &Options) -> UResult<()> {
339339
1,
340340
get_message_with_args(
341341
"stty-error-missing-argument",
342-
HashMap::from([("arg".to_string(), arg.to_string())]),
342+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
343343
),
344344
));
345345
}
@@ -361,7 +361,7 @@ fn stty(opts: &Options) -> UResult<()> {
361361
1,
362362
get_message_with_args(
363363
"stty-error-missing-argument",
364-
HashMap::from([("arg".to_string(), arg.to_string())]),
364+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
365365
),
366366
));
367367
}
@@ -373,7 +373,7 @@ fn stty(opts: &Options) -> UResult<()> {
373373
1,
374374
get_message_with_args(
375375
"stty-error-invalid-argument",
376-
HashMap::from([("arg".to_string(), arg.to_string())]),
376+
HashMap::from([("arg".to_string(), (*arg).to_string())]),
377377
),
378378
));
379379
}
@@ -469,7 +469,7 @@ fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> {
469469
"{} ",
470470
get_message_with_args(
471471
"stty-output-speed",
472-
HashMap::from([("speed".to_string(), text.to_string())])
472+
HashMap::from([("speed".to_string(), (*text).to_string())])
473473
)
474474
);
475475
break;

0 commit comments

Comments
 (0)