Skip to content

Commit 07d039a

Browse files
committed
tests: add test to check cfgs working correctly
Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent 6edf8d3 commit 07d039a

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/cfgs.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
2+
3+
use pin_init::{pin_data, pin_init, PinInit};
4+
5+
#[pin_data]
6+
pub struct Struct {
7+
#[cfg(kernel)]
8+
field_d: Field,
9+
#[cfg(not(kernel))]
10+
field_e: Field,
11+
}
12+
13+
impl Struct {
14+
pub fn new() -> impl PinInit<Self> {
15+
pin_init!(Self {
16+
#[cfg(kernel)]
17+
field_d: Field {},
18+
#[cfg(not(kernel))]
19+
field_e: Field {},
20+
})
21+
}
22+
}
23+
24+
struct Field {}

0 commit comments

Comments
 (0)