use semicolons if nothing returned

This commit is contained in:
Daniel Eades 2022-01-30 13:55:03 +01:00
parent a2d5f06be4
commit 784f2e2ea1
56 changed files with 125 additions and 127 deletions

View file

@ -77,7 +77,7 @@ pub fn main() {
)
.as_bytes(),
)
.unwrap()
.unwrap();
}
k if k.starts_with(override_prefix) => {
mf.write_all(
@ -97,7 +97,7 @@ pub fn main() {
)
.as_bytes(),
)
.unwrap()
.unwrap();
}
"false" | "true" => {
mf.write_all(
@ -116,7 +116,7 @@ pub fn main() {
)
.as_bytes(),
)
.unwrap()
.unwrap();
}
"hashsum" => {
mf.write_all(
@ -150,7 +150,7 @@ pub fn main() {
)
.as_bytes(),
)
.unwrap()
.unwrap();
}
_ => {
mf.write_all(
@ -169,7 +169,7 @@ pub fn main() {
)
.as_bytes(),
)
.unwrap()
.unwrap();
}
}
}

View file

@ -45,7 +45,7 @@ fn main() -> io::Result<()> {
} else {
println!("Error writing to {}", p);
}
writeln!(summary, "* [{0}](utils/{0}.md)", name)?
writeln!(summary, "* [{0}](utils/{0}.md)", name)?;
}
Ok(())
}

View file

@ -743,7 +743,7 @@ This almost certainly means that you have a corrupted file system.\n\
NOTIFY YOUR SYSTEM MANAGER.\n\
The following directory is part of the cycle {}.",
file_name.quote()
)
);
}
#[derive(Debug)]

View file

@ -742,7 +742,7 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec<S
if options.strip_trailing_slashes {
for source in paths.iter_mut() {
*source = source.components().as_path().to_owned()
*source = source.components().as_path().to_owned();
}
}
@ -864,7 +864,7 @@ fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResu
}
_ => {
show_error!("{}", error);
non_fatal_errors = true
non_fatal_errors = true;
}
}
}
@ -1580,5 +1580,5 @@ fn test_cp_localize_to_target() {
)
.unwrap()
== Path::new("target/c.txt")
)
);
}

View file

