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

The KnownLayout macro has an issue with the latest nightly #2117

Closed
AaronKutch opened this issue Dec 2, 2024 · 5 comments · Fixed by #2126
Closed

The KnownLayout macro has an issue with the latest nightly #2117

AaronKutch opened this issue Dec 2, 2024 · 5 comments · Fixed by #2126
Assignees
Labels
bug Something isn't working

Comments

@AaronKutch
Copy link

This is failing for me with nightly-2024-11-26

use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned};

#[derive(
    Clone, Copy, Hash, PartialEq, Eq, FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned,
)]
#[repr(C)]
pub struct Test(pub [u8; 32]);

running cargo +nightly-2024-11-26 clippy gives

warning: unexpected `cfg` condition name: `coverage_nightly`
 --> src/main.rs:5:61
  |
5 |     Clone, Copy, Hash, PartialEq, Eq, FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned,
  |                                                             ^^^^^^^^^^^
  |
  = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(coverage_nightly)");` to the top of the `build.rs`
  = 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 derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info)

which is causing issues in my strict CI

@joshlf
Copy link
Member

joshlf commented Dec 2, 2024

I am able to reproduce this locally using zerocopy 0.8.11. Confusingly, when I run cargo expand, I don't see the string coverage_nightly anywhere in the output. That makes me think that this might be a compiler bug.

What was the most recent nightly for which this code passed Clippy without issue?

EDIT: I bisected locally and determined that the regression was introduced in nightly-2024-11-20.

@joshlf
Copy link
Member

joshlf commented Dec 2, 2024

I've filed an issue upstream: rust-lang/rust#133775

joshlf added a commit that referenced this issue Dec 3, 2024
As of nightly-2024-11-20 - specifically [1] - this triggers an
`unexpected_cfgs` lint even when emitted in derive-generated code.

[1] rust-lang/rust#132577

Fixes #2117

gherrit-pr-id: I9d536f0ea08475afe0b65411b225aa55f4db449a
@joshlf
Copy link
Member

joshlf commented Dec 3, 2024

Update: It's actually a zerocopy bug.

Fix pending: #2123

joshlf added a commit that referenced this issue Dec 3, 2024
As of nightly-2024-11-20 - specifically [1] - this triggers an
`unexpected_cfgs` lint even when emitted in derive-generated code.

[1] rust-lang/rust#132577

Fixes #2117

gherrit-pr-id: I9d536f0ea08475afe0b65411b225aa55f4db449a
github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2024
As of nightly-2024-11-20 - specifically [1] - this triggers an
`unexpected_cfgs` lint even when emitted in derive-generated code.

[1] rust-lang/rust#132577

Fixes #2117

gherrit-pr-id: I9d536f0ea08475afe0b65411b225aa55f4db449a
@joshlf
Copy link
Member

joshlf commented Dec 3, 2024

Fixed by #2123.

@joshlf joshlf closed this as completed Dec 3, 2024
@joshlf
Copy link
Member

joshlf commented Dec 3, 2024

The fix is now released in 0.8.12.

github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2024
As of nightly-2024-11-20 - specifically [1] - this triggers an
`unexpected_cfgs` lint even when emitted in derive-generated code.

[1] rust-lang/rust#132577

Fixes #2117

gherrit-pr-id: I9d536f0ea08475afe0b65411b225aa55f4db449a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants