Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
#[cfg_attr(any(), pin_project::pin_project)]
struct Foo<T> {
f: T,
}
fn main() {
let mut x = Foo { f: 0_u8 };
let _ = Pin::new(&mut x).project(); //~ ERROR E0599
}

View File

@@ -0,0 +1,5 @@
error[E0599]: no method named `project` found for struct `Pin<&mut Foo<u8>>` in the current scope
--> tests/ui/cfg/cfg_attr-resolve.rs:12:30
|
12 | let _ = Pin::new(&mut x).project(); //~ ERROR E0599
| ^^^^^^^ method not found in `Pin<&mut Foo<u8>>`

View File

@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::pin_project;
#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
#[cfg_attr(any(), pin)]
f: T,
}
#[cfg_attr(not(any()), pin_project)]
struct Bar<T> {
#[cfg_attr(not(any()), pin)]
f: T,
}
fn main() {
let mut x = Foo { f: 0_u8 };
let x = Pin::new(&mut x).project();
let _: Pin<&mut u8> = x.f; //~ ERROR E0308
let mut x = Bar { f: 0_u8 };
let x = Pin::new(&mut x).project();
let _: &mut u8 = x.f; //~ ERROR E0308
}

View File

@@ -0,0 +1,25 @@
error[E0308]: mismatched types
--> tests/ui/cfg/cfg_attr-type-mismatch.rs:22:27
|
22 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308
| ------------ ^^^ expected `Pin<&mut u8>`, found `&mut u8`
| |
| expected due to this
|
= note: expected struct `Pin<&mut u8>`
found mutable reference `&mut u8`
error[E0308]: mismatched types
--> tests/ui/cfg/cfg_attr-type-mismatch.rs:26:22
|
26 | let _: &mut u8 = x.f; //~ ERROR E0308
| ------- ^^^ expected `&mut u8`, found `Pin<&mut u8>`
| |
| expected due to this
|
= note: expected mutable reference `&mut u8`
found struct `Pin<&mut u8>`
help: consider mutably borrowing here
|
26 | let _: &mut u8 = &mut x.f; //~ ERROR E0308
| ++++

View File

@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
#[pin_project]
#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[cfg(not(any()))]
#[pin]
f: u32,
#[cfg(any())]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky-span-issue-1.rs:7:15
|
7 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
#[pin_project]
#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[cfg(any())]
#[pin]
f: u32,
#[cfg(not(any()))]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky-span-issue-2.rs:7:15
|
7 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,14 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::hidden_repr_cfg_not_any;
use pin_project::pin_project;
// `#[hidden_repr_cfg_not_any(packed)]` generates `#[cfg_attr(not(any()), repr(packed))]`.
#[pin_project]
#[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[pin]
f: u32,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky.rs:8:27
|
8 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project]
struct S {
//~^ ERROR may not be used on structs with zero fields
#[cfg(any())]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,11 @@
error: #[pin_project] attribute may not be used on structs with zero fields
--> tests/ui/cfg/unsupported.rs:6:10
|
6 | struct S {
| __________^
7 | | //~^ ERROR may not be used on structs with zero fields
8 | | #[cfg(any())]
9 | | #[pin]
10 | | f: u8,
11 | | }
| |_^

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
fn main() {}

View File

@@ -0,0 +1,26 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:5:15
|
5 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Foo<_, _>`
...
12 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
| --------------------------------------------- first implementation here
error[E0119]: conflicting implementations of trait `Unpin` for type `Bar<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:14:15
|
14 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Bar<_, _>`
...
21 | impl<T, U> Unpin for Bar<T, U> {}
| ------------------------------ first implementation here
error[E0119]: conflicting implementations of trait `Unpin` for type `Baz<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:23:15
|
23 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Baz<_, _>`
...
30 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
| -------------------------------------------- first implementation here

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
fn main() {}

View File

@@ -0,0 +1,32 @@
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Foo<_, _>`
--> tests/ui/not_unpin/impl-unsafe-unpin.rs:5:1
|
5 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
12 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
| ---------------------------------------------------------- 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)
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Bar<_, _>`
--> tests/ui/not_unpin/impl-unsafe-unpin.rs:14:1
|
14 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
21 | unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
| ------------------------------------------- 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)
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Baz<_, _>`
--> tests/ui/not_unpin/impl-unsafe-unpin.rs:23:1
|
23 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
30 | unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
| --------------------------------------------------------- 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)

View File

@@ -0,0 +1,20 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670
#[pin_project::pin_project(!Unpin)]
struct Foo<Pinned, Unpinned> {
#[pin]
pinned: Pinned,
unpinned: Unpinned,
}
struct MyPhantomPinned(::core::marker::PhantomPinned);
impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {}
impl Unpin for Foo<MyPhantomPinned, ()> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Foo<MyPhantomPinned, ()>>()
}

View File

@@ -0,0 +1,8 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>`
--> tests/ui/not_unpin/negative_impls_stable.rs:5:28
|
5 | #[pin_project::pin_project(!Unpin)]
| ^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>`
...
14 | impl Unpin for Foo<MyPhantomPinned, ()> {}
| --------------------------------------- first implementation here

View File

@@ -0,0 +1,22 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::marker::PhantomPinned;
use auxiliary_macro::add_pin_attr;
use pin_project::pin_project;
#[pin_project]
#[add_pin_attr(struct)] //~ ERROR expected attribute arguments in parentheses
struct Foo {
#[pin]
f: PhantomPinned,
}
#[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
#[pin_project]
struct Bar {
#[pin]
f: PhantomPinned,
}
fn main() {}

View File