@ -491,14 +491,14 @@ pub fn parse_conv_flag_input(matches: &Matches) -> Result<IConvFlags, ParseError
if case.is_some() {
return Err(ParseError::MultipleUCaseLCase);
} else {
case = Some(flag)
case = Some(flag);
}
}
ConvFlag::LCase => {
if case.is_some() {
return Err(ParseError::MultipleUCaseLCase);
} else {
case = Some(flag)
case = Some(flag);
}
}
ConvFlag::Block => match (cbs, iconvflags.unblock) {

View file

@ -56,10 +56,10 @@ fn unimplemented_flags_should_error() {
let matches = uu_app().try_get_matches_from(args).unwrap();
if parse_iflags(&matches).is_ok() {
succeeded.push(format!("iflag={}", flag))
succeeded.push(format!("iflag={}", flag));
}
if parse_oflags(&matches).is_ok() {
succeeded.push(format!("oflag={}", flag))
succeeded.push(format!("oflag={}", flag));
}
}

View file

@ -127,7 +127,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let result;
if files.is_empty() {
result = parse(INTERNAL_DB.lines(), &out_format, "")
result = parse(INTERNAL_DB.lines(), &out_format, "");
} else {
if files.len() > 1 {
return Err(UUsageError::new(
@ -138,7 +138,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match File::open(files[0]) {
Ok(f) => {
let fin = BufReader::new(f);
result = parse(fin.lines().filter_map(Result::ok), &out_format, files[0])
result = parse(fin.lines().filter_map(Result::ok), &out_format, files[0]);
}
Err(e) => {
return Err(USimpleError::new(

View file

@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match p.parent() {
Some(d) => {
if d.components().next() == None {
print!(".")
print!(".");
} else {
print_verbatim(d).unwrap();
}

View file

@ -335,7 +335,7 @@ fn du(
ErrorKind::PermissionDenied => {
let description = format!("cannot access {}", entry.path().quote());
let error_message = "Permission denied";
show_error_custom_description!(description, "{}", error_message)
show_error_custom_description!(description, "{}", error_message);
}
_ => show_error!("cannot access {}: {}", entry.path().quote(), error),
},
@ -486,7 +486,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if options.inodes
&& (matches.is_present(options::APPARENT_SIZE) || matches.is_present(options::BYTES))
{
show_warning!("options --apparent-size and -b are ineffective with --inodes")
show_warning!("options --apparent-size and -b are ineffective with --inodes");
}
let block_size = u64::try_from(read_block_size(matches.value_of(options::BLOCK_SIZE))).unwrap();

View file

@ -332,7 +332,7 @@ fn expand(options: &Options) -> std::io::Result<()> {
// now dump out either spaces if we're expanding, or a literal tab if we're not
if init || !options.iflag {
if nts <= options.tspaces.len() {
output.write_all(options.tspaces[..nts].as_bytes())?
output.write_all(options.tspaces[..nts].as_bytes())?;
} else {
output.write_all(" ".repeat(nts).as_bytes())?;
};

View file

@ -370,7 +370,7 @@ fn push_op_to_stack(
},
)) => {
if la && prev_prec >= prec || !la && prev_prec > prec {
out_stack.push(op_stack.pop().unwrap())
out_stack.push(op_stack.pop().unwrap());
} else {
op_stack.push((token_idx, token.clone()));
return Ok(());

View file

@ -155,8 +155,8 @@ fn push_token_if_not_escaped(acc: &mut Vec<(usize, Token)>, tok_idx: usize, toke
if should_use_as_escaped {
acc.pop();
acc.push((tok_idx, Token::new_value(s)))
acc.push((tok_idx, Token::new_value(s)));
} else {
acc.push((tok_idx, token))
acc.push((tok_idx, token));
}
}

View file

@ -34,7 +34,7 @@ impl Decomposition {
if let Some((_, e)) = self.0.iter_mut().find(|(f, _)| *f == factor) {
*e += exp;
} else {
self.0.push((factor, exp))
self.0.push((factor, exp));
}
}
@ -79,11 +79,11 @@ impl Factors {
pub fn add(&mut self, prime: u64, exp: Exponent) {
debug_assert!(miller_rabin::is_prime(prime));
self.0.borrow_mut().add(prime, exp)
self.0.borrow_mut().add(prime, exp);
}
pub fn push(&mut self, prime: u64) {
self.add(prime, 1)
self.add(prime, 1);
}
#[cfg(test)]
@ -99,7 +99,7 @@ impl fmt::Display for Factors {
for (p, exp) in v.iter() {
for _ in 0..*exp {
write!(f, " {}", p)?
write!(f, " {}", p)?;
}
}

View file

@ -384,7 +384,7 @@ fn build_best_path<'a>(paths: &[LineBreak<'a>], active: &[usize]) -> Vec<(&'a Wo
None => return breakwords,
Some(prev) => {
breakwords.push((prev, next_best.break_before));
best_idx = next_best.prev
best_idx = next_best.prev;
}
}
}

View file

@ -44,7 +44,7 @@ impl Digest for md5::Context {
}
fn input(&mut self, input: &[u8]) {
self.consume(input)
self.consume(input);
}
fn result(&mut self, out: &mut [u8]) {

View file

@ -173,28 +173,28 @@ fn detect_algo(
};
name = n;
alg = Some(val);
output_bits = bits
output_bits = bits;
};
if matches.is_present("md5") {
set_or_crash("MD5", Box::new(Md5::new()), 128)
set_or_crash("MD5", Box::new(Md5::new()), 128);
}
if matches.is_present("sha1") {
set_or_crash("SHA1", Box::new(Sha1::new()), 160)
set_or_crash("SHA1", Box::new(Sha1::new()), 160);
}
if matches.is_present("sha224") {
set_or_crash("SHA224", Box::new(Sha224::new()), 224)
set_or_crash("SHA224", Box::new(Sha224::new()), 224);
}
if matches.is_present("sha256") {
set_or_crash("SHA256", Box::new(Sha256::new()), 256)
set_or_crash("SHA256", Box::new(Sha256::new()), 256);
}
if matches.is_present("sha384") {
set_or_crash("SHA384", Box::new(Sha384::new()), 384)
set_or_crash("SHA384", Box::new(Sha384::new()), 384);
}
if matches.is_present("sha512") {
set_or_crash("SHA512", Box::new(Sha512::new()), 512)
set_or_crash("SHA512", Box::new(Sha512::new()), 512);
}
if matches.is_present("b2sum") {
set_or_crash("BLAKE2", Box::new(blake2b_simd::State::new()), 512)
set_or_crash("BLAKE2", Box::new(blake2b_simd::State::new()), 512);
}
if matches.is_present("sha3") {
match matches.value_of("bits") {
@ -229,16 +229,16 @@ fn detect_algo(
}
}
if matches.is_present("sha3-224") {
set_or_crash("SHA3-224", Box::new(Sha3_224::new()), 224)
set_or_crash("SHA3-224", Box::new(Sha3_224::new()), 224);
}
if matches.is_present("sha3-256") {
set_or_crash("SHA3-256", Box::new(Sha3_256::new()), 256)
set_or_crash("SHA3-256", Box::new(Sha3_256::new()), 256);
}
if matches.is_present("sha3-384") {
set_or_crash("SHA3-384", Box::new(Sha3_384::new()), 384)
set_or_crash("SHA3-384", Box::new(Sha3_384::new()), 384);
}
if matches.is_present("sha3-512") {
set_or_crash("SHA3-512", Box::new(Sha3_512::new()), 512)
set_or_crash("SHA3-512", Box::new(Sha3_512::new()), 512);
}
if matches.is_present("shake128") {
match matches.value_of("bits") {

View file

@ -424,7 +424,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
if !first {
println!();
}
println!("==> standard input <==")
println!("==> standard input <==");
}
let stdin = std::io::stdin();
let mut stdin = stdin.lock();
@ -460,7 +460,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
if !first {
println!();
}
println!("==> {} <==", name)
println!("==> {} <==", name);
}
head_file(&mut file, options)
}

View file

@ -43,11 +43,11 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
// this also saves us 1 heap allocation
'q' => {
quiet = true;
verbose = false
verbose = false;
}
'v' => {
verbose = true;
quiet = false
quiet = false;
}
'z' => zero_terminated = true,
'c' => multiplier = Some(1),
@ -58,20 +58,20 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
_ => return Some(Err(ParseError::Syntax)),
}
if let Some((_, next)) = chars.next() {
c = next
c = next;
} else {
break;
}
}
let mut options = Vec::new();
if quiet {
options.push(OsString::from("-q"))
options.push(OsString::from("-q"));
}
if verbose {
options.push(OsString::from("-v"))
options.push(OsString::from("-v"));
}
if zero_terminated {
options.push(OsString::from("-z"))
options.push(OsString::from("-z"));
}
if let Some(n) = multiplier {
options.push(OsString::from("-c"));

View file

@ -308,7 +308,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
if is_symlink(target_dir) {
if target_dir.is_file() {
if let Err(e) = fs::remove_file(target_dir) {
show_error!("Could not update {}: {}", target_dir.quote(), e)
show_error!("Could not update {}: {}", target_dir.quote(), e);
};
}
if target_dir.is_dir() {
@ -316,7 +316,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
// considered as a dir
// See test_ln::test_symlink_no_deref_dir
if let Err(e) = fs::remove_dir(target_dir) {
show_error!("Could not update {}: {}", target_dir.quote(), e)
show_error!("Could not update {}: {}", target_dir.quote(), e);
};
}
}
@ -402,7 +402,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> Result<()> {
if !read_yes() {
return Ok(());
}
fs::remove_file(dst)?
fs::remove_file(dst)?;
}
OverwriteMode::Force => fs::remove_file(dst)?,
};

View file

@ -118,7 +118,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
if matches.is_present(OPT_T) {
tmpdir = env::temp_dir()
tmpdir = env::temp_dir();
}
let res = if dry_run {

View file

@ -305,7 +305,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR
sourcepath.quote(),
targetpath.quote()
))
)
);
}
Ok(())
}
@ -340,7 +340,7 @@ fn rename(from: &Path, to: &Path, b: &Behavior) -> io::Result<()> {
// normalize behavior between *nix and windows
if from.is_dir() {
if is_empty_dir(to) {
fs::remove_dir(to)?
fs::remove_dir(to)?;
} else {
return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty"));
}

View file

@ -60,7 +60,7 @@ impl<'b> MultifileReader<'b> {
// then move on the the next file.
// This matches the behavior of the original `od`
show_error!("{}: {}", fname.maybe_quote(), e);
self.any_err = true
self.any_err = true;
}
}
}

View file

@ -138,7 +138,7 @@ pub fn parse_format_flags(args: &[String]) -> Result<Vec<ParsedFormatterItemInfo
} else {
// not every option is a format
if let Some(r) = od_argument_traditional_format(c) {
formats.push(ParsedFormatterItemInfo::new(r, false))
formats.push(ParsedFormatterItemInfo::new(r, false));
}
}
}

View file

@ -210,9 +210,9 @@ impl Capitalize for str {
self.char_indices()
.fold(String::with_capacity(self.len()), |mut acc, x| {
if x.0 != 0 {
acc.push(x.1)
acc.push(x.1);
} else {
acc.push(x.1.to_ascii_uppercase())
acc.push(x.1.to_ascii_uppercase());
}
acc
})
@ -324,12 +324,10 @@ impl Pinky {
self.print_heading();
}
for ut in Utmpx::iter_all_records() {
if ut.is_user_process() {
if self.names.is_empty() {
self.print_entry(&ut)?
} else if self.names.iter().any(|n| n.as_str() == ut.user()) {
self.print_entry(&ut)?;
}
if ut.is_user_process()
&& (self.names.is_empty() || self.names.iter().any(|n| n.as_str() == ut.user()))
{
self.print_entry(&ut)?;
}
}
Ok(())

View file

@ -275,7 +275,7 @@ fn read_input(input_files: &[String], config: &Config) -> std::io::Result<FileMa
offset,
},
);
offset += size
offset += size;
}
Ok(file_map)
}

View file

@ -96,7 +96,7 @@ impl Iterator for FilenameGenerator {
}
if name_charset_indices[0] == NAME_CHARSET.len() - 1 {
self.exhausted.set(true)
self.exhausted.set(true);
}
// Now increment the least significant index
for i in (0..self.name_len).rev() {
@ -478,7 +478,7 @@ fn wipe_file(
if n_passes <= 3 {
// Only random passes if n_passes <= 3
for _ in 0..n_passes {
pass_sequence.push(PassType::Random)
pass_sequence.push(PassType::Random);
}
}
// First fill it with Patterns, shuffle it, then evenly distribute Random

View file

@ -57,7 +57,7 @@ impl<R: Read> RngCore for ReadRng<R> {
panic!(
"reading random bytes from Read implementation failed; error: {}",
err
)
);
});
}

