chore: handle rust 1.72 clippy & fmt changes (#5399)

This commit is contained in:
David Knaack 2023-08-25 22:53:35 +02:00 committed by GitHub
parent d3ec97f86f
commit 77967148b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 66 deletions

View File

@ -22,7 +22,7 @@ fn gen_presets_hook(mut file: &File) -> SdResult<()> {
println!("cargo:rerun-if-changed=docs/.vuepress/public/presets/toml");
let paths = fs::read_dir("docs/.vuepress/public/presets/toml")?;
let mut sortedpaths = paths.collect::<io::Result<Vec<_>>>()?;
sortedpaths.sort_by_key(|e| e.path());
sortedpaths.sort_by_key(std::fs::DirEntry::path);
let mut presets = String::new();
let mut match_arms = String::new();

View File

@ -287,8 +287,7 @@ pub fn parse_style_string(
) -> Option<nu_ansi_term::Style> {
style_string
.split_whitespace()
.fold(Some(nu_ansi_term::Style::new()), |maybe_style, token| {
maybe_style.and_then(|style| {
.try_fold(nu_ansi_term::Style::new(), |style, token| {
let token = token.to_lowercase();
// Check for FG/BG identifiers and strip them off if appropriate
@ -345,7 +344,6 @@ pub fn parse_style_string(
}
}
})
})
}
/** Parse a string that represents a color setting, returning None if this fails

View File

@ -546,12 +546,12 @@ mod tests {
#[test]
fn test_escaped_chars() {
const FORMAT_STR: &str = r#"\\\[\$text\]\(red bold\)"#;
const FORMAT_STR: &str = r"\\\[\$text\]\(red bold\)";
let formatter = StringFormatter::new(FORMAT_STR).unwrap().map(empty_mapper);
let result = formatter.parse(None, None).unwrap();
let mut result_iter = result.iter();
match_next!(result_iter, r#"\[$text](red bold)"#, None);
match_next!(result_iter, r"\[$text](red bold)", None);
}
#[test]

View File

@ -37,12 +37,12 @@ pub fn cleanup_log_files<P: AsRef<Path>>(path: P) {
let log_dir = path.as_ref();
let Ok(log_files) = fs::read_dir(log_dir) else {
// Avoid noisily handling errors in this cleanup function.
return
return;
};
for file in log_files {
// Skip files that can't be read.
let Ok (file) = file else {
let Ok(file) = file else {
continue;
};

View File

@ -231,7 +231,7 @@ where
strs.into_iter()
.chain(std::iter::once(fill.ansi_string(fill_size)))
})
.chain(current.into_iter())
.chain(current)
.collect::<Vec<AnsiString>>()
}
}

View File

@ -194,7 +194,7 @@ fn get_meson_version(context: &Context, config: &PackageConfig) -> Option<String
.split_ascii_whitespace()
.collect::<String>();
let re = Regex::new(r#"project\([^())]*,version:'(?P<version>[^']+)'[^())]*\)"#).unwrap();
let re = Regex::new(r"project\([^())]*,version:'(?P<version>[^']+)'[^())]*\)").unwrap();
let caps = re.captures(&file_contents)?;
format_version(&caps["version"], config.version_format)
@ -487,12 +487,12 @@ mod tests {
fn test_extract_nimble_package_version() -> io::Result<()> {
let config_name = "test_project.nimble";
let config_content = r##"
let config_content = r#"
version = "0.1.0"
author = "Mr. nimble"
description = "A new awesome nimble package"
license = "MIT"
"##;
"#;
let project_dir = create_project_dir()?;
fill_config(&project_dir, config_name, Some(config_content))?;
@ -505,7 +505,7 @@ license = "MIT"
.cmd(
"nimble dump --json",
Some(CommandOutput {
stdout: r##"
stdout: r#"
{
"name": "test_project.nimble",
"version": "0.1.0",
@ -524,7 +524,7 @@ license = "MIT"
"srcDir": "",
"backend": "c"
}
"##
"#
.to_owned(),
stderr: String::new(),
}),
@ -547,12 +547,12 @@ license = "MIT"
) -> io::Result<()> {
let config_name = "test_project.nimble";
let config_content = r##"
let config_content = r#"
version = "0.1.0"
author = "Mr. nimble"
description = "A new awesome nimble package"
license = "MIT"
"##;
"#;
let project_dir = create_project_dir()?;
fill_config(&project_dir, config_name, Some(config_content))?;

View File

@ -81,7 +81,7 @@ fn create_offset_time_string(
if utc_time_offset_in_hours < 24_f32 && utc_time_offset_in_hours > -24_f32 {
let utc_offset_in_seconds: i32 = (utc_time_offset_in_hours * 3600_f32) as i32;
let Some(timezone_offset) = FixedOffset::east_opt(utc_offset_in_seconds) else {
return Err("Invalid offset")
return Err("Invalid offset");
};
log::trace!("Target timezone offset is {}", timezone_offset);