Skip to content

Commit a898282

Browse files
committed
tests: ensure that #[disable_initialized_field_access] does not emit accessors
Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent 455b0f1 commit a898282

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use pin_init::*;
2+
3+
#[repr(C, packed)]
4+
struct Foo {
5+
a: i8,
6+
b: i32,
7+
c: i32,
8+
}
9+
10+
fn main() {
11+
let _ = init!(
12+
#[disable_initialized_field_access]
13+
Foo {
14+
c: -42,
15+
b: *c,
16+
a: 0,
17+
}
18+
);
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error[E0425]: cannot find value `c` in this scope
2+
--> tests/ui/compile-fail/init/no_field_access.rs:15:17
3+
|
4+
15 | b: *c,
5+
| ^ not found in this scope

0 commit comments

Comments
 (0)