View file

@ -159,7 +159,7 @@ fn reader_writer<
fn sorter(receiver: &Receiver<Chunk>, sender: &SyncSender<Chunk>, settings: &GlobalSettings) {
while let Ok(mut payload) = receiver.recv() {
payload.with_contents_mut(|contents| {
sort_by(&mut contents.lines, settings, &contents.line_data)
sort_by(&mut contents.lines, settings, &contents.line_data);
});
if sender.send(payload).is_err() {
// The receiver has gone away, likely because the other thread hit an error.

View file

@ -50,7 +50,7 @@ fn replace_output_file_in_input_files(
std::fs::copy(file_path, &copy_path)
.map_err(|error| SortError::OpenTmpFileFailed { error })?;
*file = copy_path.clone().into_os_string();
copy = Some(copy_path)
copy = Some(copy_path);
}
}
}
@ -187,7 +187,7 @@ fn merge_without_limit<M: MergeInput + 'static, F: Iterator<Item = UResult<M>>>(
file_number,
line_idx: 0,
receiver,
})
});
}
}

View file

@ -535,7 +535,7 @@ impl<'a> Line<'a> {
}
Selection::Str(str) => {
if selector.needs_selection {
line_data.selections.push(str)
line_data.selections.push(str);
}
}
}
@ -701,9 +701,9 @@ impl<'a> Line<'a> {
fn tokenize(line: &str, separator: Option<char>, token_buffer: &mut Vec<Field>) {
assert!(token_buffer.is_empty());
if let Some(separator) = separator {
tokenize_with_separator(line, separator, token_buffer)
tokenize_with_separator(line, separator, token_buffer);
} else {
tokenize_default(line, token_buffer)
tokenize_default(line, token_buffer);
}
}
@ -1232,7 +1232,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
),
));
}
settings.separator = Some(separator.chars().next().unwrap())
settings.separator = Some(separator.chars().next().unwrap());
}
if let Some(values) = matches.values_of(options::KEY) {
@ -1524,9 +1524,9 @@ fn exec(
fn sort_by<'a>(unsorted: &mut Vec<Line<'a>>, settings: &GlobalSettings, line_data: &LineData<'a>) {
if settings.stable || settings.unique {
unsorted.par_sort_by(|a, b| compare_by(a, b, settings, line_data, line_data))
unsorted.par_sort_by(|a, b| compare_by(a, b, settings, line_data, line_data));
} else {
unsorted.par_sort_unstable_by(|a, b| compare_by(a, b, settings, line_data, line_data))
unsorted.par_sort_unstable_by(|a, b| compare_by(a, b, settings, line_data, line_data));
}
}

View file

@ -55,7 +55,7 @@ impl Drop for WithEnvVarSet {
if let Ok(ref prev_value) = self._previous_var_value {
env::set_var(&self._previous_var_key, &prev_value);
} else {
env::remove_var(&self._previous_var_key)
env::remove_var(&self._previous_var_key);
}
}
}

