Skip to content

Commit 02ad57b

Browse files
committed
test: expand nonstandard_style lint test
Expands the test to also cover usage of `pin_init!` (instead of only `init!`) on structs with non-standard style field names. Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Mirko Adzic <adzicmirko97@gmail.com>
1 parent 6699b73 commit 02ad57b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/nonstandard_style.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Tests that no extra warnings are emitted for non-standard style fields when using `init!`.
1+
//! Tests that no extra warnings are emitted for non-standard style fields when using `init!`
2+
//! or `pin_init!`.
23
//!
34
//! See: https://github.com/Rust-for-Linux/pin-init/issues/125
45
@@ -16,6 +17,7 @@ struct Foo {
1617
nonStandardB: Bar,
1718
}
1819

20+
// Make sure `allow(non_snake_case)` also works.
1921
#[allow(non_snake_case)]
2022
struct Bar {
2123
Non_Standard_C: usize,
@@ -29,3 +31,20 @@ impl Foo {
2931
})
3032
}
3133
}
34+
35+
#[allow(nonstandard_style)]
36+
#[pin_data]
37+
struct Baz {
38+
NON_STANDARD: usize,
39+
#[pin]
40+
nonStandardPin: usize,
41+
}
42+
43+
impl Baz {
44+
fn new(a: impl PinInit<usize>) -> impl PinInit<Self> {
45+
pin_init!(Self {
46+
NON_STANDARD: 42,
47+
nonStandardPin <- a,
48+
})
49+
}
50+
}

0 commit comments

Comments
 (0)