chore: fix unnecessary_semicolon lint

I used this command:

```sh
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --all-features --allow-dirty
```
This commit is contained in:
Yuri Astrakhan 2025-07-09 00:50:17 -04:00 committed by Daniel Hofstetter
parent 9ee7962575
commit 4a2634989c
37 changed files with 95 additions and 96 deletions

View file

@ -630,7 +630,6 @@ missing_errors_doc = "allow" # 1572
missing_panics_doc = "allow" # 946
must_use_candidate = "allow" # 322
match_same_arms = "allow" # 204
unnecessary_semicolon = "allow" # 154
redundant_closure_for_method_calls = "allow" # 125
cast_possible_truncation = "allow" # 122
too_many_lines = "allow" # 101

View file

@ -670,7 +670,7 @@ fn write_tab_to_end<W: Write>(mut in_buf: &[u8], writer: &mut W) -> usize {
writer.write_all(in_buf).unwrap();
return in_buf.len() + count;
}
};
}
}
}

View file

@ -338,7 +338,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match matches.get_many::<OsString>(options::FILE) {
Some(files) => cksum(opts, files.map(OsStr::new))?,
None => cksum(opts, iter::once(OsStr::new("-")))?,
};
}
Ok(())
}

View file

@ -819,7 +819,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
CpError::NotAllFilesCopied => {}
// Else we caught a fatal bubbled-up error, log it to stderr
_ => show_error!("{error}"),
};
}
set_exit_code(EXIT_ERR);
}
@ -1046,7 +1046,7 @@ impl Options {
if !dir.is_dir() {
return Err(CpError::NotADirectory(dir.clone()));
}
};
}
// cp follows POSIX conventions for overriding options such as "-a",
// "-d", "--preserve", and "--no-preserve". We can use clap's
// override-all behavior to achieve this, but there's a challenge: when
@ -1648,7 +1648,7 @@ fn handle_preserve<F: Fn() -> CopyResult<()>>(p: &Preserve, f: F) -> CopyResult<
show_error_if_needed(&error);
}
}
};
}
Ok(())
}
@ -2314,7 +2314,7 @@ fn handle_copy_mode(
.open(dest)
.unwrap();
}
};
}
Ok(PerformedAction::Copied)
}
@ -2513,7 +2513,7 @@ fn copy_file(
}
return Ok(());
};
}
}
// Calculate the context upfront before canonicalizing the path

View file

@ -204,10 +204,10 @@ where
(Err(err), _) => return Err(err),
// continue the splitting process
(Ok(()), _) => (),
};
}
}
}
};
}
}
Ok(())
}
@ -429,7 +429,7 @@ impl SplitWriter<'_> {
self.writeln(&line)?;
}
_ => (),
};
}
offset -= 1;
// write the extra lines required by the offset
@ -444,7 +444,7 @@ impl SplitWriter<'_> {
pattern_as_str.to_string(),
));
}
};
}
offset -= 1;
}
self.finish_split();
@ -726,7 +726,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 1);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((1, Ok(line))) => {
@ -735,7 +735,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 2);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((2, Ok(line))) => {
@ -747,7 +747,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 2);
}
item => panic!("wrong item: {item:?}"),
};
}
input_splitter.rewind_buffer();
@ -757,7 +757,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 1);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((2, Ok(line))) => {
@ -765,7 +765,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 0);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((3, Ok(line))) => {
@ -773,7 +773,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 0);
}
item => panic!("wrong item: {item:?}"),
};
}
assert!(input_splitter.next().is_none());
}
@ -799,7 +799,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 1);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((1, Ok(line))) => {
@ -808,7 +808,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 2);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((2, Ok(line))) => {
@ -817,7 +817,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 3);
}
item => panic!("wrong item: {item:?}"),
};
}
input_splitter.rewind_buffer();
@ -828,7 +828,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 3);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((0, Ok(line))) => {
@ -836,7 +836,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 2);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((1, Ok(line))) => {
@ -844,7 +844,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 1);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((2, Ok(line))) => {
@ -852,7 +852,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 0);
}
item => panic!("wrong item: {item:?}"),
};
}
match input_splitter.next() {
Some((3, Ok(line))) => {
@ -860,7 +860,7 @@ mod tests {
assert_eq!(input_splitter.buffer_len(), 0);
}
item => panic!("wrong item: {item:?}"),
};
}
assert!(input_splitter.next().is_none());
}

View file