View file

@ -406,7 +406,7 @@ impl Stater {
flag,
precision,
format: chars[i],
})
});
}
'\\' => {
if !use_printf {

View file

@ -42,11 +42,11 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
// this also saves us 1 heap allocation
'q' => {
quiet = true;
verbose = false
verbose = false;
}
'v' => {
verbose = true;
quiet = false
quiet = false;
}
'z' => zero_terminated = true,
'c' => multiplier = Some(1),
@ -57,20 +57,20 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
_ => return Some(Err(ParseError::Syntax)),
}
if let Some((_, next)) = chars.next() {
c = next
c = next;
} else {
break;
}
}
let mut options = Vec::new();
if quiet {
options.push(OsString::from("-q"))
options.push(OsString::from("-q"));
}
if verbose {
options.push(OsString::from("-v"))
options.push(OsString::from("-v"));
}
if zero_terminated {
options.push(OsString::from("-z"))
options.push(OsString::from("-z"));
}
if let Some(n) = multiplier {
options.push(OsString::from("-c"));

View file

@ -102,7 +102,7 @@ impl Settings {
if let Some(n) = matches.value_of(options::SLEEP_INT) {
let parsed: Option<u32> = n.parse().ok();
if let Some(m) = parsed {
settings.sleep_msec = m * 1000
settings.sleep_msec = m * 1000;
}
}
}

View file

@ -97,7 +97,7 @@ fn ignore_interrupts() -> Result<()> {
fn tee(options: &Options) -> Result<()> {
if options.ignore_interrupts {
ignore_interrupts()?
ignore_interrupts()?;
}
let mut writers: Vec<NamedWriter> = options
.files

View file

@ -178,7 +178,7 @@ fn print_uptime(upsecs: i64) {
match updays.cmp(&1) {
std::cmp::Ordering::Equal => print!("up {:1} day, {:2}:{:02}, ", updays, uphours, upmins),
std::cmp::Ordering::Greater => {
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins)
print!("up {:1} days, {:2}:{:02}, ", updays, uphours, upmins);
}
_ => print!("up {:2}:{:02}, ", uphours, upmins),
};

View file

@ -27,7 +27,7 @@ impl Add for WordCount {
impl AddAssign for WordCount {
fn add_assign(&mut self, other: Self) {
*self = *self + other
*self = *self + other;
}
}

View file

@ -351,7 +351,7 @@ impl Who {
let records = Utmpx::iter_all_records_from(f).peekable();
if self.include_heading {
self.print_heading()
self.print_heading();
}
let cur_tty = if self.my_line_only {
current_tty()

View file

@ -159,7 +159,7 @@ pub fn resolve_relative_path(path: &Path) -> Cow<Path> {
}
Component::CurDir => (),
Component::RootDir | Component::Normal(_) | Component::Prefix(_) => {
result.push(comp.as_os_str())
result.push(comp.as_os_str());
}
}
}

View file

@ -156,7 +156,7 @@ impl MountInfo {
// but set dev_id
if let Ok(stat) = std::fs::metadata(&self.mount_dir) {
// Why do we cast this to i32?
self.dev_id = (stat.dev() as i32).to_string()
self.dev_id = (stat.dev() as i32).to_string();
} else {
self.dev_id = "".to_string();
}

View file

@ -62,7 +62,7 @@ pub fn parse_symbolic(
// keep the setgid and setuid bits for directories
srwx |= fperm & (0o4000 | 0o2000);
}
fperm = (fperm & !mask) | (srwx & mask)
fperm = (fperm & !mask) | (srwx & mask);
}
_ => unreachable!(),
}
@ -113,7 +113,7 @@ fn parse_change(mode: &str, fperm: u32, considering_dir: bool) -> (u32, usize) {
'x' => srwx |= 0o111,
'X' => {
if considering_dir || (fperm & 0o0111) != 0 {
srwx |= 0o111
srwx |= 0o111;
}
}
's' => srwx |= 0o4000 | 0o2000,

View file

@ -296,9 +296,9 @@ impl ChownExecutor {
} else {
"Too many levels of symbolic links".into()
}
)
);
} else {
show_error!("{}", e)
show_error!("{}", e);
}
continue;
}
@ -450,7 +450,7 @@ pub fn chown_base<'a>(
.required(true)
.takes_value(true)
.multiple_occurrences(false),
)
);
}
app = app.arg(
Arg::new(options::ARG_FILES)

View file

@ -16,7 +16,7 @@ pub fn arrnum_int_mult(arr_num: &[u8], basenum: u8, base_ten_int_fact: u8) -> Ve
new_amount = (u16::from(*u) * fact) + carry;
rem = new_amount % base;
carry = (new_amount - rem) / base;
ret_rev.push(rem as u8)
ret_rev.push(rem as u8);
}
None => {
while carry != 0 {
@ -119,7 +119,7 @@ pub fn arrnum_int_add(arrnum: &[u8], basenum: u8, base_ten_int_term: u8) -> Vec<
new_amount = u16::from(*u) + carry;
rem = new_amount % base;
carry = (new_amount - rem) / base;
ret_rev.push(rem as u8)
ret_rev.push(rem as u8);
}
None => {
while carry != 0 {
@ -170,7 +170,7 @@ pub fn base_conv_float(src: &[u8], radix_src: u8, _radix_dest: u8) -> f64 {
break;
}
factor /= radix_src_float;
r += factor * f64::from(*u)
r += factor * f64::from(*u);
}
r
}

View file

@ -283,10 +283,10 @@ impl SubParser {
}
} else {
if let Some(x) = n_ch {
it.put_back(x)
it.put_back(x);
};
if let Some(x) = preface {
it.put_back(x)
it.put_back(x);
};
false
}

