diff options
Diffstat (limited to 'tests/ui/pin_project')
-rw-r--r-- | tests/ui/pin_project/conflict-unpin.stderr | 2 | ||||
-rw-r--r-- | tests/ui/pin_project/impl-unsafe-unpin.stderr | 2 | ||||
-rw-r--r-- | tests/ui/pin_project/packed_sneaky-1.rs | 9 | ||||
-rw-r--r-- | tests/ui/pin_project/packed_sneaky-1.stderr | 16 | ||||
-rw-r--r-- | tests/ui/pin_project/packed_sneaky-4.rs | 15 | ||||
-rw-r--r-- | tests/ui/pin_project/packed_sneaky-4.stderr | 16 | ||||
-rw-r--r-- | tests/ui/pin_project/project_replace_unsized.stderr | 34 | ||||
-rw-r--r-- | tests/ui/pin_project/project_replace_unsized_fn_params.stderr | 34 | ||||
-rw-r--r-- | tests/ui/pin_project/unpin_sneaky.stderr | 6 |
9 files changed, 87 insertions, 47 deletions
diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 5e012c4..7df5db2 100644 --- a/tests/ui/pin_project/conflict-unpin.stderr +++ b/tests/ui/pin_project/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 13 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/impl-unsafe-unpin.stderr b/tests/ui/pin_project/impl-unsafe-unpin.stderr index ba42303..9554b9b 100644 --- a/tests/ui/pin_project/impl-unsafe-unpin.stderr +++ b/tests/ui/pin_project/impl-unsafe-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {} - | ---------------------------------------------------------- first implementation here + | ------------------------------------------- first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/packed_sneaky-1.rs b/tests/ui/pin_project/packed_sneaky-1.rs index 72d3d3e..83a4612 100644 --- a/tests/ui/pin_project/packed_sneaky-1.rs +++ b/tests/ui/pin_project/packed_sneaky-1.rs @@ -1,6 +1,6 @@ use std::pin::Pin; -use auxiliary_macro::hidden_repr; +use auxiliary_macro::{hidden_repr, hidden_repr2}; use pin_project::{pin_project, pinned_drop, UnsafeUnpin}; #[pin_project] //~ ERROR may not be used on #[repr(packed)] types @@ -10,6 +10,13 @@ struct A { f: u32, } +#[hidden_repr2] +#[pin_project] //~ ERROR may not be used on #[repr(packed)] types +struct B { + #[pin] + f: u32, +} + #[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types #[hidden_repr(packed)] struct C { diff --git a/tests/ui/pin_project/packed_sneaky-1.stderr b/tests/ui/pin_project/packed_sneaky-1.stderr index 32fe407..0746e1a 100644 --- a/tests/ui/pin_project/packed_sneaky-1.stderr +++ b/tests/ui/pin_project/packed_sneaky-1.stderr @@ -5,13 +5,21 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:14:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:13:1 | -14 | #[hidden_repr(packed)] +13 | #[hidden_repr2] + | ^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `hidden_repr2` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/pin_project/packed_sneaky-1.rs:21:15 + | +21 | #[hidden_repr(packed)] | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:23:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:30:15 | -23 | #[hidden_repr(packed)] +30 | #[hidden_repr(packed)] | ^^^^^^ diff --git a/tests/ui/pin_project/packed_sneaky-4.rs b/tests/ui/pin_project/packed_sneaky-4.rs new file mode 100644 index 0000000..fb954ba --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.rs @@ -0,0 +1,15 @@ +// https://github.com/taiki-e/pin-project/issues/342 + +#![allow(unaligned_references)] + +use auxiliary_macro::hidden_repr2; +use pin_project::pin_project; + +#[pin_project] //~ ERROR reference to packed field is unaligned +#[hidden_repr2] +struct A { + #[pin] + f: u32, +} + +fn main() {} diff --git a/tests/ui/pin_project/packed_sneaky-4.stderr b/tests/ui/pin_project/packed_sneaky-4.stderr new file mode 100644 index 0000000..8072ce2 --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.stderr @@ -0,0 +1,16 @@ +error: reference to packed field is unaligned + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr index 86cc148..042b499 100644 --- a/tests/ui/pin_project/project_replace_unsized.stderr +++ b/tests/ui/pin_project/project_replace_unsized.stderr @@ -48,25 +48,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized.rs:5:5 - | -3 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -4 | struct Struct<T: ?Sized> { - | - this type parameter needs to be `std::marker::Sized` -5 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized.rs:5:5 + | +3 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +4 | struct Struct<T: ?Sized> { + | - this type parameter needs to be `std::marker::Sized` +5 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read<T>(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read<T>(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -4 - struct Struct<T: ?Sized> { -4 + struct Struct<T> { - | + | +4 - struct Struct<T: ?Sized> { +4 + struct Struct<T> { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized.rs:8:15 diff --git a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr index e398ca4..10fad08 100644 --- a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr +++ b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr @@ -45,25 +45,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 - | -5 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -6 | struct Struct<T: ?Sized> { - | - this type parameter needs to be `std::marker::Sized` -7 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 + | +5 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +6 | struct Struct<T: ?Sized> { + | - this type parameter needs to be `std::marker::Sized` +7 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read<T>(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read<T>(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -6 - struct Struct<T: ?Sized> { -6 + struct Struct<T> { - | + | +6 - struct Struct<T: ?Sized> { +6 + struct Struct<T> { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8 diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr index ddf700d..82c2aa5 100644 --- a/tests/ui/pin_project/unpin_sneaky.stderr +++ b/tests/ui/pin_project/unpin_sneaky.stderr @@ -3,9 +3,3 @@ error[E0412]: cannot find type `__S` in this scope | 9 | impl Unpin for __S {} //~ ERROR E0412,E0321 | ^^^ not found in this scope - -error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]` - --> tests/ui/pin_project/unpin_sneaky.rs:9:1 - | -9 | impl Unpin for __S {} //~ ERROR E0412,E0321 - | ^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type |