@ -207,15 +207,15 @@ mod tests {
match patterns.first() {
Some(Pattern::UpToLine(24, ExecutePattern::Times(1))) => (),
_ => panic!("expected UpToLine pattern"),
};
}
match patterns.get(1) {
Some(Pattern::UpToLine(42, ExecutePattern::Always)) => (),
_ => panic!("expected UpToLine pattern"),
};
}
match patterns.get(2) {
Some(Pattern::UpToLine(50, ExecutePattern::Times(5))) => (),
_ => panic!("expected UpToLine pattern"),
};
}
}
#[test]
@ -242,42 +242,42 @@ mod tests {
assert_eq!(parsed_reg, "test1.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
match patterns.get(1) {
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Always)) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test2.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
match patterns.get(2) {
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Times(5))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test3.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
match patterns.get(3) {
Some(Pattern::UpToMatch(reg, 3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test4.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
match patterns.get(4) {
Some(Pattern::UpToMatch(reg, 3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test5.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
match patterns.get(5) {
Some(Pattern::UpToMatch(reg, -3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test6.*end$");
}
_ => panic!("expected UpToMatch pattern"),
};
}
}
#[test]
@ -304,42 +304,42 @@ mod tests {
assert_eq!(parsed_reg, "test1.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
match patterns.get(1) {
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Always)) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test2.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
match patterns.get(2) {
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Times(5))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test3.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
match patterns.get(3) {
Some(Pattern::SkipToMatch(reg, 3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test4.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
match patterns.get(4) {
Some(Pattern::SkipToMatch(reg, 3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test5.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
match patterns.get(5) {
Some(Pattern::SkipToMatch(reg, -3, ExecutePattern::Times(1))) => {
let parsed_reg = format!("{reg}");
assert_eq!(parsed_reg, "test6.*end$");
}
_ => panic!("expected SkipToMatch pattern"),
};
}
}
#[test]

View file

@ -81,7 +81,7 @@ mod tests {
match split_name {
Err(CsplitError::InvalidNumber(_)) => (),
_ => panic!("should fail with InvalidNumber"),
};
}
}
#[test]
@ -90,7 +90,7 @@ mod tests {
match split_name {
Err(CsplitError::SuffixFormatIncorrect) => (),
_ => panic!("should fail with SuffixFormatIncorrect"),
};
}
}
#[test]
@ -99,7 +99,7 @@ mod tests {
match split_name {
Err(CsplitError::SuffixFormatIncorrect) => (),
_ => panic!("should fail with SuffixFormatIncorrect"),
};
}
}
#[test]
@ -244,6 +244,6 @@ mod tests {
match split_name {
Err(CsplitError::SuffixFormatTooManyPercents) => (),
_ => panic!("should fail with SuffixFormatTooManyPercents"),
};
}
}
}

View file

@ -368,7 +368,7 @@ impl<'a> Input<'a> {
),
));
}
};
}
if settings.skip > 0 {
src.skip(settings.skip)?;
}
@ -1105,7 +1105,7 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
output_thread,
truncate,
);
};
}
// Create a common buffer with a capacity of the block size.
// This is the max size needed.

View file

@ -111,7 +111,7 @@ impl<'a> SplitIterator<'a> {
(None, Some(default)) => {
self.expander.put_native_string(default);
}
};
}
Ok(())
}

View file

@ -87,7 +87,7 @@ impl<'a> VariableParser<'a, '_> {
c.to_string(),
));
}
};
}
}
let default_opt = if let Some(default_end) = default_end {
@ -119,7 +119,7 @@ impl<'a> VariableParser<'a, '_> {
self.skip_one()?;
}
Some(_) => break,
};
}
}
let pos_end = self.parser.get_peek_position();

View file

@ -405,7 +405,7 @@ fn expand_line(
output.write_all(&options.tspaces.as_bytes()[..nts])?;
} else {
output.write_all(" ".repeat(nts).as_bytes())?;
};
}
} else {
output.write_all(&buf[byte..byte + nbytes])?;
}

View file

@ -110,7 +110,7 @@ impl NumericOp {
Self::Mod => {
if a.checked_div(&b).is_none() {
return Err(ExprError::DivisionByZero);
};
}
a % b
}
}))

View file

