Skip to content

Commit 20f01c4

Browse files
committed
[derive] Don't emit #[cfg(coverage_nightly)]
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
1 parent 1cc24c0 commit 20f01c4

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

zerocopy-derive/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ fn derive_known_layout_inner(ast: &DeriveInput, _top_level: Trait) -> Result<Tok
301301
#predicates
302302
{
303303
#[allow(clippy::missing_inline_in_public_items)]
304-
#[cfg_attr(coverage_nightly, coverage(off))]
305304
fn only_derive_is_allowed_to_implement_this_trait() {}
306305

307306
type PointerMetadata = <#ident #ty_generics as ::zerocopy::KnownLayout>::PointerMetadata;

zerocopy-derive/src/output_tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ fn test_known_layout() {
192192
<U as ::zerocopy::KnownLayout>::MaybeUninit: ::zerocopy::KnownLayout,
193193
{
194194
#[allow(clippy::missing_inline_in_public_items)]
195-
#[cfg_attr(coverage_nightly, coverage(off))]
196195
fn only_derive_is_allowed_to_implement_this_trait() {}
197196
type PointerMetadata = <Foo<T, U> as ::zerocopy::KnownLayout>::PointerMetadata;
198197
type MaybeUninit = Self;

zerocopy-derive/tests/issue_2117.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2024 The Fuchsia Authors
2+
//
3+
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4+
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5+
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6+
// This file may not be copied, modified, or distributed except according to
7+
// those terms.
8+
9+
// See comment in `include.rs` for why we disable the prelude.
10+
#![no_implicit_prelude]
11+
#![allow(warnings)]
12+
#![forbid(unexpected_cfgs)]
13+
14+
include!("include.rs");
15+
16+
// Make sure no unexpected `cfg`s are emitted by our derives (see #2117).
17+
18+
#[derive(imp::KnownLayout)]
19+
#[repr(C)]
20+
pub struct Test(pub [u8; 32]);

0 commit comments

Comments
 (0)