View file

@ -227,7 +227,7 @@ impl UnescapedText {
new_vec.extend(tmp_str.bytes());
tmp_str = String::new();
}
UnescapedText::handle_escaped(new_vec, it, subs_mode)
UnescapedText::handle_escaped(new_vec, it, subs_mode);
}
x if x == '%' && !subs_mode => {
if let Some(follow) = it.next() {

View file

@ -97,7 +97,7 @@ pub fn get_utility_is_second_arg() -> bool {
}
pub fn set_utility_is_second_arg() {
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst)
crate::macros::UTILITY_IS_SECOND_ARG.store(true, Ordering::SeqCst);
}
// args_os() can be expensive to call, it copies all of argv before iterating.

View file

@ -36,7 +36,7 @@ pub fn mute_sigpipe_panic() {
let hook = panic::take_hook();
panic::set_hook(Box::new(move |info| {
if !is_broken_pipe(info) {
hook(info)
hook(info);
}
}));
}

View file

@ -461,9 +461,9 @@ fn set_file_context(path: impl AsRef<Path>, context: &str) -> Result<(), selinux
context,
path.display(),
r
)
);
} else {
println!("set_file_context: '{}' => '{}'.", context, path.display())
println!("set_file_context: '{}' => '{}'.", context, path.display());
}
r
}