@ -169,7 +169,7 @@ impl FmtOptions {
return Err(FmtError::InvalidTabWidth(s.clone()).into());
}
};
};
}
if tabwidth < 1 {
tabwidth = 1;

View file

@ -136,7 +136,7 @@ fn create_algorithm_from_flags(matches: &ArgMatches) -> UResult<HashAlgorithm> {
bits: *bits,
})?,
None => return Err(ChecksumError::BitsRequiredForShake128.into()),
};
}
}
if matches.get_flag("shake256") {
match matches.get_one::<usize>("bits") {
@ -146,7 +146,7 @@ fn create_algorithm_from_flags(matches: &ArgMatches) -> UResult<HashAlgorithm> {
bits: *bits,
})?,
None => return Err(ChecksumError::BitsRequiredForShake256.into()),
};
}
}
if alg.is_none() {

View file

@ -395,7 +395,7 @@ where
assert_eq!(lines, 0);
lines = 1;
}
};
}
}
for separator_offset in memrchr_iter(separator, &buffer[..]) {

View file

@ -231,7 +231,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// BSD's `id` ignores all but the first specified user
pline(possible_pw.as_ref().map(|v| v.uid));
return Ok(());
};
}
if matches.get_flag(options::OPT_HUMAN_READABLE) {
// BSD's `id` ignores all but the first specified user
pretty(possible_pw);

View file

@ -1087,11 +1087,11 @@ fn exec<Sep: Separator>(file1: &str, file2: &str, settings: Settings, sep: Sep)
if let Err(e) = state1.finalize(&mut writer, &input, &repr) {
writer.flush()?;
return Err(e);
};
}
if let Err(e) = state2.finalize(&mut writer, &input, &repr) {
writer.flush()?;
return Err(e);
};
}
writer.flush()?;

View file

@ -303,7 +303,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
])
)
);
};
}
}
#[cfg(windows)]
if target_dir.is_dir() {
@ -321,7 +321,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
])
)
);
};
}
}
target_dir.to_path_buf()
} else {
@ -433,17 +433,17 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> UResult<()> {
return Err(LnError::SomeLinksFailed.into());
}
if fs::remove_file(dst).is_ok() {};
if fs::remove_file(dst).is_ok() {}
// In case of error, don't do anything
}
OverwriteMode::Force => {
if !dst.is_symlink() && paths_refer_to_same_file(src, dst, true) {
return Err(LnError::SameFile(src.to_owned(), dst.to_owned()).into());
}
if fs::remove_file(dst).is_ok() {};
if fs::remove_file(dst).is_ok() {}
// In case of error, don't do anything
}
};
}
}
if settings.symbolic {

View file

@ -2272,7 +2272,7 @@ fn enter_directory(
let entry_path_data =
PathData::new(dir_entry.path(), Some(Ok(dir_entry)), None, config, false);
entries.push(entry_path_data);
};
}
}
sort_entries(&mut entries, config, &mut state.out);
@ -2460,7 +2460,7 @@ fn display_additional_leading_info(
write!(result, "{s} ").unwrap();
} else {
write!(result, "{} ", pad_left(&s, padding.block_size)).unwrap();
};
}
}
Ok(result)
}
@ -2594,7 +2594,7 @@ fn display_items(
write!(state.out, "{}", config.line_ending)?;
}
}
};
}
}
Ok(())
@ -2814,7 +2814,7 @@ fn display_item_long(
padding.minor,
);
}
};
}
output_display.extend(b" ");
display_date(md, config, state, &mut output_display)?;

View file

@ -570,7 +570,7 @@ impl<'a> Pager<'a> {
fn handle_pattern_search(&mut self) -> UResult<()> {
if self.pattern.is_none() {
return Ok(());
};
}
match self.search_pattern_in_file() {
Some(line) => self.upper_mark = line,
None => {
@ -769,7 +769,7 @@ impl<'a> Pager<'a> {
fn page_resize(&mut self, _col: u16, row: u16, option_line: Option<u16>) {
if option_line.is_none() {
self.content_rows = row.saturating_sub(1) as usize;
};
}
}
fn draw(&mut self, wrong_key: Option<char>) -> UResult<()> {
@ -808,7 +808,7 @@ impl<'a> Pager<'a> {
pattern,
&format!("{}{pattern}{}", Attribute::Reverse, Attribute::Reset),
);
};
}
self.stdout.write_all(format!("\r{line}\n").as_bytes())?;
lines_printed += 1;
index += 1;

View file

@ -406,7 +406,7 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
}
}
OverwriteMode::Force => {}
};
}
Err(MvError::NonDirectoryToDirectory(
source.quote().to_string(),
target.quote().to_string(),
@ -672,7 +672,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, options: &Options)
match multi_progress {
Some(ref pb) => pb.suspend(|| show!(e)),
None => show!(e),
};
}
}
Ok(()) => (),
}
@ -749,7 +749,7 @@ fn rename(
}
}
OverwriteMode::Force => {}
};
}
backup_path = backup_control::get_backup_path(opts.backup, to, &opts.suffix);
if let Some(ref backup_path) = backup_path {
@ -805,7 +805,7 @@ fn rename(
println!("{message}");
}),
None => println!("{message}"),
};
}
}
Ok(())
}

View file

