clippy: fix str_to_string lint

https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string

Closes #12449
This commit is contained in:
xtqqczze
2026-02-14 15:50:25 +00:00
committed by Johannes Altmanninger
parent 1e3153c3fb
commit e76370b3b7
8 changed files with 13 additions and 14 deletions

View File

@@ -215,6 +215,7 @@ ptr_offset_by_literal = "warn"
ref_option = "warn"
semicolon_if_nothing_returned = "warn"
stable_sort_primitive = "warn"
str_to_string = "warn"
unnecessary_semicolon = "warn"
# We do not want to use the e?print(ln)?! macros.

View File

@@ -159,16 +159,14 @@ fn join_if_relative(parent_if_relative: &Path, path: String) -> PathBuf {
}
let prefix = overridable_path("PREFIX", |env_prefix| {
Some(PathBuf::from(
env_prefix.unwrap_or("/usr/local".to_string()),
))
Some(PathBuf::from(env_prefix.unwrap_or("/usr/local".to_owned())))
})
.unwrap();
overridable_path("SYSCONFDIR", |env_sysconfdir| {
Some(join_if_relative(
&prefix,
env_sysconfdir.unwrap_or("/etc/".to_string()),
env_sysconfdir.unwrap_or("/etc/".to_owned()),
))
});
@@ -199,5 +197,5 @@ fn get_version() -> String {
)
.unwrap()
.trim_ascii_end()
.to_string()
.to_owned()
}

View File

@@ -43,7 +43,7 @@ fn build_man(sec1_dir: &Path) {
];
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
if env_var("FISH_BUILD_DOCS") == Some("0".to_string()) {
if env_var("FISH_BUILD_DOCS") == Some("0".to_owned()) {
rsconf::warn!("Skipping man pages because $FISH_BUILD_DOCS is set to 0");
return;
}
@@ -62,7 +62,7 @@ fn build_man(sec1_dir: &Path) {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
assert_ne!(
env_var("FISH_BUILD_DOCS"),
Some("1".to_string()),
Some("1".to_owned()),
"Could not find sphinx-build required to build man pages.\n\
Install Sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0."
);

View File

@@ -43,7 +43,7 @@ fn cpu_use(j: &Job) -> f64 {
fn builtin_jobs_print(j: &Job, mode: JobsPrintMode, header: bool, streams: &mut IoStreams) {
let pgid = match j.get_pgid() {
Some(pgid) => pgid.to_string(),
None => "-".to_string(),
None => "-".to_owned(),
};
let mut out = WString::new();

View File

@@ -380,7 +380,7 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString {
format!("signal handler for {} ({})", signal.name(), signal.desc(),)
}
EventDescription::Variable { name } => format!("handler for variable '{name}'"),
EventDescription::ProcessExit { pid: None } => "exit handler for any process".to_string(),
EventDescription::ProcessExit { pid: None } => "exit handler for any process".to_owned(),
EventDescription::ProcessExit { pid: Some(pid) } => {
format!("exit handler for process {pid}")
}
@@ -392,11 +392,11 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString {
format!("exit handler for job with pid {pid}")
}
} else {
"exit handler for any job".to_string()
"exit handler for any job".to_owned()
}
}
EventDescription::CallerExit { .. } => {
"exit handler for command substitution caller".to_string()
"exit handler for command substitution caller".to_owned()
}
EventDescription::Generic { param } => format!("handler for generic event '{param}'"),
EventDescription::Any => unreachable!(),

View File

@@ -16,7 +16,7 @@ pub unsafe fn set_libc_locales(log_ok: bool) -> bool {
if log_ok {
crate::flog::flog!(env_locale, {
let source = if value == from_environment {
"from environment".to_string()
"from environment".to_owned()
} else {
format!("to '{}'", value.to_str().unwrap())
};

View File

@@ -1465,7 +1465,7 @@ fn summary_command(j: &Job, p: Option<&Process>) -> WString {
if j.external_procs().count() > 1 {
// I don't think it's safe to blindly unwrap here because even though we exited with
// a signal, the job could have contained a fish function?
let pid = p.pid().map_or("-".to_string(), |p| p.to_string());
let pid = p.pid().map_or("-".to_owned(), |p| p.to_string());
buffer += &sprintf!(" %s", pid)[..];
buffer.push(' ');

View File

@@ -583,7 +583,7 @@ pub fn set_position_in_viewport(&mut self, whence: &str, viewport_y: Option<usiz
flogf!(
reader,
"Setting screen y to %s due to %s",
viewport_y.map_or("<none>".to_string(), |y| format!("{y}")),
viewport_y.map_or("<none>".to_owned(), |y| format!("{y}")),
whence,
);
self.viewport_y = viewport_y;