View file

@ -48,7 +48,7 @@ mod test_passgrp {
#[test]
fn test_grp2gid() {
if cfg!(target_os = "linux") || cfg!(target_os = "android") || cfg!(target_os = "windows") {
assert_eq!(0, grp2gid("root").unwrap())
assert_eq!(0, grp2gid("root").unwrap());
} else {
assert_eq!(0, grp2gid("wheel").unwrap());
}

View file

@ -187,7 +187,7 @@ fn test_change_directory() {
.arg(pwd)
.succeeds()
.stdout_move_str();
assert_eq!(out.trim(), temporary_path.as_os_str())
assert_eq!(out.trim(), temporary_path.as_os_str());
}
#[cfg(windows)]

View file

@ -1551,7 +1551,7 @@ fn test_ls_inode() {
assert!(!re_long.is_match(result.stdout_str()));
assert!(!result.stdout_str().contains(inode_long));
assert_eq!(inode_short, inode_long)
assert_eq!(inode_short, inode_long);
}
#[test]
@ -1901,7 +1901,7 @@ fn test_ls_version_sort() {
assert_eq!(
result.stdout_str().split('\n').collect::<Vec<_>>(),
expected,
)
);
}
#[test]

View file

@ -75,7 +75,7 @@ fn test_symbolic_mode() {
ucmd.arg("-m").arg("a=rwx").arg(TEST_DIR1).succeeds();
let perms = at.metadata(TEST_DIR1).permissions().mode();
assert_eq!(perms, 0o40777)
assert_eq!(perms, 0o40777);
}
#[test]
@ -85,7 +85,7 @@ fn test_symbolic_alteration() {
ucmd.arg("-m").arg("-w").arg(TEST_DIR1).succeeds();
let perms = at.metadata(TEST_DIR1).permissions().mode();
assert_eq!(perms, 0o40555)
assert_eq!(perms, 0o40555);
}
#[test]
@ -98,5 +98,5 @@ fn test_multi_symbolic() {
.arg(TEST_DIR1)
.succeeds();
let perms = at.metadata(TEST_DIR1).permissions().mode();
assert_eq!(perms, 0o40750)
assert_eq!(perms, 0o40750);
}

View file

@ -91,7 +91,7 @@ fn test_head_count() {
result_seq.iter().all(|x| input_seq.contains(x)),
"Output includes element not from input: {}",
result.stdout_str()
)
);
}
#[test]
@ -129,7 +129,7 @@ fn test_repeat() {
.iter()
.filter(|x| !input_seq.contains(x))
.collect::<Vec<&i32>>()
)
);
}
#[test]

