Skip to content

Commit

Permalink
Fix clippy warnings with Rust 1.72.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cakebaker committed Aug 25, 2023
1 parent ffbfea4 commit 6f5610b
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ fn preserve_hardlinks(
let inode = get_inode(&info);
let nlinks = info.number_of_links();
let mut found_hard_link = false;
for (link, link_inode) in hard_links.iter() {
for (link, link_inode) in &*hard_links {
if *link_inode == inode {
// Consider the following files:
//
Expand Down Expand Up @@ -1212,7 +1212,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
None
};

for source in sources.iter() {
for source in sources {
if seen_sources.contains(source) {
// FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases)
show_warning!("source {} specified more than once", source.quote());
Expand Down
4 changes: 2 additions & 2 deletions src/uu/factor/src/factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl fmt::Display for Factors {
v.sort_unstable();

let include_exponents = f.alternate();
for (p, exp) in v.iter() {
for (p, exp) in &*v {
if include_exponents && *exp > 1 {
write!(f, " {p}^{exp}")?;
} else {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl std::ops::BitXor<Exponent> for Factors {
fn bitxor(self, rhs: Exponent) -> Self {
debug_assert_ne!(rhs, 0);
let mut r = Self::one();
for (p, e) in self.0.borrow().0.iter() {
for (p, e) in &self.0.borrow().0 {
r.add(*p, rhs * e);
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/factor/src/miller_rabin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub(crate) fn test<A: Arithmetic + Basis>(m: A) -> Result {
let one = m.one();
let minus_one = m.minus_one();

'witness: for _a in A::BASIS.iter() {
'witness: for _a in A::BASIS {
let _a = _a % n;
if _a == 0 {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/fmt/src/linebreak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>(
next_active_breaks.clear();
// go through each active break, extending it and possibly adding a new active
// break if we are above the minimum required length
for &i in active_breaks.iter() {
for &i in &*active_breaks {
let active = &mut linebreaks[i];
// normalize demerits to avoid overflow, and record if this is the least
active.demerits -= least_demerits;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
}

let mut all_successful = true;
for srcpath in files.iter() {
for srcpath in files {
let targetpath =
if settings.no_dereference && matches!(settings.overwrite, OverwriteMode::Force) {
// In that case, we don't want to do link resolution
Expand Down
2 changes: 1 addition & 1 deletion src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub fn dry_exec(tmpdir: &str, prefix: &str, rand: usize, suffix: &str) -> UResul
// Randomize.
let bytes = &mut buf[prefix.len()..prefix.len() + rand];
rand::thread_rng().fill(bytes);
for byte in bytes.iter_mut() {
for byte in &mut *bytes {
*byte = match *byte % 62 {
v @ 0..=9 => v + b'0',
v @ 10..=35 => v - 10 + b'a',
Expand Down
4 changes: 2 additions & 2 deletions src/uu/ptx/src/ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) ->
let reg = Regex::new(&filter.word_regex).unwrap();
let ref_reg = Regex::new(&config.context_regex).unwrap();
let mut word_set: BTreeSet<WordRef> = BTreeSet::new();
for (file, lines) in file_map.iter() {
for (file, lines) in file_map {
let mut count: usize = 0;
let offs = lines.offset;
for line in &lines.lines {
Expand Down Expand Up @@ -654,7 +654,7 @@ fn write_traditional_output(

let context_reg = Regex::new(&config.context_regex).unwrap();

for word_ref in words.iter() {
for word_ref in words {
let file_map_value: &FileContent = file_map
.get(&(word_ref.filename))
.expect("Missing file in file map");
Expand Down
4 changes: 2 additions & 2 deletions src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ impl Stater {
Ok(meta) => {
let tokens = &self.default_tokens;

for t in tokens.iter() {
for t in tokens {
match *t {
Token::Char(c) => print!("{c}"),
Token::Directive {
Expand Down Expand Up @@ -701,7 +701,7 @@ impl Stater {
&self.default_dev_tokens
};

for t in tokens.iter() {
for t in tokens {
match *t {
Token::Char(c) => print!("{c}"),
Token::Directive {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Graph {
self.result.push(n.clone());

let n_out_edges = self.out_edges.get_mut(&n).unwrap();
for m in n_out_edges.iter() {
for m in &*n_out_edges {
let m_in_edges = self.in_edges.get_mut(m).unwrap();
m_in_edges.remove(&n);

Expand Down
6 changes: 3 additions & 3 deletions src/uucore/src/lib/features/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Digest for CRC {
}

fn hash_update(&mut self, input: &[u8]) {
for &elt in input.iter() {
for &elt in input {
self.update(elt);
}
self.size += input.len();
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Digest for BSD {
}

fn hash_update(&mut self, input: &[u8]) {
for &byte in input.iter() {
for &byte in input {
self.state = (self.state >> 1) + ((self.state & 1) << 15);
self.state = self.state.wrapping_add(u16::from(byte));
}
Expand Down Expand Up @@ -257,7 +257,7 @@ impl Digest for SYSV {
}

fn hash_update(&mut self, input: &[u8]) {
for &byte in input.iter() {
for &byte in input {
self.state = self.state.wrapping_add(u32::from(byte));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn str_to_arrnum(src: &str, radix_def_src: &dyn RadixDef) -> Vec<u8> {

pub fn arrnum_to_str(src: &[u8], radix_def_dest: &dyn RadixDef) -> String {
let mut str_out = String::new();
for u in src.iter() {
for u in src {
#[allow(clippy::single_match)]
match radix_def_dest.format_u8(*u) {
Some(c) => {
Expand Down
4 changes: 2 additions & 2 deletions src/uucore/src/lib/features/tokenize/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ impl SubParser {
// though, as we want to mimic the original behavior of printing
// the field as interpreted up until the error in the field.

let mut legal_fields = vec![
let mut legal_fields = [
// 'a', 'A', //c99 hex float implementation not yet complete
'b', 'c', 'd', 'e', 'E', 'f', 'F', 'g', 'G', 'i', 'o', 's', 'u', 'x', 'X',
];
let mut specifiers = vec!['h', 'j', 'l', 'L', 't', 'z'];
let mut specifiers = ['h', 'j', 'l', 'L', 't', 'z'];
legal_fields.sort_unstable();
specifiers.sort_unstable();

Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_runcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn custom_context() {
}

fn get_sestatus_context(output: &[u8]) -> &str {
let re = regex::bytes::Regex::new(r#"Current context:\s*(\S+)\s*"#)
let re = regex::bytes::Regex::new(r"Current context:\s*(\S+)\s*")
.expect("Invalid regular expression");

output
Expand Down

0 comments on commit 6f5610b

Please sign in to comment.