Skip to content

Commit f7a686c

Browse files
committed
tests: update macro expansion expectations after safety docs addition
The #[pin_data] macro now generates additional safety documentation comments in the expanded output, similar to other recent safety documentation improvements. The macro generates: /// `slot` is a pointer valid for writes and any value written to it is pinned. /// `slot` is valid for writes. Thus update the expected .expanded.rs files to match current macro behavior, and fix related compile-fail test expectations. Signed-off-by: Liam Davis <[email protected]>
1 parent 26430f1 commit f7a686c

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

tests/ui/compile-fail/init/invalid_init.stderr

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ error[E0277]: the trait bound `impl pin_init::PinInit<Bar>: Init<Bar>` is not sa
1010
| |______the trait `Init<Bar>` is not implemented for `impl pin_init::PinInit<Bar>`
1111
| required by a bound introduced by this call
1212
|
13-
= help: the following other types implement trait `Init<T, E>`:
14-
ChainInit<I, F, T, E>
15-
Result<T, E>
13+
= help: the trait `Init<T, E>` is implemented for `ChainInit<I, F, T, E>`
1614
= note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `init` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui/compile-fail/init/missing_pin_data.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ error[E0599]: no associated item named `__pin_data` found for struct `Foo` in th
1111
= note: the following trait defines an item `__pin_data`, perhaps you need to implement it:
1212
candidate #1: `HasPinData`
1313
= note: this error originates in the macro `$crate::try_pin_init` which comes from the expansion of the macro `pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
help: there is an associated function `__init_data` with a similar name
15+
--> src/lib.rs
16+
|
17+
- @has_data(HasPinData, __pin_data),
18+
+ @has_data(HasPinData, __init_data),
19+
|

tests/ui/compile-fail/init/wrong_generics2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ help: you might have forgotten to add the struct literal inside the block
1212
--> src/macros.rs
1313
|
1414
~ ::core::ptr::write($slot, $t { SomeStruct {
15-
|8 $($acc)*
15+
|9 $($acc)*
1616
~ } });
1717
|
1818

tests/ui/expand/many_generics.expanded.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const _: () = {
5050
///
5151
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
5252
/// that is properly aligned and large enough to hold a value of type `$p_type`.
53+
/// `slot` is a pointer valid for writes and any value written to it is pinned.
5354
unsafe fn _pin<E>(
5455
self,
5556
slot: *mut PhantomPinned,
@@ -62,6 +63,7 @@ const _: () = {
6263
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
6364
/// that is properly aligned and large enough to hold a value of type `$type`.
6465
/// The memory at `slot` must also be valid for writes.
66+
/// `slot` is valid for writes.
6567
unsafe fn array<E>(
6668
self,
6769
slot: *mut [u8; 1024 * 1024],
@@ -74,6 +76,7 @@ const _: () = {
7476
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
7577
/// that is properly aligned and large enough to hold a value of type `$type`.
7678
/// The memory at `slot` must also be valid for writes.
79+
/// `slot` is valid for writes.
7780
unsafe fn r<E>(
7881
self,
7982
slot: *mut &'b mut [&'a mut T; SIZE],

tests/ui/expand/pin-data.expanded.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const _: () = {
2121
///
2222
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
2323
/// that is properly aligned and large enough to hold a value of type `$p_type`.
24+
/// `slot` is a pointer valid for writes and any value written to it is pinned.
2425
unsafe fn _pin<E>(
2526
self,
2627
slot: *mut PhantomPinned,
@@ -33,6 +34,7 @@ const _: () = {
3334
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
3435
/// that is properly aligned and large enough to hold a value of type `$type`.
3536
/// The memory at `slot` must also be valid for writes.
37+
/// `slot` is valid for writes.
3638
unsafe fn array<E>(
3739
self,
3840
slot: *mut [u8; 1024 * 1024],

tests/ui/expand/pinned_drop.expanded.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const _: () = {
2121
///
2222
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
2323
/// that is properly aligned and large enough to hold a value of type `$p_type`.
24+
/// `slot` is a pointer valid for writes and any value written to it is pinned.
2425
unsafe fn _pin<E>(
2526
self,
2627
slot: *mut PhantomPinned,
@@ -33,6 +34,7 @@ const _: () = {
3334
/// The caller must ensure that `slot` is a valid pointer to uninitialized memory
3435
/// that is properly aligned and large enough to hold a value of type `$type`.
3536
/// The memory at `slot` must also be valid for writes.
37+
/// `slot` is valid for writes.
3638
unsafe fn array<E>(
3739
self,
3840
slot: *mut [u8; 1024 * 1024],

0 commit comments

Comments
 (0)