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 #60

Open
jjl opened this issue Dec 27, 2024 · 2 comments
Open

fix clippy warnings #60

jjl opened this issue Dec 27, 2024 · 2 comments

Comments

@jjl
Copy link

jjl commented Dec 27, 2024

for example, with the connected nodes example:

warning: this `if` statement can be collapsed
  --> src/main.rs:11:4
   |
11 |    path(x, y) <-- edge(x, y);
   |    ^^^^^^^^^ help: collapse nested if block: `if path(x, y && path(x, y && path(x, y path(x, y`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
   = note: `#[warn(clippy::collapsible_if)]` on by default

warning: this `if` statement can be collapsed
  --> src/main.rs:12:4
   |
12 |    path(x, z) <-- edge(x, y), path(y, z);
   |    ^^^^^^^^^ help: collapse nested if block: `if path(x, z && path(x, z && path(x, z path(x, z`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if

warning: using `clone` on type `i32` which implements the `Copy` trait
  --> src/main.rs:11:4
   |
11 |    path(x, y) <-- edge(x, y);
   |    ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
   = note: `#[warn(clippy::clone_on_copy)]` on by default
help: try removing the `clone` call
   |
11 ~    ascent! {
12 +    relation edge(i32, i32);
13 +    relation path(i32, i32);
14 +       
15 +    path(x, y) <-- edge(x, y);
16 +    path(x, z) <-- edge(x, y), path(y, z);
17 ~ }) <-- edge(x, y);
   |

warning: using `clone` on type `i32` which implements the `Copy` trait
  --> src/main.rs:12:36
   |
12 |    path(x, z) <-- edge(x, y), path(y, z);
   |                                    ^ help: try dereferencing it: `*y`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

warning: using `clone` on type `i32` which implements the `Copy` trait
  --> src/main.rs:12:4
   |
12 |    path(x, z) <-- edge(x, y), path(y, z);
   |    ^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
help: try removing the `clone` call
   |
12 ~    ascent! {
13 +    relation edge(i32, i32);
14 +    relation path(i32, i32);
15 +       
16 +    path(x, y) <-- edge(x, y);
17 +    path(x, z) <-- edge(x, y), path(y, z);
18 ~ }) <-- edge(x, y), path(y, z);
   |

warning: using `clone` on type `i32` which implements the `Copy` trait
  --> src/main.rs:12:27
   |
12 |    path(x, z) <-- edge(x, y), path(y, z);
   |                           ^ help: try dereferencing it: `*y`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

warning: you seem to use `.enumerate()` and immediately discard the index
 --> src/main.rs:8:13
  |
8 |    relation edge(i32, i32);
  |             ^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
  = note: `#[warn(clippy::unused_enumerate_index)]` on by default
  = note: this warning originates in the macro `ascent` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using `clone` on type `i32` which implements the `Copy` trait
 --> src/main.rs:8:13
  |
8 |    relation edge(i32, i32);
  |             ^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
help: try removing the `clone` call
  |
8 ~    relation ascent! {
9 +    relation edge(i32, i32);
10+    relation path(i32, i32);
11+       
12+    path(x, y) <-- edge(x, y);
13+    path(x, z) <-- edge(x, y), path(y, z);
14~ }(i32, i32);
  |

warning: you seem to use `.enumerate()` and immediately discard the index
 --> src/main.rs:9:13
  |
9 |    relation path(i32, i32);
  |             ^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
  = note: this warning originates in the macro `ascent` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using `clone` on type `i32` which implements the `Copy` trait
 --> src/main.rs:9:13
  |
9 |    relation path(i32, i32);
  |             ^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
help: try removing the `clone` call
  |
9 ~    relation ascent! {
10+    relation edge(i32, i32);
11+    relation path(i32, i32);
12+       
13+    path(x, y) <-- edge(x, y);
14+    path(x, z) <-- edge(x, y), path(y, z);
15~ }(i32, i32);
  |

warning: field assignment outside of initializer for an instance created with Default::default()
  --> src/main.rs:17:4
   |
17 |    prog.edge = vec![(1, 2), (2, 3)];
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: consider initializing the variable with `AscentProgram { edge: vec![(1, 2), (2, 3)], ..Default::default() }` and removing relevant reassignments
  --> src/main.rs:16:4
   |
16 |    let mut prog = AscentProgram::default();
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
   = note: `#[warn(clippy::field_reassign_with_default)]` on by default
@s-arash
Copy link
Owner

s-arash commented Jan 5, 2025

Fair enough. With the litany of (not helpful) Clippy warnings, I may just silence all of the Clippy warnings for the generated code.

@jjl
Copy link
Author

jjl commented Jan 6, 2025

if they aren't giving any useful info, may as well.

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

No branches or pull requests

2 participants