@@ -0,0 +1,15 @@
error: expected attribute arguments in parentheses: `pin(...)`
--> tests/ui/pin_project/add-attr-to-struct.rs:9:1
|
9 | #[add_pin_attr(struct)] //~ ERROR expected attribute arguments in parentheses
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `add_pin_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/add-attr-to-struct.rs:15:1
|
15 | #[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `add_pin_attr` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::add_pinned_field;
use pin_project::pin_project;
fn is_unpin<T: Unpin>() {}
#[pin_project]
#[add_pinned_field]
struct Foo {
#[pin]
f: u32,
}
#[add_pinned_field]
#[pin_project]
struct Bar {
#[pin]
f: u32,
}
fn main() {
is_unpin::<Foo>(); //~ ERROR E0277
is_unpin::<Bar>(); //~ ERROR E0277
}

View File

@@ -0,0 +1,54 @@
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/add-pinned-field.rs:23:16
|
23 | is_unpin::<Foo>(); //~ ERROR E0277
| ^^^ within `__Foo<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `__Foo<'_>`
--> tests/ui/pin_project/add-pinned-field.rs:10:8
|
10 | struct Foo {
| ^^^
note: required for `Foo` to implement `Unpin`
--> tests/ui/pin_project/add-pinned-field.rs:8:1
|
8 | #[pin_project]
| ^^^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
9 | #[add_pinned_field]
10 | struct Foo {
| ^^^
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/add-pinned-field.rs:6:16
|
6 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/add-pinned-field.rs:24:16
|
24 | is_unpin::<Bar>(); //~ ERROR E0277
| ^^^ within `__Bar<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `__Bar<'_>`
--> tests/ui/pin_project/add-pinned-field.rs:17:8
|
17 | struct Bar {
| ^^^
note: required for `Bar` to implement `Unpin`
--> tests/ui/pin_project/add-pinned-field.rs:16:1
|
16 | #[pin_project]
| ^^^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
17 | struct Bar {
| ^^^
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/add-pinned-field.rs:6:16
|
6 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Drop for Foo<T, U> {
fn drop(&mut self) {}
}
#[pin_project(PinnedDrop)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
#[pinned_drop]
impl<T, U> PinnedDrop for Bar<T, U> {
fn drop(self: Pin<&mut Self>) {}
}
impl<T, U> Drop for Bar<T, U> {
fn drop(&mut self) {}
}
fn main() {}

View File

@@ -0,0 +1,19 @@
error[E0119]: conflicting implementations of trait `Drop` for type `Bar<_, _>`
--> tests/ui/pin_project/conflict-drop.rs:18:15
|
18 | #[pin_project(PinnedDrop)] //~ ERROR E0119
| ^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
30 | impl<T, U> Drop for Bar<T, U> {
| ----------------------------- first implementation here
error[E0119]: conflicting implementations of trait `FooMustNotImplDrop` for type `Foo<_, _>`
--> tests/ui/pin_project/conflict-drop.rs:7:1
|
7 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `Foo<_, _>`
|
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,39 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
// The same implementation.
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
// conflicting implementations
impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
// The implementation that under different conditions.
#[pin_project] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
// conflicting implementations
impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
#[pin_project] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
// conflicting implementations
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
fn main() {}

View File

@@ -0,0 +1,32 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:7:1
|
7 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
15 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
| --------------------------------------------- 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)
error[E0119]: conflicting implementations of trait `Unpin` for type `Bar<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:19:1
|
19 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
27 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
| ------------------------------ 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)
error[E0119]: conflicting implementations of trait `Unpin` for type `Baz<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:29:1
|
29 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
37 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
| -------------------------------------------- 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)

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
#[pin_project] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
#[pin_project] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
fn main() {}

View File

@@ -0,0 +1,32 @@
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Foo<_, _>`
--> tests/ui/pin_project/impl-unsafe-unpin.rs:5:1
|
5 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
12 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
| ---------------------------------------------------------- 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)
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Bar<_, _>`
--> tests/ui/pin_project/impl-unsafe-unpin.rs:14:1
|
14 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
21 | unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
| ------------------------------------------- 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)
error[E0119]: conflicting implementations of trait `UnsafeUnpin` for type `Baz<_, _>`
--> tests/ui/pin_project/impl-unsafe-unpin.rs:23:1
|
23 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
30 | unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
| --------------------------------------------------------- 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)

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Only named projected types can be imported.
// See visibility.rs for named projected types.
mod pub_ {
use pin_project::pin_project;
#[pin_project]
pub struct Default(());
#[pin_project(project_replace)]
pub struct Replace(());
}
#[allow(unused_imports)]
pub mod use_ {
#[rustfmt::skip]
use crate::pub_::__DefaultProjection; //~ ERROR E0432
#[rustfmt::skip]
use crate::pub_::__DefaultProjectionRef; //~ ERROR E0432
#[rustfmt::skip]
use crate::pub_::__ReplaceProjection; //~ ERROR E0432
#[rustfmt::skip]
use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0432
#[rustfmt::skip]
use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0432
// Confirm that the visibility of the original type is not changed.
pub use crate::pub_::{Default, Replace};
}
fn main() {}

View File

@@ -0,0 +1,29 @@
error[E0432]: unresolved import `crate::pub_::__DefaultProjection`
--> tests/ui/pin_project/import_unnamed.rs:18:9
|
18 | use crate::pub_::__DefaultProjection; //~ ERROR E0432
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjection` in `pub_`
error[E0432]: unresolved import `crate::pub_::__DefaultProjectionRef`
--> tests/ui/pin_project/import_unnamed.rs:20:9
|
20 | use crate::pub_::__DefaultProjectionRef; //~ ERROR E0432
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjectionRef` in `pub_`
error[E0432]: unresolved import `crate::pub_::__ReplaceProjection`
--> tests/ui/pin_project/import_unnamed.rs:22:9
|
22 | use crate::pub_::__ReplaceProjection; //~ ERROR E0432
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjection` in `pub_`
error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionOwned`
--> tests/ui/pin_project/import_unnamed.rs:24:9
|
24 | use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0432
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionOwned` in `pub_`
error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionRef`
--> tests/ui/pin_project/import_unnamed.rs:26:9
|
26 | use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0432
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionRef` in `pub_`

View File

@@ -0,0 +1,282 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
mod pin_argument {
use pin_project::pin_project;
#[pin_project]
struct Struct {
#[pin()] //~ ERROR unexpected token in attribute
f: (),
}
#[pin_project]
struct TupleStruct(#[pin(foo)] ()); //~ ERROR unexpected token in attribute
#[pin_project]
enum EnumTuple {
V(#[pin(foo)] ()), //~ ERROR unexpected token in attribute
}
#[pin_project]
enum EnumStruct {
V {
#[pin(foo)] //~ ERROR unexpected token in attribute
f: (),
},
}
}
mod pin_attribute {
use pin_project::pin_project;
#[pin_project]
struct DuplicateStruct {
#[pin]
#[pin] //~ ERROR duplicate #[pin] attribute
f: (),
}
#[pin_project]
struct DuplicateTupleStruct(
#[pin]
#[pin]
(),
//~^^ ERROR duplicate #[pin] attribute
);
#[pin_project]
enum DuplicateEnumTuple {
V(
#[pin]
#[pin]
(),
//~^^ ERROR duplicate #[pin] attribute
),
}
#[pin_project]
enum DuplicateEnumStruct {
V {
#[pin]
#[pin] //~ ERROR duplicate #[pin] attribute
f: (),
},
}
}
mod pin_item {
use pin_project::pin_project;
#[pin_project]
#[pin] //~ ERROR may only be used on fields of structs or variants
struct Struct {
#[pin]
f: (),
}
#[pin_project]
enum Variant {
#[pin] //~ ERROR may only be used on fields of structs or variants
V(()),
}
#[pin_project]
#[pin] //~ ERROR may only be used on fields of structs or variants
enum Enum {
V(()),
}
}
mod pin_project_argument {
use pin_project::pin_project;
#[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
struct RemovedReplace(#[pin] ());
#[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
struct Unexpected1(#[pin] ());
#[pin_project(Foo)] //~ ERROR unexpected argument
struct Unexpected2(#[pin] ());
#[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
struct Unexpected3(#[pin] ());
#[pin_project()] // Ok
struct Unexpected4(#[pin] ());
#[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
struct Unexpected5(#[pin] ());
#[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
struct DuplicatePinnedDrop(#[pin] ());
#[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
struct DuplicateUnsafeUnpin(#[pin] ());
#[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
struct DuplicateNotUnpin(#[pin] ());
#[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
struct Duplicate3(#[pin] ());
#[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
struct Duplicate4(#[pin] ());
#[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
struct DuplicateProject(#[pin] ());
#[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
struct DuplicateProject2(#[pin] ());
#[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
struct DuplicateProjectRef(#[pin] ());
#[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
struct DuplicateProjectReplace1(#[pin] ());
#[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
struct DuplicateProjectReplace2(#[pin] ());
#[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
struct DuplicateProjectReplace3(#[pin] ());
#[pin_project(project_replace = A)] // Ok
struct ProjectReplaceWithoutReplace(#[pin] ());
#[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
struct PinnedDropWithProjectReplace1(#[pin] ());
#[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
struct PinnedDropWithProjectReplace2(#[pin] ());
#[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
struct UnsafeUnpinWithNotUnpin1(#[pin] ());
#[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
struct UnsafeUnpinWithNotUnpin2(#[pin] ());
#[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
struct NotUnpin1(#[pin] ());
#[pin_project(Unpin)] //~ ERROR unexpected argument
struct NotUnpin2(#[pin] ());
#[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
struct Project1(#[pin] ());
#[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
struct Project2(#[pin] ());
#[pin_project(project = !)] //~ ERROR expected identifier
struct Project3(#[pin] ());
#[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
struct ProjectRef1(#[pin] ());
#[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
struct ProjectRef2(#[pin] ());
#[pin_project(project_ref = !)] //~ ERROR expected identifier
struct ProjectRef3(#[pin] ());
#[pin_project(project_replace)] // Ok
struct ProjectReplace1(#[pin] ());
#[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
struct ProjectReplace2(#[pin] ());
#[pin_project(project_replace = !)] //~ ERROR expected identifier
struct ProjectReplace3(#[pin] ());
#[pin_project(project_replace)] //~ ERROR `project_replace` argument requires a value when used on enums
enum ProjectReplaceEnum {
V(#[pin] ()),
}
}
mod pin_project_conflict_naming {
use pin_project::pin_project;
#[pin_project(project = OrigAndProj)] //~ ERROR name `OrigAndProj` is the same as the original type name
struct OrigAndProj(#[pin] ());
#[pin_project(project_ref = OrigAndProjRef)] //~ ERROR name `OrigAndProjRef` is the same as the original type name
struct OrigAndProjRef(#[pin] ());
#[pin_project(project_replace = OrigAndProjOwn)] //~ ERROR name `OrigAndProjOwn` is the same as the original type name
struct OrigAndProjOwn(#[pin] ());
#[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
struct ProjAndProjRef(#[pin] ());
#[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
struct ProjAndProjOwn(#[pin] ());
#[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
struct ProjRefAndProjOwn(#[pin] ());
}
mod pin_project_attribute {
use pin_project::pin_project;
#[pin_project]
#[pin_project] //~ ERROR duplicate #[pin_project] attribute
struct Duplicate(#[pin] ());
}
mod pin_project_item {
use pin_project::pin_project;
#[pin_project]
struct Struct {} //~ ERROR may not be used on structs with zero fields
#[pin_project]
struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
#[pin_project]
struct UnitStruct; //~ ERROR may not be used on structs with zero fields
#[pin_project]
enum EnumEmpty {} //~ ERROR may not be used on enums without variants
#[pin_project]
enum EnumDiscriminant {
V = 2, //~ ERROR may not be used on enums with discriminants
}
#[pin_project]
enum EnumZeroFields {
Unit, //~ ERROR may not be used on enums with zero fields
Tuple(),
Struct {},
}
#[pin_project]
union Union {
//~^ ERROR may only be used on structs or enums
f: (),
}
#[pin_project]
impl Impl {} //~ ERROR may only be used on structs or enums
}
// #[repr(packed)] is always detected first, even on unsupported structs.
mod pin_project_item_packed {
use pin_project::pin_project;
#[pin_project]
#[repr(packed)]
struct Struct {} //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
#[repr(packed)]
struct TupleStruct(); //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
#[repr(packed)]
struct UnitStruct; //~ ERROR may not be used on #[repr(packed)] types
}
fn main() {}

View File

@@ -0,0 +1,364 @@
error: unexpected token in attribute
--> tests/ui/pin_project/invalid.rs:8:14
|
8 | #[pin()] //~ ERROR unexpected token in attribute
| ^
error: unexpected token in attribute
--> tests/ui/pin_project/invalid.rs:13:29
|
13 | struct TupleStruct(#[pin(foo)] ()); //~ ERROR unexpected token in attribute
| ^
error: unexpected token in attribute
--> tests/ui/pin_project/invalid.rs:17:16
|
17 | V(#[pin(foo)] ()), //~ ERROR unexpected token in attribute
| ^
error: unexpected token in attribute
--> tests/ui/pin_project/invalid.rs:23:18
|
23 | #[pin(foo)] //~ ERROR unexpected token in attribute
| ^
error: duplicate #[pin] attribute
--> tests/ui/pin_project/invalid.rs:35:9
|
35 | #[pin] //~ ERROR duplicate #[pin] attribute
| ^^^^^^
error: duplicate #[pin] attribute
--> tests/ui/pin_project/invalid.rs:42:9
|
42 | #[pin]
| ^^^^^^
error: duplicate #[pin] attribute
--> tests/ui/pin_project/invalid.rs:51:13
|
51 | #[pin]
| ^^^^^^
error: duplicate #[pin] attribute
--> tests/ui/pin_project/invalid.rs:61:13
|
61 | #[pin] //~ ERROR duplicate #[pin] attribute
| ^^^^^^
error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/invalid.rs:71:5
|
71 | #[pin] //~ ERROR may only be used on fields of structs or variants
| ^^^^^^
error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/invalid.rs:79:9
|
79 | #[pin] //~ ERROR may only be used on fields of structs or variants
| ^^^^^^
error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/invalid.rs:84:5
|
84 | #[pin] //~ ERROR may only be used on fields of structs or variants
| ^^^^^^
error: `Replace` argument was removed, use `project_replace` argument instead
--> tests/ui/pin_project/invalid.rs:93:19
|
93 | #[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
| ^^^^^^^
error: expected identifier
--> tests/ui/pin_project/invalid.rs:96:31
|
96 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
| ^
error: unexpected argument: Foo
--> tests/ui/pin_project/invalid.rs:99:19
|
99 | #[pin_project(Foo)] //~ ERROR unexpected argument
| ^^^
error: expected identifier
--> tests/ui/pin_project/invalid.rs:102:19
|
102 | #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
| ^
error: expected `,`
--> tests/ui/pin_project/invalid.rs:108:30
|
108 | #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
| ^^^^^^^^^^
error: duplicate `PinnedDrop` argument
--> tests/ui/pin_project/invalid.rs:111:31
|
111 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
error: duplicate `UnsafeUnpin` argument
--> tests/ui/pin_project/invalid.rs:114:32
|
114 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^
error: duplicate `!Unpin` argument
--> tests/ui/pin_project/invalid.rs:117:27
|
117 | #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
| ^^^^^^
error: duplicate `UnsafeUnpin` argument
--> tests/ui/pin_project/invalid.rs:120:44
|
120 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^
error: duplicate `PinnedDrop` argument
--> tests/ui/pin_project/invalid.rs:123:44
|
123 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
error: duplicate `project` argument
--> tests/ui/pin_project/invalid.rs:126:32
|
126 | #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
| ^^^^^^^^^^^
error: duplicate `project` argument
--> tests/ui/pin_project/invalid.rs:129:49
|
129 | #[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
| ^^^^^^^^^^^
error: duplicate `project_ref` argument
--> tests/ui/pin_project/invalid.rs:132:36
|
132 | #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
| ^^^^^^^^^^^^^^^
error: duplicate `project_replace` argument
--> tests/ui/pin_project/invalid.rs:135:40
|
135 | #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
| ^^^^^^^^^^^^^^^^^^^
error: duplicate `project_replace` argument
--> tests/ui/pin_project/invalid.rs:138:36
|
138 | #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
| ^^^^^^^^^^^^^^^^^^^
error: duplicate `project_replace` argument
--> tests/ui/pin_project/invalid.rs:141:40
|
141 | #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
| ^^^^^^^^^^^^^^^
error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
--> tests/ui/pin_project/invalid.rs:147:19
|
147 | #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
| ^^^^^^^^^^
error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
--> tests/ui/pin_project/invalid.rs:150:49
|
150 | #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
| ^^^^^^^^^^
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
--> tests/ui/pin_project/invalid.rs:153:19
|
153 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
--> tests/ui/pin_project/invalid.rs:156:39
|
156 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
error: expected `!Unpin`, found `!`
--> tests/ui/pin_project/invalid.rs:159:19
|
159 | #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
| ^
error: unexpected argument: Unpin
--> tests/ui/pin_project/invalid.rs:162:19
|
162 | #[pin_project(Unpin)] //~ ERROR unexpected argument
| ^^^^^
error: expected `project = <identifier>`, found `project`
--> tests/ui/pin_project/invalid.rs:165:19
|
165 | #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
| ^^^^^^^
error: expected `project = <identifier>`, found `project =`
--> tests/ui/pin_project/invalid.rs:168:19
|
168 | #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
| ^^^^^^^^^
error: expected identifier
--> tests/ui/pin_project/invalid.rs:171:29
|
171 | #[pin_project(project = !)] //~ ERROR expected identifier
| ^
error: expected `project_ref = <identifier>`, found `project_ref`
--> tests/ui/pin_project/invalid.rs:174:19
|
174 | #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
| ^^^^^^^^^^^
error: expected `project_ref = <identifier>`, found `project_ref =`
--> tests/ui/pin_project/invalid.rs:177:19
|
177 | #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
| ^^^^^^^^^^^^^
error: expected identifier
--> tests/ui/pin_project/invalid.rs:180:33
|
180 | #[pin_project(project_ref = !)] //~ ERROR expected identifier
| ^
error: expected `project_replace = <identifier>`, found `project_replace =`
--> tests/ui/pin_project/invalid.rs:186:19
|
186 | #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
| ^^^^^^^^^^^^^^^^^
error: expected identifier
--> tests/ui/pin_project/invalid.rs:189:37
|
189 | #[pin_project(project_replace = !)] //~ ERROR expected identifier
| ^
error: `project_replace` argument requires a value when used on enums
--> tests/ui/pin_project/invalid.rs:192:19
|
192 | #[pin_project(project_replace)] //~ ERROR `project_replace` argument requires a value when used on enums
| ^^^^^^^^^^^^^^^
error: name `OrigAndProj` is the same as the original type name
--> tests/ui/pin_project/invalid.rs:201:29
|
201 | #[pin_project(project = OrigAndProj)] //~ ERROR name `OrigAndProj` is the same as the original type name
| ^^^^^^^^^^^
error: name `OrigAndProjRef` is the same as the original type name
--> tests/ui/pin_project/invalid.rs:204:33
|
204 | #[pin_project(project_ref = OrigAndProjRef)] //~ ERROR name `OrigAndProjRef` is the same as the original type name
| ^^^^^^^^^^^^^^
error: name `OrigAndProjOwn` is the same as the original type name
--> tests/ui/pin_project/invalid.rs:207:37
|
207 | #[pin_project(project_replace = OrigAndProjOwn)] //~ ERROR name `OrigAndProjOwn` is the same as the original type name
| ^^^^^^^^^^^^^^
error: name `A` is already specified by `project` argument
--> tests/ui/pin_project/invalid.rs:210:46
|
210 | #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
| ^
error: name `A` is already specified by `project` argument
--> tests/ui/pin_project/invalid.rs:213:50
|
213 | #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
| ^
error: name `A` is already specified by `project_ref` argument
--> tests/ui/pin_project/invalid.rs:216:54
|
216 | #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
| ^
error: duplicate #[pin_project] attribute
--> tests/ui/pin_project/invalid.rs:224:5
|
224 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
| ^^^^^^^^^^^^^^
error: #[pin_project] attribute may not be used on structs with zero fields
--> tests/ui/pin_project/invalid.rs:232:19
|
232 | struct Struct {} //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
--> tests/ui/pin_project/invalid.rs:235:23
|
235 | struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
--> tests/ui/pin_project/invalid.rs:238:12
|
238 | struct UnitStruct; //~ ERROR may not be used on structs with zero fields
| ^^^^^^^^^^
error: #[pin_project] attribute may not be used on enums without variants
--> tests/ui/pin_project/invalid.rs:241:20
|
241 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
| ^^
error: #[pin_project] attribute may not be used on enums with discriminants
--> tests/ui/pin_project/invalid.rs:245:13
|
245 | V = 2, //~ ERROR may not be used on enums with discriminants
| ^
error: #[pin_project] attribute may not be used on enums with zero fields
--> tests/ui/pin_project/invalid.rs:250:9
|
250 | / Unit, //~ ERROR may not be used on enums with zero fields
251 | | Tuple(),
252 | | Struct {},
| |__________________^
error: #[pin_project] attribute may only be used on structs or enums
--> tests/ui/pin_project/invalid.rs:256:5
|
256 | / union Union {
257 | | //~^ ERROR may only be used on structs or enums
258 | | f: (),
259 | | }
| |_____^
error: #[pin_project] attribute may only be used on structs or enums
--> tests/ui/pin_project/invalid.rs:262:5
|
262 | impl Impl {} //~ ERROR may only be used on structs or enums
| ^^^^^^^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/invalid.rs:270:12
|
270 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/invalid.rs:274:12
|
274 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/invalid.rs:278:12
|
278 | #[repr(packed)]
| ^^^^^^

View File

@@ -0,0 +1,20 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670
#[pin_project::pin_project]
struct Foo<Pinned, Unpinned> {
#[pin]
pinned: Pinned,
unpinned: Unpinned,
}
struct MyPhantomPinned(::core::marker::PhantomPinned);
impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {}
impl Unpin for Foo<MyPhantomPinned, ()> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Foo<MyPhantomPinned, ()>>()
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>`
--> tests/ui/pin_project/negative_impls_stable.rs:5:1
|
5 | #[pin_project::pin_project]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>`
...
14 | impl Unpin for Foo<MyPhantomPinned, ()> {}
| --------------------------------------- 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)

