Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings with Rust 1.72.0 #5204

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

cakebaker
Copy link
Contributor

No description provided.

@cakebaker cakebaker force-pushed the fix_clippy_warnings branch 2 times, most recently from 6f5610b to 392bec5 Compare August 25, 2023 06:32
@tertsdiepraam
Copy link
Member

I don't really like the changes from foo.iter() to &*foo. I suppose just & doesn't work? I guess it's fine either way, neither option is great.

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (p, exp) in &*v {
for (p, exp) in v {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just like you, i don't like the &* syntax :)
if v works, great! if it doesn't, i would prefer to keep v.iter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes I suggested should work. But there are a few more cases of &* and &mut * left that I couldn't simplify. I'll go look for a clippy issue related to this. I'm guessing we aren't the only ones who don't like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found something related: rust-lang/rust-clippy#11074

Copy link
Contributor Author

@cakebaker cakebaker Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will simplify where possible and go back to iter (and disable the warning) in the other cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (p, e) in &self.0.borrow().0 {
for (p, e) in self.0.borrow().0 {

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for byte in &mut *bytes {
for byte in bytes {

@cakebaker cakebaker force-pushed the fix_clippy_warnings branch from 392bec5 to 01b2834 Compare August 25, 2023 11:22
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail-2/inotify-dir-recreate

@sylvestre sylvestre merged commit f0602b0 into uutils:main Aug 25, 2023
@cakebaker cakebaker deleted the fix_clippy_warnings branch August 26, 2023 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants