Skip to content

fix clippy warnings #1

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

haryu703
Copy link

When I used gf macro, I encountered following warnings in generated code.

This PR fixes these warnings.

Test:

$ cargo clippy --all-features
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

Note:
This PR may bump MSRV of this crate.

@geky
Copy link
Owner

geky commented May 2, 2025

Hi @haryu703, thanks for creating this. Sorry that I haven't been able to review the changes.

@haryu703
Copy link
Author

haryu703 commented May 3, 2025

@geky Thank you for responding. I updated the PR to fix new clippy warnings.
https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_doc_comments

Following is the output of cargo clippy after the changes:

$ cargo +stable clippy --all-features
warning: unexpected `cfg` condition value: `8`
   --> src/p.rs:232:1
    |
232 | #[p(u=usize)] pub type psize;
    | ^^^^^^^^^^^^^
    |
    = note: expected values for `target_pointer_width` are: `16`, `32`, and `64`
    = note: using a cfg inside a attribute macro will use the cfgs from the destination crate and not the ones from the defining crate
    = help: try referring to `p` crate for guidance on how handle this unexpected cfg
    = help: the attribute macro `p` may come from an old version of the `gf256_macros` crate, try updating your dependency with `cargo update -p gf256_macros`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
    = note: `#[warn(unexpected_cfgs)]` on by default
    = note: this warning originates in the attribute macro `p` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `128`
   --> src/p.rs:232:1
    |
232 | #[p(u=usize)] pub type psize;
    | ^^^^^^^^^^^^^
    |
    = note: expected values for `target_pointer_width` are: `16`, `32`, and `64`
    = note: using a cfg inside a attribute macro will use the cfgs from the destination crate and not the ones from the defining crate
    = help: try referring to `p` crate for guidance on how handle this unexpected cfg
    = help: the attribute macro `p` may come from an old version of the `gf256_macros` crate, try updating your dependency with `cargo update -p gf256_macros`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
    = note: this warning originates in the attribute macro `p` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `gf256` (lib) generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s

2 warnings are related to this code. Could I remove #[cfg(target_pointer_width = "8")] and #[cfg(target_pointer_width = "128")]?

@geky
Copy link
Owner

geky commented May 5, 2025

I was curious about this. This seems to have broken even outside of clippy, which is a bit annoying given that the code hasn't changed.

And doesn't that warning seem a bit... naive? Given that 128-bit hardware already exists?

At least it's fair to say 8-bit processors will never exist.

Feel free to add #[allow(unexpected_cfgs)] or delete them. They shouldn't have an effect unless Rust adopts a 128-bit arch, and I don't have a strong opinion.

@haryu703
Copy link
Author

This warning was introduced in Rust 1.80.0 and expanded in 1.84.0. Expected values are automatically set.

If 8-bit/128-bit psize is really needed, is it possible to reimplement psize using p macro? If so, I would remove them.

rust-lang/rust#65473 may be related to this.

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.

2 participants