Skip to content

Commit 5be2d62

Browse files
committed
test: add nonstandard_style lint test
Adds a test to make sure that no excess warnings are emitted when dealing with non-standard field names in `init!`. Signed-off-by: Mirko Adzic <adzicmirko97@gmail.com>
1 parent 4e8592e commit 5be2d62

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/nonstandard_style.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//! Tests that no extra warnings are emitted for non-standard style fields when using `init!`.
2+
//!
3+
//! See: https://github.com/Rust-for-Linux/pin-init/issues/125
4+
5+
// Should be implied by crate lint settings, but just to be sure:
6+
#![deny(nonstandard_style)]
7+
#![allow(dead_code)]
8+
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
9+
#![cfg_attr(USE_RUSTC_FEATURES, feature(raw_ref_op))]
10+
11+
use pin_init::*;
12+
13+
#[allow(nonstandard_style)]
14+
struct Foo {
15+
NON_STANDARD_A: usize,
16+
nonStandardB: Bar,
17+
}
18+
19+
#[allow(non_snake_case)]
20+
struct Bar {
21+
Non_Standard_C: usize,
22+
}
23+
24+
impl Foo {
25+
fn new() -> impl Init<Self> {
26+
init!(Self {
27+
NON_STANDARD_A: 42,
28+
nonStandardB <- init!(Bar { Non_Standard_C: 42 }),
29+
})
30+
}
31+
}

0 commit comments

Comments
 (0)