@ -346,7 +346,7 @@ fn nl<T: Read>(reader: &mut BufReader<T>, stats: &mut Stats, settings: &Settings
stats.consecutive_empty_lines += 1;
} else {
stats.consecutive_empty_lines = 0;
};
}
let new_numbering_style = match SectionDelimiter::parse(&line, &settings.section_delimiter)
{

View file

@ -72,7 +72,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if unsafe { !_vprocmgr_detach_from_console(0).is_null() } {
return Err(NohupError::CannotDetach.into());
};
}
let cstrs: Vec<CString> = matches
.get_many::<String>(options::CMD)

View file

@ -84,7 +84,7 @@ fn format_and_handle_validation(input_line: &str, options: &NumfmtOptions) -> UR
show_error!("{error_message}");
}
InvalidModes::Ignore => {}
};
}
println!("{input_line}");
}

View file

@ -541,7 +541,7 @@ where
input_offset.print_final_offset();
return Err(1.into());
}
};
}
}
if input_decoder.has_error() {

View file

@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match item?.write(stdout(), &mut args)? {
ControlFlow::Continue(()) => {}
ControlFlow::Break(()) => return Ok(()),
};
}
}
args.start_next_batch();
@ -74,7 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match item?.write(stdout(), &mut args)? {
ControlFlow::Continue(()) => {}
ControlFlow::Break(()) => return Ok(()),
};
}
}
args.start_next_batch();
}

View file

@ -76,7 +76,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
HashMap::from([("arg".to_string(), second_file.quote().to_string())]),
),
));
};
}
Mode::Default(file.into())
};

View file

@ -75,7 +75,7 @@ fn sleep(args: &[&str]) -> UResult<()> {
if arg_error {
return Err(UUsageError::new(1, ""));
};
}
thread::sleep(sleep_dur);
Ok(())
}

View file

@ -1312,7 +1312,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
{
settings.check_silent = true;
settings.check = true;
};
}
settings.ignore_case = matches.get_flag(options::IGNORE_CASE);

View file

@ -1403,7 +1403,7 @@ where
// if there is nothing else to read - exit the loop
if num_bytes_read == 0 {
break;
};
}
let bytes = line.as_slice();
if let Some(chunk_number) = kth_chunk {

View file

@ -109,7 +109,7 @@ fn pad_and_print(result: &str, left: bool, width: usize, padding: Padding) {
(false, Padding::Space) => print!("{result:>width$}"),
(true, Padding::Zero) => print!("{result:0<width$}"),
(true, Padding::Space) => print!("{result:<width$}"),
};
}
}
#[derive(Debug)]

View file

@ -79,7 +79,7 @@ fn open(name: &str) -> UResult<Box<dyn Read>> {
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
));
};
}
// Silent the warning as we want to the error message
if path.metadata().is_err() {
return Err(USimpleError::new(
@ -89,7 +89,7 @@ fn open(name: &str) -> UResult<Box<dyn Read>> {
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
));
};
}
let f = File::open(path).map_err_context(String::new)?;
Ok(Box::new(f) as Box<dyn Read>)
}

View file

@ -63,7 +63,7 @@ impl WatcherRx {
HashMap::from([("path".to_string(), path.display().to_string())]),
),
));
};
}
}
if path.is_relative() {
path = path.canonicalize()?;
@ -255,7 +255,7 @@ impl Observer {
watcher = Box::new(notify::PollWatcher::new(tx_clone, watcher_config).unwrap());
}
Err(e) => return Err(USimpleError::new(1, e.to_string())),
};
}
}
self.watcher_rx = Some(WatcherRx::new(watcher, rx));

View file

@ -310,7 +310,7 @@ fn tail_stdin(
observer.add_stdin(input.display_name.as_str(), Some(Box::new(reader)), true)?;
}
}
};
}
Ok(())
}

View file

@ -504,7 +504,7 @@ fn touch_file(
}
show!(e);
return Ok(());
};
}
// Minor optimization: if no reference time, timestamp, or date was specified, we're done.
if opts.source == Source::Now && opts.date.is_none() {
@ -924,6 +924,6 @@ mod tests {
Err(TouchError::InvalidFiletime(filetime)) => assert_eq!(filetime, invalid_filetime),
Err(e) => panic!("Expected TouchError::InvalidFiletime, got {e}"),
Ok(_) => panic!("Expected to error with TouchError::InvalidFiletime but succeeded"),
};
}
}
}

View file

@ -29,7 +29,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} else {
Err(1.into())
};
};
}
let mut stdout = std::io::stdout();
@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Don't return to prevent a panic later when another flush is attempted
// because the `uucore_procs::main` macro inserts a flush after execution for every utility.
std::process::exit(3);
};
}
Ok(())
}

View file

@ -69,7 +69,7 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
}
}
Err(_) => return Err(byte_count),
};
}
}
Ok(byte_count)