Skip to content

Commit 252dc48

Browse files
committed
tests: ensure that the data cannot be accessed
Similarly to guards, the pin-init data generated by the `#[pin_data]` attribute macro and instantiated by an initializer macro should not be accessible by user-controlled code. Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent dc0131a commit 252dc48

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use pin_init::*;
2+
3+
#[pin_data]
4+
struct Foo {}
5+
6+
fn main() {
7+
let _ = pin_init!(Foo {
8+
_: {
9+
let _ = __data;
10+
},
11+
});
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error[E0425]: cannot find value `__data` in this scope
2+
--> tests/ui/compile-fail/init/data_access.rs:9:21
3+
|
4+
9 | let _ = __data;
5+
| ^^^^^^ not found in this scope

0 commit comments

Comments
 (0)