View File

@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project]
struct S<T> {
#[pin]
f: T,
}
struct __S {}
impl Unpin for __S {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
}

View File

@@ -0,0 +1,26 @@
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/overlapping_unpin_struct.rs:20:16
|
20 | is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
| ^^^^^^^^^^^^^^^^ within `_::__S<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `_::__S<'_, PhantomPinned>`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:8:8
|
8 | struct S<T> {
| ^
note: required for `S<PhantomPinned>` to implement `Unpin`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:7:1
|
7 | #[pin_project]
| ^^^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
8 | struct S<T> {
| ^^^^
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:17:16
|
17 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,36 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// https://discord.com/channels/273534239310479360/512792629516173323/870075511009857617
#![allow(hidden_glob_reexports)]
extern crate pin_project as pin_project_orig;
extern crate self as pin_project;
pub use ::pin_project_orig::*;
mod __private {
pub use ::pin_project_orig::__private::*;
pub trait Drop {}
}
use std::{marker::PhantomPinned, mem};
#[pin_project] //~ ERROR conflicting implementations of trait `_::FooMustNotImplDrop`
struct S {
#[pin]
f: (u8, PhantomPinned),
}
impl Drop for S {
fn drop(&mut self) {
let prev = &self.f.0 as *const _ as usize;
let moved = mem::take(&mut self.f); // move pinned field
let moved = &moved.0 as *const _ as usize;
assert_eq!(prev, moved); // panic
}
}
fn main() {
let mut x = Box::pin(S { f: (1, PhantomPinned) });
let _f = x.as_mut().project().f; // first mutable access
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `SMustNotImplDrop` for type `S`
--> tests/ui/pin_project/override-priv-mod.rs:18:1
|
18 | #[pin_project] //~ ERROR conflicting implementations of trait `_::FooMustNotImplDrop`
| ^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `S`
|
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,26 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
// #[repr(packed)] cannot be apply on enums and will be rejected by rustc.
// However, we should not rely on the behavior of rustc that rejects this.
// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
#[repr(packed)] //~ ERROR E0517
enum E1 {
V(()),
}
#[pin_project]
#[repr(packed)] //~ ERROR E0517
enum E2 {
V(()),
}
#[repr(packed)] //~ ERROR E0517
#[pin_project]
enum E3 {
V(()),
}
fn main() {}

View File

@@ -0,0 +1,42 @@
error: #[repr(packed)] attribute should be applied to a struct or union
--> tests/ui/pin_project/packed-enum.rs:15:8
|
15 | #[repr(packed)] //~ ERROR E0517
| ^^^^^^
error: #[repr(packed)] attribute should be applied to a struct or union
--> tests/ui/pin_project/packed-enum.rs:20:8
|
20 | #[repr(packed)] //~ ERROR E0517
| ^^^^^^
error[E0517]: attribute should be applied to a struct or union
--> tests/ui/pin_project/packed-enum.rs:9:8
|
9 | #[repr(packed)] //~ ERROR E0517
| ^^^^^^
10 | / enum E1 {
11 | | V(()),
12 | | }
| |_- not a struct or union
error[E0517]: attribute should be applied to a struct or union
--> tests/ui/pin_project/packed-enum.rs:15:8
|
15 | #[repr(packed)] //~ ERROR E0517
| ^^^^^^
16 | / enum E2 {
17 | | V(()),
18 | | }
| |_- not a struct or union
error[E0517]: attribute should be applied to a struct or union
--> tests/ui/pin_project/packed-enum.rs:20:8
|
20 | #[repr(packed)] //~ ERROR E0517
| ^^^^^^
21 | #[pin_project]
22 | / enum E3 {
23 | | V(()),
24 | | }
| |_- not a struct or union

View File

@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
// #[repr(packed = "")] is not valid format of #[repr(packed)] and will be
// rejected by rustc.
// However, we should not rely on the behavior of rustc that rejects this.
// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
// https://github.com/rust-lang/rust/issues/83921
// #[repr(packed = "")] //~ ERROR E0552
// struct S1 {
// f: (),
// }
#[pin_project]
#[repr(packed = "")] //~ ERROR attribute should not be name-value pair
struct S2 {
f: (),
}
#[repr(packed = "")] //~ ERROR attribute should not be name-value pair
#[pin_project]
struct S3 {
f: (),
}
fn main() {}

View File

@@ -0,0 +1,23 @@
error: #[repr(packed)] attribute should not be name-value pair
--> tests/ui/pin_project/packed-name-value.rs:18:8
|
18 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
| ^^^^^^^^^^^
error: #[repr(packed)] attribute should not be name-value pair
--> tests/ui/pin_project/packed-name-value.rs:23:8
|
23 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
| ^^^^^^^^^^^
error[E0693]: incorrect `repr(packed)` attribute format
--> tests/ui/pin_project/packed-name-value.rs:18:8
|
18 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
| ^^^^^^^^^^^ help: use parentheses instead: `packed()`
error[E0693]: incorrect `repr(packed)` attribute format
--> tests/ui/pin_project/packed-name-value.rs:23:8
|
23 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
| ^^^^^^^^^^^ help: use parentheses instead: `packed()`

View File

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project]
#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
struct Packed1 {
#[pin]
f: u8,
}
// Test putting 'repr' before the 'pin_project' attribute
#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
struct Packed2 {
#[pin]
f: u8,
}
#[pin_project]
#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
struct PackedN1 {
#[pin]
f: u32,
}
// Test putting 'repr' before the 'pin_project' attribute
#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
struct PackedN2 {
#[pin]
f: u32,
}
fn main() {}

View File

@@ -0,0 +1,23 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/packed.rs:6:8
|
6 | #[repr(packed, C)] //~ ERROR 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.rs:13:8
|
13 | #[repr(packed, C)] //~ ERROR 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.rs:21:8
|
21 | #[repr(packed(2))] //~ ERROR 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.rs:28:8
|
28 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^^^^

View File

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
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
#[hidden_repr(packed)]
struct A {
#[pin]
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 {
#[pin]
f: u32,
}
unsafe impl UnsafeUnpin for C {}
#[pin_project(PinnedDrop)] //~ ERROR may not be used on #[repr(packed)] types
#[hidden_repr(packed)]
struct D {
#[pin]
f: u32,
}
#[pinned_drop]
impl PinnedDrop for D {
fn drop(self: Pin<&mut Self>) {}
}
fn main() {}

View File

@@ -0,0 +1,25 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/packed_sneaky-1.rs:9:15
|
9 | #[hidden_repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/packed_sneaky-1.rs:15:1
|
15 | #[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:23:15
|
23 | #[hidden_repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/packed_sneaky-1.rs:32:15
|
32 | #[hidden_repr(packed)]
| ^^^^^^

View File

@@ -0,0 +1,14 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::hidden_repr_macro;
use pin_project::pin_project;
hidden_repr_macro! { //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
struct B {
#[pin]
f: u32,
}
}
fn main() {}

View File

@@ -0,0 +1,12 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/pin_project/packed_sneaky-2.rs:6:1
|
6 | / hidden_repr_macro! { //~ ERROR may not be used on #[repr(packed)] types
7 | | #[pin_project]
8 | | struct B {
9 | | #[pin]
... |
12 | | }
| |_^
|
= note: this error originates in the macro `hidden_repr_macro` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auxiliary_macro::{hidden_repr_macro, HiddenRepr};
use pin_project::pin_project;
hidden_repr_macro! {} //~ ERROR expected item after attributes
#[pin_project]
struct S1 {
#[pin]
f: u32,
}
macro_rules! hidden_repr_macro2 {
() => {
#[repr(packed)] //~ ERROR expected item after attributes
};
}
hidden_repr_macro2! {}
#[pin_project]
struct S2 {
#[pin]
f: u32,
}
#[derive(HiddenRepr)] //~ ERROR expected item after attributes
struct S3 {}
#[pin_project]
struct S4 {
#[pin]
f: u32,
}
fn main() {}

View File

@@ -0,0 +1,32 @@
error: expected item after attributes
--> tests/ui/pin_project/packed_sneaky-3.rs:6:1
|
6 | hidden_repr_macro! {} //~ ERROR expected item after attributes
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `hidden_repr_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected item after attributes
--> tests/ui/pin_project/packed_sneaky-3.rs:15:9
|
15 | #[repr(packed)] //~ ERROR expected item after attributes
| ^^^^^^^^^^^^^^^
...
19 | hidden_repr_macro2! {}
| ---------------------- in this macro invocation
|
= note: this error originates in the macro `hidden_repr_macro2` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected item after attributes
--> tests/ui/pin_project/packed_sneaky-3.rs:26:10
|
26 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
| ^^^^^^^^^^
|
= note: this error originates in the derive macro `HiddenRepr` (in Nightly builds, run with -Z macro-backtrace for more info)
error: proc-macro derive produced unparsable tokens
--> tests/ui/pin_project/packed_sneaky-3.rs:26:10
|
26 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
| ^^^^^^^^^^

View File

@@ -0,0 +1,15 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// https://github.com/taiki-e/pin-project/issues/342
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() {}

View File

@@ -0,0 +1,20 @@
error[E0793]: reference to packed field is unaligned
--> tests/ui/pin_project/packed_sneaky-4.rs:12:5
|
12 | f: u32,
| ^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)
error[E0793]: 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: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)

View File

@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project(project_replace)] //~ ERROR E0277
struct Struct<T: ?Sized> {
f: T,
}
#[pin_project(project_replace)] //~ ERROR E0277
struct TupleStruct<T: ?Sized>(T);
fn main() {}

View File

@@ -0,0 +1,160 @@
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> tests/ui/pin_project/project_replace_unsized.rs:6:8
|
6 | struct Struct<T: ?Sized> {
| ^^^^^^^-^^^^^^^^^
| | |
| | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
note: required because it appears within the type `__StructProjectionOwned<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:6:8
|
6 | struct Struct<T: ?Sized> {
| ^^^^^^
= note: the return type of a function must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
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.rs:11:8
|
11 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^^-^^^^^^^^^
| | |
| | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
note: required because it appears within the type `__TupleStructProjectionOwned<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:11:8
|
11 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^
= note: the return type of a function must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
11 - struct TupleStruct<T: ?Sized>(T);
11 + struct TupleStruct<T>(T);
|
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> tests/ui/pin_project/project_replace_unsized.rs:5:15
|
5 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6 | struct Struct<T: ?Sized> {
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `Struct<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:6:8
|
6 | struct Struct<T: ?Sized> {
| ^^^^^^
= help: unsized fn params are gated as an unstable feature
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
6 - struct Struct<T: ?Sized> {
6 + struct Struct<T> {
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
5 | #[pin_project(&project_replace)] //~ ERROR E0277
| +
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> tests/ui/pin_project/project_replace_unsized.rs:5:1
|
5 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6 | struct Struct<T: ?Sized> {
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `Struct<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:6:8
|
6 | struct Struct<T: ?Sized> {
| ^^^^^^
note: required by an implicit `Sized` bound in `UnsafeOverwriteGuard`
--> src/lib.rs
|
| pub struct UnsafeOverwriteGuard<T> {
| ^ required by the implicit `Sized` requirement on this type parameter in `UnsafeOverwriteGuard`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
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.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 `Sized`
7 | f: T,
| ^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `std::ptr::read`
--> $RUST/core/src/ptr/mod.rs
|
| pub const unsafe fn read<T>(src: *const T) -> T {
| ^ required by the implicit `Sized` requirement on this type parameter in `read`
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
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.rs:10:15
|
10 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
11 | struct TupleStruct<T: ?Sized>(T);
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `TupleStruct<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:11:8
|
11 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^
= help: unsized fn params are gated as an unstable feature
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
11 - struct TupleStruct<T: ?Sized>(T);
11 + struct TupleStruct<T>(T);
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
10 | #[pin_project(&project_replace)] //~ ERROR E0277
| +
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> tests/ui/pin_project/project_replace_unsized.rs:10:1
|
10 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
11 | struct TupleStruct<T: ?Sized>(T);
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `TupleStruct<T>`
--> tests/ui/pin_project/project_replace_unsized.rs:11:8
|
11 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^
note: required by an implicit `Sized` bound in `UnsafeOverwriteGuard`
--> src/lib.rs
|
| pub struct UnsafeOverwriteGuard<T> {
| ^ required by the implicit `Sized` requirement on this type parameter in `UnsafeOverwriteGuard`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
11 - struct TupleStruct<T: ?Sized>(T);
11 + struct TupleStruct<T>(T);
|

View File

@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
#![allow(internal_features)]
#![feature(unsized_fn_params)]
use pin_project::pin_project;
#[pin_project(project_replace)] //~ ERROR E0277
struct Struct<T: ?Sized> {
f: T,
}
#[pin_project(project_replace)] //~ ERROR E0277
struct TupleStruct<T: ?Sized>(T);
fn main() {}

View File

@@ -0,0 +1,112 @@
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:9:8
|
9 | struct Struct<T: ?Sized> {
| ^^^^^^^-^^^^^^^^^
| | |
| | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
note: required because it appears within the type `__StructProjectionOwned<T>`
--> tests/ui/pin_project/project_replace_unsized_fn_params.rs:9:8
|
9 | struct Struct<T: ?Sized> {
| ^^^^^^
= note: the return type of a function must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
9 - struct Struct<T: ?Sized> {
9 + 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:14:8
|
14 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^^-^^^^^^^^^
| | |
| | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
note: required because it appears within the type `__TupleStructProjectionOwned<T>`
--> tests/ui/pin_project/project_replace_unsized_fn_params.rs:14:8
|
14 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^
= note: the return type of a function must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
14 - struct TupleStruct<T: ?Sized>(T);
14 + struct TupleStruct<T>(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:8:1
|
8 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9 | struct Struct<T: ?Sized> {
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `Struct<T>`
--> tests/ui/pin_project/project_replace_unsized_fn_params.rs:9:8
|
9 | struct Struct<T: ?Sized> {
| ^^^^^^
note: required by an implicit `Sized` bound in `UnsafeOverwriteGuard`
--> src/lib.rs
|
| pub struct UnsafeOverwriteGuard<T> {
| ^ required by the implicit `Sized` requirement on this type parameter in `UnsafeOverwriteGuard`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
9 - struct Struct<T: ?Sized> {
9 + 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:10:5
|
8 | #[pin_project(project_replace)] //~ ERROR E0277
| ------------------------------- required by a bound introduced by this call
9 | struct Struct<T: ?Sized> {
| - this type parameter needs to be `Sized`
10 | f: T,
| ^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `std::ptr::read`
--> $RUST/core/src/ptr/mod.rs
|
| pub const unsafe fn read<T>(src: *const T) -> T {
| ^ required by the implicit `Sized` requirement on this type parameter in `read`
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
9 - struct Struct<T: ?Sized> {
9 + 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:13:1
|
13 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
14 | struct TupleStruct<T: ?Sized>(T);
| - this type parameter needs to be `Sized`
|
note: required because it appears within the type `TupleStruct<T>`
--> tests/ui/pin_project/project_replace_unsized_fn_params.rs:14:8
|
14 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^
note: required by an implicit `Sized` bound in `UnsafeOverwriteGuard`
--> src/lib.rs
|
| pub struct UnsafeOverwriteGuard<T> {
| ^ required by the implicit `Sized` requirement on this type parameter in `UnsafeOverwriteGuard`
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
14 - struct TupleStruct<T: ?Sized>(T);
14 + struct TupleStruct<T>(T);
|

View File

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::{marker::PhantomPinned, pin::Pin};
use auxiliary_macro::remove_attr;
use pin_project::pin_project;
fn is_unpin<T: Unpin>() {}
#[pin_project]
#[remove_attr(field_all)]
struct A {
#[pin]
f: PhantomPinned,
}
#[remove_attr(field_all)]
#[pin_project]
struct B {
#[pin]
f: PhantomPinned,
}
fn main() {
is_unpin::<A>();
is_unpin::<B>();
let mut x = A { f: PhantomPinned };
let x = Pin::new(&mut x).project();
let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
let mut x = B { f: PhantomPinned };
let x = Pin::new(&mut x).project();
let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
}

View File

@@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> tests/ui/pin_project/remove-attr-from-field.rs:30:38
|
30 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
| ----------------------- ^^^ expected `Pin<&mut PhantomPinned>`, found `&mut PhantomPinned`
| |
| expected due to this
|
= note: expected struct `Pin<&mut PhantomPinned>`
found mutable reference `&mut PhantomPinned`
error[E0308]: mismatched types
--> tests/ui/pin_project/remove-attr-from-field.rs:34:38
|
34 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
| ----------------------- ^^^ expected `Pin<&mut PhantomPinned>`, found `&mut PhantomPinned`
| |
| expected due to this
|
= note: expected struct `Pin<&mut PhantomPinned>`
found mutable reference `&mut PhantomPinned`

View File

@@ -0,0 +1,49 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::{marker::PhantomPinned, pin::Pin};
use auxiliary_macro::remove_attr;
use pin_project::pin_project;
fn is_unpin<T: Unpin>() {}
#[pin_project]
#[remove_attr(struct_all)]
struct A {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
f: PhantomPinned,
}
#[remove_attr(struct_all)]
#[pin_project]
struct B {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
f: PhantomPinned,
}
#[pin_project] //~ ERROR has been removed
#[remove_attr(struct_pin)]
struct C {
f: PhantomPinned,
}
#[remove_attr(struct_pin)]
#[pin_project] // Ok
struct D {
f: PhantomPinned,
}
fn main() {
is_unpin::<A>(); //~ ERROR E0277
is_unpin::<B>(); //~ ERROR E0277
is_unpin::<D>(); // Ok
let mut x = A { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
let mut x = B { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
let mut x = D { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ Ok
}

View File

@@ -0,0 +1,117 @@
error: #[pin_project] attribute has been removed
--> tests/ui/pin_project/remove-attr-from-struct.rs:24:1
|
24 | #[pin_project] //~ ERROR has been removed
| ^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
error: cannot find attribute `pin` in this scope
--> tests/ui/pin_project/remove-attr-from-struct.rs:20:7
|
20 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
| ^^^
error: cannot find attribute `pin` in this scope
--> tests/ui/pin_project/remove-attr-from-struct.rs:13:7
|
13 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
| ^^^
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/remove-attr-from-struct.rs:37:16
|
37 | is_unpin::<A>(); //~ ERROR E0277
| ^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `A`
--> tests/ui/pin_project/remove-attr-from-struct.rs:12:8
|
12 | struct A {
| ^
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/remove-attr-from-struct.rs:8:16
|
8 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/remove-attr-from-struct.rs:38:16
|
38 | is_unpin::<B>(); //~ ERROR E0277
| ^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `B`
--> tests/ui/pin_project/remove-attr-from-struct.rs:19:8
|
19 | struct B {
| ^
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/remove-attr-from-struct.rs:8:16
|
8 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/remove-attr-from-struct.rs:42:22
|
42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
| -------- ^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
| |
| required by a bound introduced by this call
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `A`
--> tests/ui/pin_project/remove-attr-from-struct.rs:12:8
|
12 | struct A {
| ^
note: required by a bound in `Pin::<Ptr>::new`
--> $RUST/core/src/pin.rs
|
| impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
| ^^^^^ required by this bound in `Pin::<Ptr>::new`
...
| pub const fn new(pointer: Ptr) -> Pin<Ptr> {
| --- required by a bound in this associated function
error[E0599]: no method named `project` found for struct `Pin<&mut A>` in the current scope
--> tests/ui/pin_project/remove-attr-from-struct.rs:42:30
|
42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
| ^^^^^^^ method not found in `Pin<&mut A>`
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/pin_project/remove-attr-from-struct.rs:45:22
|
45 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
| -------- ^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
| |
| required by a bound introduced by this call
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `B`
--> tests/ui/pin_project/remove-attr-from-struct.rs:19:8
|
19 | struct B {
| ^
note: required by a bound in `Pin::<Ptr>::new`
--> $RUST/core/src/pin.rs
|
| impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
| ^^^^^ required by this bound in `Pin::<Ptr>::new`
...
| pub const fn new(pointer: Ptr) -> Pin<Ptr> {
| --- required by a bound in this associated function
error[E0599]: no method named `project` found for struct `Pin<&mut B>` in the current scope
--> tests/ui/pin_project/remove-attr-from-struct.rs:45:30
|
45 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
| ^^^^^^^ method not found in `Pin<&mut B>`

View File

@@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
#![deny(renamed_and_removed_lints)]
#![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references`
// This lint was removed in https://github.com/rust-lang/rust/pull/82525 (nightly-2021-03-28).
// Refs:
// - https://github.com/rust-lang/rust/pull/82525
// - https://github.com/rust-lang/rust/issues/46043
#[repr(packed)]
struct Packed {
f: u32,
}
#[repr(packed(2))]
struct PackedN {
f: u32,
}
fn main() {
let a = Packed { f: 1 };
let _ = &a.f;
let b = PackedN { f: 1 };
let _ = &b.f;
}

View File

@@ -0,0 +1,31 @@
error: lint `safe_packed_borrows` has been removed: converted into hard error, see issue #82523 <https://github.com/rust-lang/rust/issues/82523> for more information
--> tests/ui/pin_project/safe_packed_borrows.rs:4:9
|
4 | #![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references`
| ^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/pin_project/safe_packed_borrows.rs:3:9
|
3 | #![deny(renamed_and_removed_lints)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0793]: reference to packed field is unaligned
--> tests/ui/pin_project/safe_packed_borrows.rs:23:13
|
23 | let _ = &a.f;
| ^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)
error[E0793]: reference to packed field is unaligned
--> tests/ui/pin_project/safe_packed_borrows.rs:26:13
|
26 | let _ = &b.f;
| ^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)

View File

@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Refs: https://github.com/rust-lang/rust/issues/82523
#[repr(packed)]
struct Packed {
f: u32,
}
#[repr(packed(2))]
struct PackedN {
f: u32,
}
fn main() {
let a = Packed { f: 1 };
let _ = &a.f; //~ ERROR reference to packed field is unaligned
let b = PackedN { f: 1 };
let _ = &b.f; //~ ERROR reference to packed field is unaligned
}

View File

@@ -0,0 +1,19 @@
error[E0793]: reference to packed field is unaligned
--> tests/ui/pin_project/unaligned_references.rs:17:13
|
17 | let _ = &a.f; //~ ERROR reference to packed field is unaligned
| ^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)
error[E0793]: reference to packed field is unaligned
--> tests/ui/pin_project/unaligned_references.rs:20:13
|
20 | let _ = &b.f; //~ ERROR reference to packed field is unaligned
| ^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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)

View File

@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project]
struct S {
#[pin]
f: u8,
}
impl Unpin for __S {} //~ ERROR E0412,E0321
fn main() {}

View File

@@ -0,0 +1,5 @@
error[E0412]: cannot find type `__S` in this scope
--> tests/ui/pin_project/unpin_sneaky.rs:11:16
|
11 | impl Unpin for __S {} //~ ERROR E0412,E0321
| ^^^ not found in this scope

View File

@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Only named projected types can be imported.
// See import_unnamed.rs for unnamed projected types.
#![allow(unused_imports)]
mod pub_ {
use pin_project::pin_project;
#[pin_project(project = DProj, project_ref = DProjRef)]
pub struct Default(());
#[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
pub struct Replace(());
}
pub mod pub_use {
#[rustfmt::skip]
pub use crate::pub_::DProj; //~ ERROR E0365
#[rustfmt::skip]
pub use crate::pub_::DProjRef; //~ ERROR E0365
#[rustfmt::skip]
pub use crate::pub_::RProj; //~ ERROR E0365
#[rustfmt::skip]
pub use crate::pub_::RProjOwn; //~ ERROR E0365
#[rustfmt::skip]
pub use crate::pub_::RProjRef; //~ ERROR E0365
// Confirm that the visibility of the original type is not changed.
pub use crate::pub_::{Default, Replace};
}
pub mod pub_use2 {
// Ok
pub(crate) use crate::pub_::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
}
mod pub_crate {
use pin_project::pin_project;
#[pin_project(project = DProj, project_ref = DProjRef)]
pub(crate) struct Default(());
#[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
pub(crate) struct Replace(());
}
pub mod pub_crate_use {
// Ok
pub(crate) use crate::pub_crate::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
}
fn main() {}

View File

@@ -0,0 +1,39 @@
error[E0365]: `DProj` is only public within the crate, and cannot be re-exported outside
--> tests/ui/pin_project/visibility.rs:19:13
|
19 | pub use crate::pub_::DProj; //~ ERROR E0365
| ^^^^^^^^^^^^^^^^^^ re-export of crate public `DProj`
|
= note: consider declaring type or module `DProj` with `pub`
error[E0365]: `DProjRef` is only public within the crate, and cannot be re-exported outside
--> tests/ui/pin_project/visibility.rs:21:13
|
21 | pub use crate::pub_::DProjRef; //~ ERROR E0365
| ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `DProjRef`
|
= note: consider declaring type or module `DProjRef` with `pub`
error[E0365]: `RProj` is only public within the crate, and cannot be re-exported outside
--> tests/ui/pin_project/visibility.rs:23:13
|
23 | pub use crate::pub_::RProj; //~ ERROR E0365
| ^^^^^^^^^^^^^^^^^^ re-export of crate public `RProj`
|
= note: consider declaring type or module `RProj` with `pub`
error[E0365]: `RProjOwn` is only public within the crate, and cannot be re-exported outside
--> tests/ui/pin_project/visibility.rs:25:13
|
25 | pub use crate::pub_::RProjOwn; //~ ERROR E0365
| ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `RProjOwn`
|
= note: consider declaring type or module `RProjOwn` with `pub`
error[E0365]: `RProjRef` is only public within the crate, and cannot be re-exported outside
--> tests/ui/pin_project/visibility.rs:27:13
|
27 | pub use crate::pub_::RProjRef; //~ ERROR E0365
| ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `RProjRef`
|
= note: consider declaring type or module `RProjRef` with `pub`

View File

@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Struct {
f: bool,
}
#[pinned_drop]
impl PinnedDrop for Struct {
fn drop(mut self: Pin<&mut Self>) {
__drop_inner(__self);
}
}
fn main() {}

View File

@@ -0,0 +1,17 @@
error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> tests/ui/pinned_drop/call-drop-inner.rs:15:9
|
15 | __drop_inner(__self);
| ^^^^^^^^^^^^ ------ unexpected argument of type `Pin<&mut Struct>`
|
note: function defined here
--> tests/ui/pinned_drop/call-drop-inner.rs:12:1
|
12 | #[pinned_drop]
| ^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `pinned_drop` (in Nightly builds, run with -Z macro-backtrace for more info)
help: remove the extra argument
|
15 - __drop_inner(__self);
15 + __drop_inner();
|

View File

@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
// In `Drop` impl, the implementor must specify the same requirement as type definition.
struct DropImpl<T> {
f: T,
}
impl<T: Unpin> Drop for DropImpl<T> {
//~^ ERROR E0367
fn drop(&mut self) {}
}
#[pin_project(PinnedDrop)] //~ ERROR E0277
struct PinnedDropImpl<T> {
#[pin]
f: T,
}
#[pinned_drop]
impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
fn drop(self: Pin<&mut Self>) {}
}
fn main() {}

View File

@@ -0,0 +1,34 @@
error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
--> tests/ui/pinned_drop/conditional-drop-impl.rs:13:9
|
13 | impl<T: Unpin> Drop for DropImpl<T> {
| ^^^^^
|
note: the implementor must specify the same requirement
--> tests/ui/pinned_drop/conditional-drop-impl.rs:9:1
|
9 | struct DropImpl<T> {
| ^^^^^^^^^^^^^^^^^^
error[E0277]: `T` cannot be unpinned
--> tests/ui/pinned_drop/conditional-drop-impl.rs:18:15
|
18 | #[pin_project(PinnedDrop)] //~ ERROR E0277
| ^^^^^^^^^^ the trait `Unpin` is not implemented for `T`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required for `PinnedDropImpl<T>` to implement `PinnedDrop`
--> tests/ui/pinned_drop/conditional-drop-impl.rs:25:16
|
24 | #[pinned_drop]
| -------------- in this procedural macro expansion
25 | impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
| ----- ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the attribute macro `pinned_drop` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T` with trait `Unpin`
|
19 | struct PinnedDropImpl<T: std::marker::Unpin> {
| ++++++++++++++++++++

View File

@@ -0,0 +1,11 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project(PinnedDrop)] //~ ERROR E0277
struct Struct {
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error[E0277]: the trait bound `Struct: PinnedDrop` is not satisfied
--> tests/ui/pinned_drop/forget-pinned-drop-impl.rs:5:15
|
5 | #[pin_project(PinnedDrop)] //~ ERROR E0277
| ^^^^^^^^^^ the trait `PinnedDrop` is not implemented for `Struct`

View File

@@ -0,0 +1,16 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// by-ref binding `ref (mut) self` and sub-patterns `@` are not allowed in receivers (rejected by rustc).
use std::pin::Pin;
struct S {}
impl S {
fn take_ref_self(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
fn take_ref_mut_self(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
}
fn main() {}

View File

@@ -0,0 +1,25 @@
error: expected identifier, found keyword `self`
--> tests/ui/pinned_drop/invalid-self.rs:10:26
|
10 | fn take_ref_self(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
| ^^^^ expected identifier, found keyword
error: expected identifier, found keyword `self`
--> tests/ui/pinned_drop/invalid-self.rs:11:34
|
11 | fn take_ref_mut_self(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
| ^^^^ expected identifier, found keyword
error: expected parameter name, found `@`
--> tests/ui/pinned_drop/invalid-self.rs:13:25
|
13 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
| ^ expected parameter name
error: expected one of `)`, `,`, or `:`, found `@`
--> tests/ui/pinned_drop/invalid-self.rs:13:25
|
13 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
| -^ expected one of `)`, `,`, or `:`
| |
| help: missing `,`

View File

@@ -0,0 +1,233 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
mod argument {
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct UnexpectedArg1(());
#[pinned_drop(foo)] //~ ERROR unexpected argument
impl PinnedDrop for UnexpectedArg1 {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct UnexpectedArg2(());
#[pinned_drop()] // Ok
impl PinnedDrop for UnexpectedArg2 {
fn drop(self: Pin<&mut Self>) {}
}
}
mod attribute {
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Duplicate(());
#[pinned_drop]
#[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute
impl PinnedDrop for Duplicate {
fn drop(self: Pin<&mut Self>) {}
}
}
mod item {
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct TraitImpl(());
#[pinned_drop]
impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
#[pin_project(PinnedDrop)]
struct InherentImpl(());
#[pinned_drop]
impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
#[pinned_drop]
fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
}
mod unsafety {
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Impl(());
#[pinned_drop]
unsafe impl PinnedDrop for Impl {
//~^ ERROR implementing the trait `PinnedDrop` is not unsafe
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct Method(());
#[pinned_drop]
impl PinnedDrop for Method {
unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
}
}
mod assoc_item {
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Empty(());
#[pinned_drop]
impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop`
#[pin_project(PinnedDrop)]
struct Const1(());
#[pinned_drop]
impl PinnedDrop for Const1 {
const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct Const2(());
#[pinned_drop]
impl PinnedDrop for Const2 {
fn drop(self: Pin<&mut Self>) {}
const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
}
#[pin_project(PinnedDrop)]
struct Type1(());
#[pinned_drop]
impl PinnedDrop for Type1 {
type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct Type2(());
#[pinned_drop]
impl PinnedDrop for Type2 {
fn drop(self: Pin<&mut Self>) {}
type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
}
#[pin_project(PinnedDrop)]
struct Duplicate(());
#[pinned_drop]
impl PinnedDrop for Duplicate {
fn drop(self: Pin<&mut Self>) {}
fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
}
}
mod method {
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct RetUnit(());
#[pinned_drop]
impl PinnedDrop for RetUnit {
fn drop(self: Pin<&mut Self>) -> () {} // Ok
}
#[pin_project(PinnedDrop)]
struct RetTy(());
#[pinned_drop]
impl PinnedDrop for RetTy {
fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type
}
#[pin_project(PinnedDrop)]
struct NoArg(());
#[pinned_drop]
impl PinnedDrop for NoArg {
fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct MultiArg(());
#[pinned_drop]
impl PinnedDrop for MultiArg {
fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct InvalidArg1(());
#[pinned_drop]
impl PinnedDrop for InvalidArg1 {
fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct InvalidArg2(());
#[pinned_drop]
impl PinnedDrop for InvalidArg2 {
fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct InvalidArg3(());
#[pinned_drop]
impl PinnedDrop for InvalidArg3 {
fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct InvalidArg4(());
#[pinned_drop]
impl PinnedDrop for InvalidArg4 {
fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
}
#[pin_project(PinnedDrop)]
struct InvalidName(());
#[pinned_drop]
impl PinnedDrop for InvalidName {
fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop`
}
}
mod self_ty {
use pin_project::pinned_drop;
#[pinned_drop]
impl PinnedDrop for () {
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
fn drop(self: Pin<&mut Self>) {}
}
#[pinned_drop]
impl PinnedDrop for &mut A {
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
fn drop(self: Pin<&mut Self>) {}
}
#[pinned_drop]
impl PinnedDrop for [A] {
//~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
fn drop(self: Pin<&mut Self>) {}
}
}
fn main() {}

View File

@@ -0,0 +1,143 @@
error: unexpected argument: `foo`
--> tests/ui/pinned_drop/invalid.rs:11:19
|
11 | #[pinned_drop(foo)] //~ ERROR unexpected argument
| ^^^
error: duplicate #[pinned_drop] attribute
--> tests/ui/pinned_drop/invalid.rs:32:5
|
32 | #[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute
| ^^^^^^^^^^^^^^
error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
--> tests/ui/pinned_drop/invalid.rs:45:10
|
45 | impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
| ^^^^
error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
--> tests/ui/pinned_drop/invalid.rs:51:10
|
51 | impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
| ^^^^^^^^^^^^
error: expected `impl`
--> tests/ui/pinned_drop/invalid.rs:54:5
|
54 | fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
| ^^
error: implementing the trait `PinnedDrop` is not unsafe
--> tests/ui/pinned_drop/invalid.rs:64:5
|
64 | unsafe impl PinnedDrop for Impl {
| ^^^^^^
error: implementing the method `drop` is not unsafe
--> tests/ui/pinned_drop/invalid.rs:74:9
|
74 | unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
| ^^^^^^
error: not all trait items implemented, missing: `drop`
--> tests/ui/pinned_drop/invalid.rs:85:5
|
85 | impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: const `A` is not a member of trait `PinnedDrop`
--> tests/ui/pinned_drop/invalid.rs:92:9
|
92 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
| ^^^^^^^^^^^^^^^^
error: const `A` is not a member of trait `PinnedDrop`
--> tests/ui/pinned_drop/invalid.rs:102:9
|
102 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
| ^^^^^^^^^^^^^^^^
error: type `A` is not a member of trait `PinnedDrop`
--> tests/ui/pinned_drop/invalid.rs:110:9
|
110 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
| ^^^^^^^^^^^^
error: type `A` is not a member of trait `PinnedDrop`
--> tests/ui/pinned_drop/invalid.rs:120:9
|
120 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
| ^^^^^^^^^^^^
error: duplicate definitions with name `drop`
--> tests/ui/pinned_drop/invalid.rs:129:9
|
129 | fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: method `drop` must return the unit type
--> tests/ui/pinned_drop/invalid.rs:151:42
|
151 | fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type
| ^^^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:159:16
|
159 | fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:167:17
|
167 | fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:175:17
|
175 | fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^^^^^^^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:183:17
|
183 | fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^^^^^^^^^^^^^^^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:191:17
|
191 | fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^^^^^^^^^^^^^^^
error: method `drop` must take an argument `self: Pin<&mut Self>`
--> tests/ui/pinned_drop/invalid.rs:199:17
|
199 | fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
| ^^^^^^^^^^^^^^^^^^
error: method `pinned_drop` is not a member of trait `PinnedDrop`
--> tests/ui/pinned_drop/invalid.rs:207:12
|
207 | fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop`
| ^^^^^^^^^^^
error: implementing the trait `PinnedDrop` on this type is unsupported
--> tests/ui/pinned_drop/invalid.rs:215:25
|
215 | impl PinnedDrop for () {
| ^^
error: implementing the trait `PinnedDrop` on this type is unsupported
--> tests/ui/pinned_drop/invalid.rs:221:25
|
221 | impl PinnedDrop for &mut A {
| ^^^^^^
error: implementing the trait `PinnedDrop` on this type is unsupported
--> tests/ui/pinned_drop/invalid.rs:227:25
|
227 | impl PinnedDrop for [A] {
| ^^^

View File

@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project]
struct S {
#[pin]
f: u8,
}
#[pinned_drop]
impl PinnedDrop for S {
//~^ ERROR E0119
fn drop(self: Pin<&mut Self>) {}
}
fn main() {}

View File

@@ -0,0 +1,8 @@
error[E0119]: conflicting implementations of trait `PinnedDrop` for type `S`
--> tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs:14:1
|
7 | #[pin_project]
| -------------- first implementation here
...
14 | impl PinnedDrop for S {
| ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S`

View File

@@ -0,0 +1,60 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
pub mod self_in_macro_def {
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
pub struct S {
f: (),
}
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
macro_rules! t {
() => {{
let _ = self; //~ ERROR E0434
fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
}};
}
t!();
}
}
}
pub mod self_span {
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
pub struct S {
f: (),
}
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
let _: () = self; //~ ERROR E0308
let _: Self = Self; //~ ERROR E0423
}
}
#[pin_project(PinnedDrop)]
pub enum E {
V { f: () },
}
#[pinned_drop]
impl PinnedDrop for E {
fn drop(self: Pin<&mut Self>) {
let _: () = self; //~ ERROR E0308
let _: Self = Self::V; //~ ERROR E0533
}
}
}
fn main() {}

View File

@@ -0,0 +1,67 @@
error: `self` parameter is only allowed in associated functions
--> tests/ui/pinned_drop/self.rs:20:26
|
20 | fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
| ^^^^ not semantically valid as function parameter
...
23 | t!();
| ---- in this macro invocation
|
= note: associated functions are those in `impl` or `trait` definitions
= note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0434]: can't capture dynamic environment in a fn item
--> tests/ui/pinned_drop/self.rs:18:29
|
18 | let _ = self; //~ ERROR E0434
| ^^^^
...
23 | t!();
| ---- in this macro invocation
|
= help: use the `|| { ... }` closure form instead
= note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0423]: expected value, found struct `S`
--> tests/ui/pinned_drop/self.rs:42:27
|
34 | / pub struct S {
35 | | f: (),
36 | | }
| |_____- `S` defined here
...
42 | let _: Self = Self; //~ ERROR E0423
| ^^^^ help: use struct literal syntax instead: `S { f: val }`
error[E0308]: mismatched types
--> tests/ui/pinned_drop/self.rs:41:25
|
41 | let _: () = self; //~ ERROR E0308
| -- ^^^^ expected `()`, found `Pin<&mut S>`
| |
| expected due to this
|
= note: expected unit type `()`
found struct `Pin<&mut self_span::S>`
error[E0308]: mismatched types
--> tests/ui/pinned_drop/self.rs:54:25
|
54 | let _: () = self; //~ ERROR E0308
| -- ^^^^ expected `()`, found `Pin<&mut E>`
| |
| expected due to this
|
= note: expected unit type `()`
found struct `Pin<&mut E>`
error[E0533]: expected value, found struct variant `E::V`
--> tests/ui/pinned_drop/self.rs:55:27
|
55 | let _: Self = Self::V; //~ ERROR E0533
| ^^^^^^^ not a value
|
help: you might have meant to create a new value of the struct
|
55 | let _: Self = Self::V { f: /* value */ }; //~ ERROR E0533
| ++++++++++++++++++

View File

@@ -0,0 +1,20 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct S {
#[pin]
f: u8,
}
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
}
}
fn main() {}

View File

@@ -0,0 +1,10 @@
error[E0133]: call to unsafe function `Pin::<&'a mut T>::get_unchecked_mut` is unsafe and requires unsafe function or block
--> tests/ui/pinned_drop/unsafe-call.rs:16:9
|
13 | #[pinned_drop]
| -------------- items do not inherit unsafety from separate enclosing items
...
16 | self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
use pin_project::pin_project;
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Bar<T, U> {}
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
fn main() {}

View File

@@ -0,0 +1,26 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<_, _>`
--> tests/ui/unsafe_unpin/conflict-unpin.rs:5:15
|
5 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
| ^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
12 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
| --------------------------------------------- first implementation here
error[E0119]: conflicting implementations of trait `Unpin` for type `Bar<_, _>`
--> tests/ui/unsafe_unpin/conflict-unpin.rs:14:15
|
14 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
| ^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
21 | impl<T, U> Unpin for Bar<T, U> {}
| ------------------------------ first implementation here
error[E0119]: conflicting implementations of trait `Unpin` for type `Baz<_, _>`
--> tests/ui/unsafe_unpin/conflict-unpin.rs:23:15
|
23 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
| ^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
30 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
| -------------------------------------------- first implementation here

View File

@@ -0,0 +1,22 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670
#[pin_project::pin_project(UnsafeUnpin)]
struct Foo<Pinned, Unpinned> {
#[pin]
pinned: Pinned,
unpinned: Unpinned,
}
unsafe impl<Pinned: Unpin, Unpinned> pin_project::UnsafeUnpin for Foo<Pinned, Unpinned> {}
struct MyPhantomPinned(::core::marker::PhantomPinned);
impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {}
impl Unpin for Foo<MyPhantomPinned, ()> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Foo<MyPhantomPinned, ()>>()
}

View File

@@ -0,0 +1,8 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>`
--> tests/ui/unsafe_unpin/negative_impls_stable.rs:5:28
|
5 | #[pin_project::pin_project(UnsafeUnpin)]
| ^^^^^^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>`
...
16 | impl Unpin for Foo<MyPhantomPinned, ()> {}
| --------------------------------------- first implementation here

View File

@@ -0,0 +1,7 @@
# UI tests for unstable features
These tests check how the guarantees and features provided by pin-project
interact with unstable language features.
The names of the files contained in this directory need to begin with the name
of the feature.

View File

@@ -0,0 +1,22 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Note: If you change this test, change 'marker_trait_attr.rs' at the same time.
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
f: T,
}
// unsound Unpin impl
impl<T> Unpin for Struct<T> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Struct<PhantomPinned>>()
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Struct<_>`
--> tests/ui/unstable-features/marker_trait_attr-feature-gate.rs:9:1
|
9 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
...
16 | impl<T> Unpin for Struct<T> {}
| --------------------------- 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)

View File

@@ -0,0 +1,28 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Note: If you change this test, change 'marker_trait_attr-feature-gate.rs' at the same time.
// marker_trait_attr
// Tracking issue: https://github.com/rust-lang/rust/issues/29864
#![feature(marker_trait_attr)]
// See https://github.com/taiki-e/pin-project/issues/105#issuecomment-535355974
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
f: T,
}
// unsound Unpin impl
impl<T> Unpin for Struct<T> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Struct<PhantomPinned>>()
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Struct<_>`
--> tests/ui/unstable-features/marker_trait_attr.rs:15:1
|
15 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
...
22 | impl<T> Unpin for Struct<T> {}
| --------------------------- 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)

View File

@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
#![feature(negative_impls)]
// https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.3A.20backlog.20bonanza/near/269471299
// https://github.com/taiki-e/pin-project/issues/340
#[pin_project::pin_project]
struct Foo<Pinned, Unpinned> {
#[pin]
pinned: Pinned,
unpinned: Unpinned,
}
struct MyPhantomPinned {}
impl !Unpin for MyPhantomPinned {}
impl Unpin for Foo<MyPhantomPinned, ()> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Foo<MyPhantomPinned, ()>>()
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>`
--> tests/ui/unstable-features/negative_impls.rs:8:1
|
8 | #[pin_project::pin_project]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>`
...
17 | impl Unpin for Foo<MyPhantomPinned, ()> {}
| --------------------------------------- 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)

View File

@@ -0,0 +1,22 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Note: If you change this test, change 'overlapping_marker_traits.rs' at the same time.
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
f: T,
}
// unsound Unpin impl
impl<T> Unpin for Struct<T> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Struct<PhantomPinned>>()
}

View File

@@ -0,0 +1,10 @@
error[E0119]: conflicting implementations of trait `Unpin` for type `Struct<_>`
--> tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs:9:1
|
9 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
...
16 | impl<T> Unpin for Struct<T> {}
| --------------------------- 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)

View File

@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Note: If you change this test, change 'overlapping_marker_traits-feature-gate.rs' at the same time.
// This feature could break the guarantee for Unpin provided by pin-project,
// but was removed in https://github.com/rust-lang/rust/pull/68544 (nightly-2020-02-06).
// Refs:
// - https://github.com/rust-lang/rust/issues/29864#issuecomment-515780867
// - https://github.com/taiki-e/pin-project/issues/105
// overlapping_marker_traits
// Tracking issue: https://github.com/rust-lang/rust/issues/29864
#![feature(overlapping_marker_traits)]
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project]
struct Struct<T> {
#[pin]
f: T,
}
// unsound Unpin impl
impl<T> Unpin for Struct<T> {}
fn is_unpin<T: Unpin>() {}
fn main() {
is_unpin::<Struct<PhantomPinned>>()
}

View File

@@ -0,0 +1,18 @@
error[E0557]: feature has been removed
--> tests/ui/unstable-features/overlapping_marker_traits.rs:13:12
|
13 | #![feature(overlapping_marker_traits)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in favor of `#![feature(marker_trait_attr)]`
error[E0119]: conflicting implementations of trait `Unpin` for type `Struct<_>`
--> tests/ui/unstable-features/overlapping_marker_traits.rs:19:1
|
19 | #[pin_project]
| ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
...
26 | impl<T> Unpin for Struct<T> {}
| --------------------------- 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)

View File

@@ -0,0 +1,55 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Note: If you change this test, change 'trivial_bounds.rs' at the same time.
mod phantom_pinned {
use std::marker::{PhantomData, PhantomPinned};
struct A(PhantomPinned);
impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
struct Wrapper<T>(T);
impl<T> Unpin for Wrapper<T> where T: Unpin {}
struct B(PhantomPinned);
impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
struct C(PhantomPinned);
impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {} // Ok
}
mod inner {
use std::marker::{PhantomData, PhantomPinned};
struct Inner(PhantomPinned);
struct A(Inner);
impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
struct Wrapper<T>(T);
impl<T> Unpin for Wrapper<T> where T: Unpin {}
struct B(Inner);
impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
struct C(Inner);
impl<'a> Unpin for C where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
}
fn main() {}

Some files were not shown because too many files have changed in this diff Show More