View file

@ -155,7 +155,7 @@ fn test_multiple_decimals_general() {
test_helper(
"multiple_decimals_general",
&["-g", "--general-numeric-sort", "--sort=general-numeric"],
)
);
}
#[test]
@ -163,7 +163,7 @@ fn test_multiple_decimals_numeric() {
test_helper(
"multiple_decimals_numeric",
&["-n", "--numeric-sort", "--sort=numeric"],
)
);
}
#[test]
@ -171,7 +171,7 @@ fn test_numeric_with_trailing_invalid_chars() {
test_helper(
"numeric_trailing_chars",
&["-n", "--numeric-sort", "--sort=numeric"],
)
);
}
#[test]
@ -588,7 +588,7 @@ fn test_keys_with_options_blanks_start() {
#[test]
fn test_keys_blanks_with_char_idx() {
test_helper("keys_blanks", &["-k 1.2b"])
test_helper("keys_blanks", &["-k 1.2b"]);
}
#[test]
@ -648,7 +648,7 @@ fn test_keys_negative_size_match() {
#[test]
fn test_keys_ignore_flag() {
test_helper("keys_ignore_flag", &["-k 1n -b"])
test_helper("keys_ignore_flag", &["-k 1n -b"]);
}
#[test]

View file

@ -27,7 +27,7 @@ fn get_symlink_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
}
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap()
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap();
}
// Adjusts for local timezone

View file

@ -241,7 +241,7 @@ impl CmdResult {
"stdout was {}\nExpected any of {:#?}",
self.stdout_str(),
expected
)
);
}
self
}
@ -419,14 +419,14 @@ impl CmdResult {
pub fn stdout_matches(&self, regex: &regex::Regex) -> &CmdResult {
if !regex.is_match(self.stdout_str().trim()) {
panic!("Stdout does not match regex:\n{}", self.stdout_str())
panic!("Stdout does not match regex:\n{}", self.stdout_str());
}
self
}
pub fn stdout_does_not_match(&self, regex: &regex::Regex) -> &CmdResult {
if regex.is_match(self.stdout_str().trim()) {
panic!("Stdout matches regex:\n{}", self.stdout_str())
panic!("Stdout matches regex:\n{}", self.stdout_str());
}
self
}
@ -1059,7 +1059,7 @@ impl UCommand {
.write_all(input);
if !self.ignore_stdin_write_error {
if let Err(e) = write_result {
panic!("failed to write to stdin of child: {}", e)
panic!("failed to write to stdin of child: {}", e);
}
}
}