Run cargo fmt with Rustfmt 1.6.0

- "1.6.0" now supports formatting let-else statements which we use liberally,
  and appears to have some fixes in regards to long-indented-lines with macros
  like `wgettext_ft!`
- This commit updates the formatting so that devs with the latest stable don't
  see random format-fixes upon running `cargo fmt`
This commit is contained in:
Henrik Hørlück Berg 2023-08-24 16:11:40 +02:00 committed by Fabian Boehm
parent 0aa21440d1
commit 05c44df1a4
8 changed files with 36 additions and 13 deletions

View file

@ -21,7 +21,9 @@ pub fn emit(
} }
let Some(event_name) = argv.get(opts.optind) else { let Some(event_name) = argv.get(opts.optind) else {
streams.err.append(&sprintf!("%ls: expected event name\n"L, cmd)); streams
.err
.append(&sprintf!("%ls: expected event name\n"L, cmd));
return STATUS_INVALID_ARGS; return STATUS_INVALID_ARGS;
}; };

View file

@ -107,7 +107,11 @@ fn parse_cmd_opts(
} }
's' => { 's' => {
let Some(signal) = Signal::parse(w.woptarg.unwrap()) else { let Some(signal) = Signal::parse(w.woptarg.unwrap()) else {
streams.err.append(wgettext_fmt!("%ls: Unknown signal '%ls'", cmd, w.woptarg.unwrap())); streams.err.append(wgettext_fmt!(
"%ls: Unknown signal '%ls'",
cmd,
w.woptarg.unwrap()
));
return STATUS_INVALID_ARGS; return STATUS_INVALID_ARGS;
}; };
opts.events.push(EventDescription::Signal { signal }); opts.events.push(EventDescription::Signal { signal });

View file

@ -257,7 +257,11 @@ fn parse_cmd_opts(
return STATUS_CMD_ERROR; return STATUS_CMD_ERROR;
} }
let Ok(job_mode) = w.woptarg.unwrap().try_into() else { let Ok(job_mode) = w.woptarg.unwrap().try_into() else {
streams.err.append(wgettext_fmt!("%ls: Invalid job control mode '%ls'\n", cmd, w.woptarg.unwrap())); streams.err.append(wgettext_fmt!(
"%ls: Invalid job control mode '%ls'\n",
cmd,
w.woptarg.unwrap()
));
return STATUS_CMD_ERROR; return STATUS_CMD_ERROR;
}; };
opts.new_job_control_mode = Some(job_mode); opts.new_job_control_mode = Some(job_mode);
@ -398,7 +402,11 @@ pub fn status(
return STATUS_INVALID_ARGS; return STATUS_INVALID_ARGS;
} }
let Ok(new_mode) = args[0].try_into() else { let Ok(new_mode) = args[0].try_into() else {
streams.err.append(wgettext_fmt!("%ls: Invalid job control mode '%ls'\n", cmd, args[0])); streams.err.append(wgettext_fmt!(
"%ls: Invalid job control mode '%ls'\n",
cmd,
args[0]
));
return STATUS_CMD_ERROR; return STATUS_CMD_ERROR;
}; };
new_mode new_mode

View file

@ -224,7 +224,9 @@ fn path_is_executable(path: &wstr) -> bool {
return false; return false;
} }
let narrow: Vec<u8> = narrow.into(); let narrow: Vec<u8> = narrow.into();
let Ok(md) = std::fs::metadata(OsStr::from_bytes(&narrow)) else { return false; }; let Ok(md) = std::fs::metadata(OsStr::from_bytes(&narrow)) else {
return false;
};
md.is_file() md.is_file()
} }
@ -240,7 +242,9 @@ pub fn path_get_paths(cmd: &wstr, vars: &dyn Environment) -> Vec<WString> {
return paths; return paths;
} }
let Some(path_var) = vars.get(L!("PATH")) else { return paths; }; let Some(path_var) = vars.get(L!("PATH")) else {
return paths;
};
for path in path_var.as_list() { for path in path_var.as_list() {
if path.is_empty() { if path.is_empty() {
continue; continue;

View file

@ -151,7 +151,8 @@ fn test_escape_no_printables() {
&random_string, &random_string,
EscapeStringStyle::Script(EscapeFlags::NO_PRINTABLES | EscapeFlags::NO_QUOTED), EscapeStringStyle::Script(EscapeFlags::NO_PRINTABLES | EscapeFlags::NO_QUOTED),
); );
let Some(unescaped_string) = unescape_string(&escaped_string, UnescapeStringStyle::default()) else { let Some(unescaped_string) = unescape_string(&escaped_string, UnescapeStringStyle::default())
else {
panic!("Failed to unescape string <{escaped_string}>"); panic!("Failed to unescape string <{escaped_string}>");
}; };

View file

@ -74,7 +74,9 @@ fn test_to_wstring() {
let mut val: i64 = 1; let mut val: i64 = 1;
loop { loop {
assert_eq!(val.to_wstring(), val.to_string()); assert_eq!(val.to_wstring(), val.to_string());
let Some(next) = val.checked_mul(-3) else { break; }; let Some(next) = val.checked_mul(-3) else {
break;
};
val = next; val = next;
} }
assert_eq!(u64::MAX.to_wstring(), "18446744073709551615"); assert_eq!(u64::MAX.to_wstring(), "18446744073709551615");

View file

@ -169,7 +169,9 @@ pub fn wrealpath(pathname: &wstr) -> Option<WString> {
canonicalize(".") canonicalize(".")
}; };
let Ok(narrow_result) = narrow_res else { return None; }; let Ok(narrow_result) = narrow_res else {
return None;
};
let pathsep_idx = pathsep_idx.map_or(0, |idx| idx + 1); let pathsep_idx = pathsep_idx.map_or(0, |idx| idx + 1);