mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 07:46:28 +00:00
chore: fix clippy warnings for rust 1.66 (#4715)
chore: fix new clippy lints
This commit is contained in:
parent
220844daa0
commit
aa6c2dd588
@ -38,7 +38,7 @@ pub fn create() {
|
||||
if input.trim().to_lowercase() == "y" {
|
||||
let link = make_github_issue_link(&issue_body);
|
||||
if let Err(e) = open::that(&link) {
|
||||
println!("Failed to open issue report in your browser: {}", e);
|
||||
println!("Failed to open issue report in your browser: {e}");
|
||||
println!("Please copy the above report and open an issue manually, or try opening the following link:\n{link}");
|
||||
}
|
||||
} else {
|
||||
|
@ -18,7 +18,7 @@ pub struct OSConfig<'a> {
|
||||
|
||||
impl<'a> OSConfig<'a> {
|
||||
pub fn get_symbol(&self, key: &Type) -> Option<&'a str> {
|
||||
self.symbols.get(key).cloned()
|
||||
self.symbols.get(key).copied()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> {
|
||||
"cmd" => print_script(CMDEXE_INIT, &StarshipPath::init()?.sprint_cmdexe()?),
|
||||
_ => {
|
||||
eprintln!(
|
||||
"{0} is not yet supported by starship.\n\
|
||||
"{shell_basename} is not yet supported by starship.\n\
|
||||
For the time being, we support the following shells:\n\
|
||||
* bash\n\
|
||||
* elvish\n\
|
||||
@ -197,9 +197,8 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> {
|
||||
* cmd\n\
|
||||
\n\
|
||||
Please open an issue in the starship repo if you would like to \
|
||||
see support for {0}:\n\
|
||||
https://github.com/starship/starship/issues/new\n",
|
||||
shell_basename
|
||||
see support for {shell_basename}:\n\
|
||||
https://github.com/starship/starship/issues/new\n"
|
||||
)
|
||||
}
|
||||
};
|
||||
|
@ -133,6 +133,6 @@ impl log::Log for StarshipLogger {
|
||||
}
|
||||
|
||||
pub fn init() {
|
||||
log::set_boxed_logger(Box::new(StarshipLogger::default())).unwrap();
|
||||
log::set_boxed_logger(Box::<StarshipLogger>::default()).unwrap();
|
||||
log::set_max_level(LevelFilter::Trace);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ fn main() {
|
||||
println!("Supported modules list");
|
||||
println!("----------------------");
|
||||
for modules in ALL_MODULES {
|
||||
println!("{}", modules);
|
||||
println!("{modules}");
|
||||
}
|
||||
}
|
||||
if let Some(module_name) = name {
|
||||
@ -198,7 +198,7 @@ fn main() {
|
||||
configure::update_configuration(&name, &value)
|
||||
}
|
||||
} else if let Err(reason) = configure::edit_configuration(None) {
|
||||
eprintln!("Could not edit configuration: {}", reason);
|
||||
eprintln!("Could not edit configuration: {reason}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
if let Segment::LineTerm = segment {
|
||||
if matches!(segment, Segment::LineTerm) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -682,9 +682,8 @@ credential_process = /opt/bin/awscreds-retriever
|
||||
"[astronauts]
|
||||
aws_access_key_id=dummy
|
||||
aws_secret_access_key=dummy
|
||||
{}={}
|
||||
",
|
||||
key, expiration_date
|
||||
{key}={expiration_date}
|
||||
"
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
|
@ -491,10 +491,9 @@ mod tests {
|
||||
toml::from_str(&format!(
|
||||
"
|
||||
[git_branch]
|
||||
truncation_length = {}
|
||||
{}
|
||||
",
|
||||
truncate_length, config_options
|
||||
truncation_length = {truncate_length}
|
||||
{config_options}
|
||||
"
|
||||
))
|
||||
.unwrap(),
|
||||
)
|
||||
@ -530,10 +529,9 @@ mod tests {
|
||||
toml::from_str(&format!(
|
||||
r#"
|
||||
[git_branch]
|
||||
format = "{}"
|
||||
{}
|
||||
"#,
|
||||
format, config_options
|
||||
format = "{format}"
|
||||
{config_options}
|
||||
"#
|
||||
))
|
||||
.unwrap(),
|
||||
)
|
||||
|
@ -132,7 +132,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -151,7 +151,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -173,7 +173,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -201,7 +201,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -230,7 +230,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -260,7 +260,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
@ -290,7 +290,7 @@ mod tests {
|
||||
"haxe --version",
|
||||
Some(CommandOutput {
|
||||
stdout: "4.3.0-rc.1+\n".to_owned(),
|
||||
stderr: "".to_owned(),
|
||||
stderr: String::new(),
|
||||
}),
|
||||
)
|
||||
.path(dir.path())
|
||||
|
@ -326,8 +326,7 @@ mod tests {
|
||||
let expected = Some(format!(
|
||||
"on {} ",
|
||||
expect_style.paint(format!(
|
||||
"{} {}{}",
|
||||
expect_symbol, expect_branch_name, expect_truncation_symbol
|
||||
"{expect_symbol} {expect_branch_name}{expect_truncation_symbol}"
|
||||
)),
|
||||
));
|
||||
assert_eq!(expected, actual);
|
||||
|
@ -385,12 +385,11 @@ users: []
|
||||
apiVersion: v1
|
||||
clusters: []
|
||||
contexts: []
|
||||
current-context: {}
|
||||
current-context: {ctx_name}
|
||||
kind: Config
|
||||
preferences: {{}}
|
||||
users: []
|
||||
",
|
||||
ctx_name
|
||||
"
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
@ -695,15 +694,14 @@ clusters: []
|
||||
contexts:
|
||||
- context:
|
||||
cluster: test_cluster
|
||||
user: {}
|
||||
user: {user_name}
|
||||
namespace: test_namespace
|
||||
name: test_context
|
||||
current-context: test_context
|
||||
kind: Config
|
||||
preferences: {{}}
|
||||
users: []
|
||||
",
|
||||
user_name
|
||||
"
|
||||
)
|
||||
.as_bytes(),
|
||||
)?;
|
||||
|
@ -11,7 +11,7 @@ mod cobol;
|
||||
mod conda;
|
||||
mod container;
|
||||
mod crystal;
|
||||
pub(crate) mod custom;
|
||||
pub mod custom;
|
||||
mod daml;
|
||||
mod dart;
|
||||
mod deno;
|
||||
|
@ -77,7 +77,7 @@ fn get_type(os: &os_info::Info) -> Option<String> {
|
||||
fn get_version(os: &os_info::Info) -> Option<String> {
|
||||
Some(os.version())
|
||||
.filter(|&x| x != &os_info::Version::Unknown)
|
||||
.map(|x| x.to_string())
|
||||
.map(os_info::Version::to_string)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -394,7 +394,7 @@ fn format_rustc_version(rustc_version: &str, version_format: &str) -> Option<Str
|
||||
Ok(formatted) => Some(formatted),
|
||||
Err(error) => {
|
||||
log::warn!("Error formatting `rust` version:\n{}", error);
|
||||
Some(format!("v{}", version))
|
||||
Some(format!("v{version}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -402,7 +402,7 @@ fn format_rustc_version(rustc_version: &str, version_format: &str) -> Option<Str
|
||||
fn format_toolchain(toolchain: &str, default_host_triple: Option<&str>) -> String {
|
||||
default_host_triple
|
||||
.map_or(toolchain, |triple| {
|
||||
toolchain.trim_end_matches(&format!("-{}", triple))
|
||||
toolchain.trim_end_matches(&format!("-{triple}"))
|
||||
})
|
||||
.to_owned()
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use std::path::Path;
|
||||
/// 2a) (not implemented on macOS) one of the supplementary groups of the current user is the
|
||||
/// directory group owner and whether it has write access
|
||||
/// 3) 'others' part of the access mask has the write access
|
||||
#[allow(clippy::useless_conversion)] // On some platforms it is not u32
|
||||
pub fn is_write_allowed(folder_path: &Path) -> Result<bool, String> {
|
||||
let meta =
|
||||
fs::metadata(folder_path).map_err(|e| format!("Unable to stat() directory: {e:?}"))?;
|
||||
@ -22,14 +23,15 @@ pub fn is_write_allowed(folder_path: &Path) -> Result<bool, String> {
|
||||
if euid.is_root() {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
if meta.uid() == euid.as_raw() {
|
||||
Ok(perms & Mode::S_IWUSR.bits() as u32 != 0)
|
||||
Ok(perms & u32::from(Mode::S_IWUSR.bits()) != 0)
|
||||
} else if (meta.gid() == Gid::effective().as_raw())
|
||||
|| (get_supplementary_groups().contains(&meta.gid()))
|
||||
{
|
||||
Ok(perms & Mode::S_IWGRP.bits() as u32 != 0)
|
||||
Ok(perms & u32::from(Mode::S_IWGRP.bits()) != 0)
|
||||
} else {
|
||||
Ok(perms & Mode::S_IWOTH.bits() as u32 != 0)
|
||||
Ok(perms & u32::from(Mode::S_IWOTH.bits()) != 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,8 +668,8 @@ mod tests {
|
||||
fn exec_no_output() {
|
||||
let result = internal_exec_cmd("true", &[] as &[&OsStr], Duration::from_millis(500));
|
||||
let expected = Some(CommandOutput {
|
||||
stdout: String::from(""),
|
||||
stderr: String::from(""),
|
||||
stdout: String::new(),
|
||||
stderr: String::new(),
|
||||
});
|
||||
|
||||
assert_eq!(result, expected)
|
||||
@ -682,7 +682,7 @@ mod tests {
|
||||
internal_exec_cmd("/bin/sh", &["-c", "echo hello"], Duration::from_millis(500));
|
||||
let expected = Some(CommandOutput {
|
||||
stdout: String::from("hello\n"),
|
||||
stderr: String::from(""),
|
||||
stderr: String::new(),
|
||||
});
|
||||
|
||||
assert_eq!(result, expected)
|
||||
@ -697,7 +697,7 @@ mod tests {
|
||||
Duration::from_millis(500),
|
||||
);
|
||||
let expected = Some(CommandOutput {
|
||||
stdout: String::from(""),
|
||||
stdout: String::new(),
|
||||
stderr: String::from("hello\n"),
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user