summaryrefslogtreecommitdiffstats
path: root/third_party/rust/pin-project/tests/ui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/pin-project/tests/ui
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/pin-project/tests/ui')
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs24
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.rs21
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.stderr22
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs18
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr1
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs18
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr1
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs12
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr7
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/proper_unpin.rs28
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/proper_unpin.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/unsupported.rs13
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr1
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs19
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr15
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs31
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr21
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs37
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.rs27
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/invalid.rs56
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr53
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs18
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed.rs25
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed.stderr17
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs33
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs12
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr13
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr17
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.rs38
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.stderr37
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr21
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr63
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs21
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr24
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr16
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unsupported.rs32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unsupported.stderr45
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs9
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr7
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs152
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr85
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs15
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr8
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.rs14
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/self.rs93
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr95
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.rs17
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.stderr7
-rw-r--r--third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs24
-rw-r--r--third_party/rust/pin-project/tests/ui/project/ambiguous-let.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/project/invalid.rs24
-rw-r--r--third_party/rust/pin-project/tests/ui/project/invalid.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/project/type-mismatch.rs74
-rw-r--r--third_party/rust/pin-project/tests/ui/project/type-mismatch.stderr16
-rw-r--r--third_party/rust/pin-project/tests/ui/project/use-public.rs15
-rw-r--r--third_party/rust/pin-project/tests/ui/project/use-public.stderr7
-rw-r--r--third_party/rust/pin-project/tests/ui/project/use.rs17
-rw-r--r--third_party/rust/pin-project/tests/ui/project/use.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs14
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.rs43
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.stderr63
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/README.md5
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs19
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs25
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs19
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs29
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr18
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs62
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs55
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr35
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.rs33
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs52
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr45
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs34
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr17
94 files changed, 2469 insertions, 0 deletions
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs
new file mode 100644
index 0000000000..e16f3e8de2
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs
@@ -0,0 +1,11 @@
+use std::pin::Pin;
+
+#[cfg_attr(any(), pin_project::pin_project)]
+struct Foo<T> {
+ inner: T,
+}
+
+fn main() {
+ let mut x = Foo { inner: 0_u8 };
+ let _x = Pin::new(&mut x).project(); //~ ERROR E0599
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr
new file mode 100644
index 0000000000..45af3ae05a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr
@@ -0,0 +1,5 @@
+error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Foo<u8>>` in the current scope
+ --> $DIR/cfg_attr-resolve.rs:10:31
+ |
+10 | let _x = Pin::new(&mut x).project(); //~ ERROR E0599
+ | ^^^^^^^ method not found in `std::pin::Pin<&mut Foo<u8>>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs
new file mode 100644
index 0000000000..2807c8768b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs
@@ -0,0 +1,24 @@
+use pin_project::pin_project;
+use std::pin::Pin;
+
+#[cfg_attr(not(any()), pin_project)]
+struct Foo<T> {
+ #[cfg_attr(any(), pin)]
+ inner: T,
+}
+
+#[cfg_attr(not(any()), pin_project)]
+struct Bar<T> {
+ #[cfg_attr(not(any()), pin)]
+ inner: T,
+}
+
+fn main() {
+ let mut x = Foo { inner: 0_u8 };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut u8> = x.inner; //~ ERROR E0308
+
+ let mut x = Bar { inner: 0_u8 };
+ let x = Pin::new(&mut x).project();
+ let _: &mut u8 = x.inner; //~ ERROR E0308
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr
new file mode 100644
index 0000000000..286829911f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+ --> $DIR/cfg_attr-type-mismatch.rs:19:27
+ |
+19 | let _: Pin<&mut u8> = x.inner; //~ ERROR E0308
+ | ------------ ^^^^^^^ expected struct `std::pin::Pin`, found `&mut u8`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `std::pin::Pin<&mut u8>`
+ found mutable reference `&mut u8`
+
+error[E0308]: mismatched types
+ --> $DIR/cfg_attr-type-mismatch.rs:23:22
+ |
+23 | let _: &mut u8 = x.inner; //~ ERROR E0308
+ | ------- ^^^^^^^
+ | | |
+ | | expected `&mut u8`, found struct `std::pin::Pin`
+ | | help: consider mutably borrowing here: `&mut x.inner`
+ | expected due to this
+ |
+ = note: expected mutable reference `&mut u8`
+ found struct `std::pin::Pin<&mut u8>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.rs
new file mode 100644
index 0000000000..7b88205542
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.rs
@@ -0,0 +1,21 @@
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[cfg_attr(any(), pin_project)]
+struct Foo<T> {
+ inner: T,
+}
+
+#[cfg_attr(not(any()), pin_project)]
+struct Bar<T> {
+ #[cfg_attr(not(any()), pin)]
+ inner: T,
+}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>(); // ERROR E0277
+ is_unpin::<Bar<()>>(); // Ok
+ is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.stderr
new file mode 100644
index 0000000000..8879d020e8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-unpin.stderr
@@ -0,0 +1,22 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/cfg_attr-unpin.rs:18:5
+ |
+15 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+18 | is_unpin::<Foo<PhantomPinned>>(); // ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Foo<std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Foo<std::marker::PhantomPinned>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/cfg_attr-unpin.rs:20:5
+ |
+15 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+20 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__Bar<'_, std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs
new file mode 100644
index 0000000000..3776dac3df
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs
@@ -0,0 +1,18 @@
+use auxiliary_macros::hidden_repr;
+use pin_project::pin_project;
+
+//~ ERROR may not be used on #[repr(packed)] types
+// span is lost.
+// Refs: https://github.com/rust-lang/rust/issues/43081
+#[pin_project]
+#[hidden_repr(packed)]
+struct Foo {
+ #[cfg(not(any()))]
+ #[pin]
+ field: u32,
+ #[cfg(any())]
+ #[pin]
+ field: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr
new file mode 100644
index 0000000000..f4d7dee6b7
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr
@@ -0,0 +1 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs
new file mode 100644
index 0000000000..aa65d33149
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs
@@ -0,0 +1,18 @@
+use auxiliary_macros::hidden_repr;
+use pin_project::pin_project;
+
+//~ ERROR may not be used on #[repr(packed)] types
+// span is lost.
+// Refs: https://github.com/rust-lang/rust/issues/43081
+#[pin_project]
+#[hidden_repr(packed)]
+struct Foo {
+ #[cfg(any())]
+ #[pin]
+ field: u32,
+ #[cfg(not(any()))]
+ #[pin]
+ field: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr
new file mode 100644
index 0000000000..f4d7dee6b7
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr
@@ -0,0 +1 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs
new file mode 100644
index 0000000000..3305ed39c5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs
@@ -0,0 +1,12 @@
+use auxiliary_macros::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 Foo {
+ #[pin]
+ field: u32,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr
new file mode 100644
index 0000000000..5910cf4b64
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr
@@ -0,0 +1,7 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed_sneaky.rs:6:1
+ |
+6 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.rs b/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.rs
new file mode 100644
index 0000000000..b7bb04de80
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.rs
@@ -0,0 +1,28 @@
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project]
+struct Foo<T> {
+ #[cfg(any())]
+ #[pin]
+ inner: T,
+ #[cfg(not(any()))]
+ inner: T,
+}
+
+#[pin_project]
+struct Bar<T> {
+ #[cfg(any())]
+ inner: T,
+ #[cfg(not(any()))]
+ #[pin]
+ inner: T,
+}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>(); // Ok
+ is_unpin::<Bar<()>>(); // Ok
+ is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.stderr b/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.stderr
new file mode 100644
index 0000000000..1f58ea218b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/proper_unpin.stderr
@@ -0,0 +1,11 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:27:5
+ |
+22 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+27 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__Bar<'_, std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs
new file mode 100644
index 0000000000..5205307d22
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs
@@ -0,0 +1,13 @@
+use pin_project::pin_project;
+
+//~ ERROR may not be used on structs with zero fields
+// span is lost.
+// Refs: https://github.com/rust-lang/rust/issues/43081
+#[pin_project]
+struct Struct {
+ #[cfg(any())]
+ #[pin]
+ f: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr
new file mode 100644
index 0000000000..0ee8676705
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr
@@ -0,0 +1 @@
+error: #[pin_project] attribute may not be used on structs with zero fields
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs
new file mode 100644
index 0000000000..ea7c917d54
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs
@@ -0,0 +1,19 @@
+use auxiliary_macros::add_attr;
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project]
+#[add_attr(struct)] //~ ERROR duplicate #[pin] attribute
+struct Foo {
+ #[pin]
+ field: PhantomPinned,
+}
+
+#[add_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
+#[pin_project]
+struct Bar {
+ #[pin]
+ field: PhantomPinned,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr
new file mode 100644
index 0000000000..cb2c9638bb
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr
@@ -0,0 +1,15 @@
+error: duplicate #[pin] attribute
+ --> $DIR/add-attr-to-struct.rs:6:1
+ |
+6 | #[add_attr(struct)] //~ ERROR duplicate #[pin] attribute
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> $DIR/add-attr-to-struct.rs:12:1
+ |
+12 | #[add_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs
new file mode 100644
index 0000000000..76394cf506
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs
@@ -0,0 +1,23 @@
+use auxiliary_macros::add_pinned_field;
+use pin_project::pin_project;
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[add_pinned_field]
+struct Foo {
+ #[pin]
+ field: u32,
+}
+
+#[add_pinned_field]
+#[pin_project]
+struct Bar {
+ #[pin]
+ field: u32,
+}
+
+fn main() {
+ is_unpin::<Foo>(); //~ ERROR E0277
+ is_unpin::<Bar>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr
new file mode 100644
index 0000000000..3de6f4ac5a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr
@@ -0,0 +1,23 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/add-pinned-field.rs:21:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+21 | is_unpin::<Foo>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `__Foo<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__Foo<'_>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/add-pinned-field.rs:22:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+22 | is_unpin::<Bar>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `__Bar<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__Bar<'_>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs
new file mode 100644
index 0000000000..c9651848a4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs
@@ -0,0 +1,31 @@
+use pin_project::{pin_project, pinned_drop};
+use std::pin::Pin;
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+}
+
+impl<T, U> Drop for Foo<T, U> {
+ fn drop(&mut self) {}
+}
+
+#[pin_project(PinnedDrop)] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ future: T,
+ field: 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() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr
new file mode 100644
index 0000000000..1724fcc07d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr
@@ -0,0 +1,21 @@
+error[E0119]: conflicting implementations of trait `FooMustNotImplDrop` for type `Foo<_, _>`:
+ --> $DIR/conflict-drop.rs:4:1
+ |
+4 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^
+ | |
+ | first implementation here
+ | conflicting implementation for `Foo<_, _>`
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `Bar<_, _>`:
+ --> $DIR/conflict-drop.rs:15:1
+ |
+15 | #[pin_project(PinnedDrop)] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+27 | impl<T, U> Drop for Bar<T, U> {
+ | ----------------------------- first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs
new file mode 100644
index 0000000000..0c48d27907
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs
@@ -0,0 +1,37 @@
+use pin_project::pin_project;
+
+// The same implementation.
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ future: T,
+ field: 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]
+ future: T,
+ field: U,
+}
+
+// conflicting implementations
+impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
+
+#[pin_project] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+}
+
+// conflicting implementations
+impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr
new file mode 100644
index 0000000000..0d6f439b8b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`:
+ --> $DIR/conflict-unpin.rs:5:1
+ |
+5 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+13 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
+ | --------------------------------------------- first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`:
+ --> $DIR/conflict-unpin.rs:17:1
+ |
+17 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+25 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
+ | ------------------------------ first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`:
+ --> $DIR/conflict-unpin.rs:27:1
+ |
+27 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+35 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+ | -------------------------------------------- first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.rs b/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.rs
new file mode 100644
index 0000000000..df8bf1b751
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.rs
@@ -0,0 +1,27 @@
+use pin_project::pin_project;
+
+#[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+struct UnsafeUnpin<T> {
+ #[pin]
+ pinned: T,
+}
+
+#[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+struct PinnedDrop<T> {
+ #[pin]
+ pinned: T,
+}
+
+#[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+struct Duplicate3<T> {
+ #[pin]
+ pinned: T,
+}
+
+#[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+struct Duplicate4<T> {
+ #[pin]
+ pinned: T,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.stderr b/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.stderr
new file mode 100644
index 0000000000..338e3f4e2d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/duplicate-argument.stderr
@@ -0,0 +1,23 @@
+error: duplicate `UnsafeUnpin` argument
+ --> $DIR/duplicate-argument.rs:3:28
+ |
+3 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `PinnedDrop` argument
+ --> $DIR/duplicate-argument.rs:9:27
+ |
+9 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+ | ^^^^^^^^^^
+
+error: duplicate `UnsafeUnpin` argument
+ --> $DIR/duplicate-argument.rs:15:40
+ |
+15 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `PinnedDrop` argument
+ --> $DIR/duplicate-argument.rs:21:40
+ |
+21 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+ | ^^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs b/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs
new file mode 100644
index 0000000000..f545018c1e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs
@@ -0,0 +1,56 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct A<T> {
+ #[pin()] //~ ERROR unexpected token
+ pinned: T,
+}
+
+#[pin_project]
+struct B<T>(#[pin(foo)] T); //~ ERROR unexpected token
+
+#[pin_project]
+enum C<T> {
+ A(#[pin(foo)] T), //~ ERROR unexpected token
+}
+
+#[pin_project]
+enum D<T> {
+ A {
+ #[pin(foo)] //~ ERROR unexpected token
+ pinned: T,
+ },
+}
+
+#[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
+struct E<T> {
+ #[pin]
+ pinned: T,
+}
+
+#[pin_project(Foo)] //~ ERROR unexpected argument
+struct F<T> {
+ #[pin]
+ pinned: T,
+}
+
+#[pin_project]
+enum G<T> {
+ #[pin] //~ ERROR may only be used on fields of structs or variants
+ A(T),
+}
+
+#[pin_project]
+#[pin] //~ ERROR may only be used on fields of structs or variants
+enum H<T> {
+ A(T),
+}
+
+#[pin_project]
+struct I<T> {
+ #[pin]
+ #[pin] //~ ERROR duplicate #[pin] attribute
+ pinned: T,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr b/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr
new file mode 100644
index 0000000000..308d476670
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr
@@ -0,0 +1,53 @@
+error: unexpected token: ()
+ --> $DIR/invalid.rs:5:10
+ |
+5 | #[pin()] //~ ERROR unexpected token
+ | ^^
+
+error: unexpected token: (foo)
+ --> $DIR/invalid.rs:10:18
+ |
+10 | struct B<T>(#[pin(foo)] T); //~ ERROR unexpected token
+ | ^^^^^
+
+error: unexpected token: (foo)
+ --> $DIR/invalid.rs:14:12
+ |
+14 | A(#[pin(foo)] T), //~ ERROR unexpected token
+ | ^^^^^
+
+error: unexpected token: (foo)
+ --> $DIR/invalid.rs:20:14
+ |
+20 | #[pin(foo)] //~ ERROR unexpected token
+ | ^^^^^
+
+error: expected identifier
+ --> $DIR/invalid.rs:25:27
+ |
+25 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
+ | ^
+
+error: unexpected argument: Foo
+ --> $DIR/invalid.rs:31:15
+ |
+31 | #[pin_project(Foo)] //~ ERROR unexpected argument
+ | ^^^
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> $DIR/invalid.rs:39:5
+ |
+39 | #[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
+ --> $DIR/invalid.rs:44:1
+ |
+44 | #[pin] //~ ERROR may only be used on fields of structs or variants
+ | ^^^^^^
+
+error: duplicate #[pin] attribute
+ --> $DIR/invalid.rs:52:5
+ |
+52 | #[pin] //~ ERROR duplicate #[pin] attribute
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs
new file mode 100644
index 0000000000..00fef3cc3b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs
@@ -0,0 +1,18 @@
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project]
+struct Foo<T> {
+ #[pin]
+ inner: T,
+}
+
+struct __Foo {}
+
+impl Unpin for __Foo {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr
new file mode 100644
index 0000000000..60f4116dbd
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -0,0 +1,11 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/overlapping_unpin_struct.rs:17:5
+ |
+14 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+17 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__Foo<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__Foo<'_, std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned>`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed.rs
new file mode 100644
index 0000000000..86f3ecf33d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed.rs
@@ -0,0 +1,25 @@
+use pin_project::pin_project;
+
+#[pin_project]
+#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+struct A {
+ #[pin]
+ field: u8,
+}
+
+// Test putting 'repr' before the 'pin_project' attribute
+#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+#[pin_project]
+struct B {
+ #[pin]
+ field: u8,
+}
+
+#[pin_project]
+#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+struct C {
+ #[pin]
+ field: u32,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr
new file mode 100644
index 0000000000..969faea211
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr
@@ -0,0 +1,17 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed.rs:4:8
+ |
+4 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed.rs:11:8
+ |
+11 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed.rs:19:8
+ |
+19 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs
new file mode 100644
index 0000000000..dcf5464e4c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs
@@ -0,0 +1,33 @@
+use auxiliary_macros::hidden_repr;
+use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
+use std::pin::Pin;
+
+#[pin_project] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct A {
+ #[pin]
+ field: u32,
+}
+
+#[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct C {
+ #[pin]
+ field: u32,
+}
+
+unsafe impl UnsafeUnpin for C {}
+
+#[pin_project(PinnedDrop)] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct D {
+ #[pin]
+ field: u32,
+}
+
+#[pinned_drop]
+impl PinnedDrop for D {
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr
new file mode 100644
index 0000000000..06a4f6266c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr
@@ -0,0 +1,23 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed_sneaky-1.rs:6:1
+ |
+6 | #[hidden_repr(packed)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed_sneaky-1.rs:13:1
+ |
+13 | #[hidden_repr(packed)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed_sneaky-1.rs:22:1
+ |
+22 | #[hidden_repr(packed)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs
new file mode 100644
index 0000000000..d16270635e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs
@@ -0,0 +1,12 @@
+use auxiliary_macros::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]
+ field: u32,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr
new file mode 100644
index 0000000000..d653a4d29f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr
@@ -0,0 +1,13 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> $DIR/packed_sneaky-2.rs:4:1
+ |
+4 | / hidden_repr_macro! { //~ ERROR may not be used on #[repr(packed)] types
+5 | | #[pin_project]
+6 | | struct B {
+7 | | #[pin]
+8 | | field: u32,
+9 | | }
+10 | | }
+ | |_^
+ |
+ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs
new file mode 100644
index 0000000000..66ddefa4d8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs
@@ -0,0 +1,23 @@
+// Even if allows private_in_public, these are errors.
+
+#![allow(private_in_public)]
+
+pub enum PublicEnum {
+ Variant(PrivateEnum),
+}
+
+enum PrivateEnum {
+ Variant(u8),
+}
+
+mod foo {
+ pub(crate) enum CrateEnum {
+ Variant(PrivateEnum),
+ }
+
+ enum PrivateEnum {
+ Variant(u8),
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr
new file mode 100644
index 0000000000..2a5ae992c0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr
@@ -0,0 +1,17 @@
+error[E0446]: private type `PrivateEnum` in public interface
+ --> $DIR/private_in_public-enum.rs:6:13
+ |
+6 | Variant(PrivateEnum),
+ | ^^^^^^^^^^^ can't leak private type
+...
+9 | enum PrivateEnum {
+ | - `PrivateEnum` declared as private
+
+error[E0446]: private type `foo::PrivateEnum` in public interface
+ --> $DIR/private_in_public-enum.rs:15:17
+ |
+15 | Variant(PrivateEnum),
+ | ^^^^^^^^^^^ can't leak private type
+...
+18 | enum PrivateEnum {
+ | - `foo::PrivateEnum` declared as private
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.rs b/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.rs
new file mode 100644
index 0000000000..7121cc84a3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.rs
@@ -0,0 +1,38 @@
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+struct Inner<T> {
+ val: T,
+}
+
+#[pin_project]
+struct Foo<T, U> {
+ #[pin]
+ inner: Inner<T>,
+ other: U,
+}
+
+#[pin_project]
+pub struct TrivialBounds {
+ #[pin]
+ field1: PhantomPinned,
+}
+
+#[pin_project]
+struct Bar<'a, T, U> {
+ #[pin]
+ inner: &'a mut Inner<T>,
+ other: U,
+}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
+ is_unpin::<Foo<(), PhantomPinned>>(); // Ok
+ is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
+
+ is_unpin::<TrivialBounds>(); //~ ERROR E0277
+
+ is_unpin::<Bar<'_, PhantomPinned, PhantomPinned>>(); //~ Ok
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.stderr b/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.stderr
new file mode 100644
index 0000000000..73fd289438
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/proper_unpin.stderr
@@ -0,0 +1,37 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:31:5
+ |
+28 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+31 | is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__Foo<'_, std::marker::PhantomPinned, ()>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
+ = note: required because it appears within the type `__Foo<'_, std::marker::PhantomPinned, ()>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, ()>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:33:5
+ |
+28 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+33 | is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
+ = note: required because it appears within the type `__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:35:5
+ |
+28 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+35 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `__TrivialBounds<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `__TrivialBounds<'_>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs
new file mode 100644
index 0000000000..eebd3cd27f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs
@@ -0,0 +1,32 @@
+use auxiliary_macros::remove_attr;
+use pin_project::pin_project;
+use std::{marker::PhantomPinned, pin::Pin};
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[remove_attr(field)]
+struct Foo {
+ #[pin]
+ field: PhantomPinned,
+}
+
+#[remove_attr(field)]
+#[pin_project]
+struct Bar {
+ #[pin]
+ field: PhantomPinned,
+}
+
+fn main() {
+ is_unpin::<Foo>();
+ is_unpin::<Bar>();
+
+ let mut x = Foo { field: PhantomPinned };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+
+ let mut x = Bar { field: PhantomPinned };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr
new file mode 100644
index 0000000000..15195e7737
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+ --> $DIR/remove-attr-from-field.rs:27:38
+ |
+27 | let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+ | ----------------------- ^^^^^^^ expected struct `std::pin::Pin`, found `&mut std::marker::PhantomPinned`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `std::pin::Pin<&mut std::marker::PhantomPinned>`
+ found mutable reference `&mut std::marker::PhantomPinned`
+
+error[E0308]: mismatched types
+ --> $DIR/remove-attr-from-field.rs:31:38
+ |
+31 | let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+ | ----------------------- ^^^^^^^ expected struct `std::pin::Pin`, found `&mut std::marker::PhantomPinned`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `std::pin::Pin<&mut std::marker::PhantomPinned>`
+ found mutable reference `&mut std::marker::PhantomPinned`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs
new file mode 100644
index 0000000000..b395a42354
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs
@@ -0,0 +1,30 @@
+use auxiliary_macros::remove_attr;
+use pin_project::pin_project;
+use std::{marker::PhantomPinned, pin::Pin};
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[remove_attr(struct)]
+struct Foo {
+ #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ field: PhantomPinned,
+}
+
+#[remove_attr(struct)]
+#[pin_project]
+struct Bar {
+ #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ field: PhantomPinned,
+}
+
+fn main() {
+ is_unpin::<Foo>(); //~ ERROR E0277
+ is_unpin::<Bar>(); //~ ERROR E0277
+
+ let mut x = Foo { field: PhantomPinned };
+ let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+
+ let mut x = Bar { field: PhantomPinned };
+ let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr
new file mode 100644
index 0000000000..3173248daa
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr
@@ -0,0 +1,63 @@
+error: cannot find attribute `pin` in this scope
+ --> $DIR/remove-attr-from-struct.rs:10:7
+ |
+10 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ | ^^^
+
+error: cannot find attribute `pin` in this scope
+ --> $DIR/remove-attr-from-struct.rs:17:7
+ |
+17 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ | ^^^
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/remove-attr-from-struct.rs:22:5
+ |
+5 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+22 | is_unpin::<Foo>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `Foo`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Foo`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/remove-attr-from-struct.rs:23:5
+ |
+5 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+23 | is_unpin::<Bar>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `Bar`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Bar`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/remove-attr-from-struct.rs:26:14
+ |
+26 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^^ within `Foo`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Foo`
+ = note: required by `std::pin::Pin::<P>::new`
+
+error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Foo>` in the current scope
+ --> $DIR/remove-attr-from-struct.rs:26:31
+ |
+26 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `std::pin::Pin<&mut Foo>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/remove-attr-from-struct.rs:29:14
+ |
+29 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^^ within `Bar`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `Bar`
+ = note: required by `std::pin::Pin::<P>::new`
+
+error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Bar>` in the current scope
+ --> $DIR/remove-attr-from-struct.rs:29:31
+ |
+29 | let _x = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `std::pin::Pin<&mut Bar>`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs
new file mode 100644
index 0000000000..c1a7d55dda
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs
@@ -0,0 +1,21 @@
+#![deny(safe_packed_borrows)]
+
+// Refs: https://github.com/rust-lang/rust/issues/46043
+
+#[repr(packed)]
+struct A {
+ field: u32,
+}
+
+#[repr(packed(2))]
+struct B {
+ field: u32,
+}
+
+fn main() {
+ let a = A { field: 1 };
+ &a.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+
+ let b = B { field: 1 };
+ &b.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr
new file mode 100644
index 0000000000..7b4cc08ec6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr
@@ -0,0 +1,24 @@
+error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
+ --> $DIR/safe_packed_borrows.rs:17:5
+ |
+17 | &a.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ | ^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/safe_packed_borrows.rs:1:9
+ |
+1 | #![deny(safe_packed_borrows)]
+ | ^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
+ = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
+
+error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
+ --> $DIR/safe_packed_borrows.rs:20:5
+ |
+20 | &b.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ | ^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
+ = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs
new file mode 100644
index 0000000000..3ccb1a95d1
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs
@@ -0,0 +1,11 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct Foo {
+ #[pin]
+ inner: u8,
+}
+
+impl Unpin for __Foo {} //~ ERROR E0412,E0321
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr
new file mode 100644
index 0000000000..d96050bb54
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr
@@ -0,0 +1,16 @@
+error[E0412]: cannot find type `__Foo` in this scope
+ --> $DIR/unpin_sneaky.rs:9:16
+ |
+9 | impl Unpin for __Foo {} //~ ERROR E0412,E0321
+ | ^^^^^ not found in this scope
+ |
+help: possible candidate is found in another module, you can import it into scope
+ |
+1 | use crate::__Foo;
+ |
+
+error[E0321]: cross-crate traits with a default impl, like `std::marker::Unpin`, can only be implemented for a struct/enum type, not `[type error]`
+ --> $DIR/unpin_sneaky.rs:9:1
+ |
+9 | impl Unpin for __Foo {} //~ ERROR E0412,E0321
+ | ^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unsupported.rs b/third_party/rust/pin-project/tests/ui/pin_project/unsupported.rs
new file mode 100644
index 0000000000..f7b8eb94a0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unsupported.rs
@@ -0,0 +1,32 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct Struct1 {} //~ ERROR may not be used on structs with zero fields
+
+#[pin_project]
+struct Struct2(); //~ ERROR may not be used on structs with zero fields
+
+#[pin_project]
+struct Struct3; //~ ERROR may not be used on structs with units
+
+#[pin_project]
+enum Enum1 {} //~ ERROR may not be used on enums without variants
+
+#[pin_project]
+enum Enum2 {
+ A = 2, //~ ERROR may not be used on enums with discriminants
+}
+
+#[pin_project]
+enum Enum3 {
+ A, //~ ERROR may not be used on enums that have no field
+ B,
+}
+
+#[pin_project]
+union Union {
+ //~^ ERROR may only be used on structs or enums
+ x: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unsupported.stderr b/third_party/rust/pin-project/tests/ui/pin_project/unsupported.stderr
new file mode 100644
index 0000000000..89ffd949f5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unsupported.stderr
@@ -0,0 +1,45 @@
+error: #[pin_project] attribute may not be used on structs with zero fields
+ --> $DIR/unsupported.rs:4:16
+ |
+4 | struct Struct1 {} //~ ERROR may not be used on structs with zero fields
+ | ^^
+
+error: #[pin_project] attribute may not be used on structs with zero fields
+ --> $DIR/unsupported.rs:7:15
+ |
+7 | struct Struct2(); //~ ERROR may not be used on structs with zero fields
+ | ^^
+
+error: #[pin_project] attribute may not be used on structs with units
+ --> $DIR/unsupported.rs:10:8
+ |
+10 | struct Struct3; //~ ERROR may not be used on structs with units
+ | ^^^^^^^
+
+error: #[pin_project] attribute may not be used on enums without variants
+ --> $DIR/unsupported.rs:13:12
+ |
+13 | enum Enum1 {} //~ ERROR may not be used on enums without variants
+ | ^^
+
+error: #[pin_project] attribute may not be used on enums with discriminants
+ --> $DIR/unsupported.rs:17:9
+ |
+17 | A = 2, //~ ERROR may not be used on enums with discriminants
+ | ^
+
+error: #[pin_project] attribute may not be used on enums that have no field
+ --> $DIR/unsupported.rs:22:5
+ |
+22 | / A, //~ ERROR may not be used on enums that have no field
+23 | | B,
+ | |______^
+
+error: #[pin_project] attribute may only be used on structs or enums
+ --> $DIR/unsupported.rs:27:1
+ |
+27 | / union Union {
+28 | | //~^ ERROR may only be used on structs or enums
+29 | | x: u8,
+30 | | }
+ | |_^
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
new file mode 100644
index 0000000000..b291fbae54
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
@@ -0,0 +1,9 @@
+use pin_project::pin_project;
+
+#[pin_project(PinnedDrop)] //~ ERROR E0277
+pub struct Struct {
+ #[pin]
+ field: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
new file mode 100644
index 0000000000..67bdbe11bd
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
@@ -0,0 +1,7 @@
+error[E0277]: the trait bound `Struct: pin_project::__private::PinnedDrop` is not satisfied
+ --> $DIR/forget-pinned-drop-impl.rs:3:15
+ |
+3 | #[pin_project(PinnedDrop)] //~ ERROR E0277
+ | ^^^^^^^^^^ the trait `pin_project::__private::PinnedDrop` is not implemented for `Struct`
+ |
+ = note: required by `pin_project::__private::PinnedDrop::drop`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs
new file mode 100644
index 0000000000..651d76856e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs
@@ -0,0 +1,152 @@
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+pub struct A {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop(foo)] //~ ERROR unexpected token
+impl PinnedDrop for A {
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct B {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl Drop for B {
+ //~^ ERROR #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ fn drop(&mut self) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct C {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl C {
+ //~^ ERROR #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ fn drop(&mut self) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct D {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for D {
+ fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+}
+
+#[pin_project(PinnedDrop)]
+pub struct E {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for E {
+ fn drop_baz(&mut self) {} //~ ERROR method `drop_baz` is not a member of trait `PinnedDrop
+}
+
+#[pin_project(PinnedDrop)]
+pub struct F {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+unsafe impl PinnedDrop for F {
+ //~^ ERROR implementing the trait `PinnedDrop` is not unsafe
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct G {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for G {
+ unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
+}
+
+#[pin_project(PinnedDrop)]
+pub struct H {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for H {
+ const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct I {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for I {
+ fn drop(self: Pin<&mut Self>) {}
+ const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+}
+
+#[pin_project(PinnedDrop)]
+pub struct J {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for J {
+ type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+#[pin_project(PinnedDrop)]
+pub struct K {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for K {
+ fn drop(self: Pin<&mut Self>) {}
+ type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+}
+
+#[pin_project(PinnedDrop)]
+pub struct L {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for L {
+ fn drop(self: Pin<&mut Self>) {}
+ fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
+}
+
+#[pin_project(PinnedDrop)] //~ ERROR E0277
+pub struct M {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+fn drop(_this: Pin<&mut M>) {} //~ ERROR expected `impl`
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr
new file mode 100644
index 0000000000..c767fbb113
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr
@@ -0,0 +1,85 @@
+error: unexpected token: foo
+ --> $DIR/invalid.rs:9:15
+ |
+9 | #[pinned_drop(foo)] //~ ERROR unexpected token
+ | ^^^
+
+error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ --> $DIR/invalid.rs:21:6
+ |
+21 | impl Drop for B {
+ | ^^^^
+
+error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ --> $DIR/invalid.rs:33:6
+ |
+33 | impl C {
+ | ^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> $DIR/invalid.rs:46:13
+ |
+46 | fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^
+
+error: method `drop_baz` is not a member of trait `PinnedDrop
+ --> $DIR/invalid.rs:57:8
+ |
+57 | fn drop_baz(&mut self) {} //~ ERROR method `drop_baz` is not a member of trait `PinnedDrop
+ | ^^^^^^^^
+
+error: implementing the trait `PinnedDrop` is not unsafe
+ --> $DIR/invalid.rs:67:1
+ |
+67 | unsafe impl PinnedDrop for F {
+ | ^^^^^^
+
+error: implementing the method `drop` is not unsafe
+ --> $DIR/invalid.rs:80:5
+ |
+80 | unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
+ | ^^^^^^
+
+error: const `A` is not a member of trait `PinnedDrop`
+ --> $DIR/invalid.rs:91:5
+ |
+91 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^^^^^
+
+error: const `A` is not a member of trait `PinnedDrop`
+ --> $DIR/invalid.rs:104:5
+ |
+104 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^^^^^
+
+error: type `A` is not a member of trait `PinnedDrop`
+ --> $DIR/invalid.rs:115:5
+ |
+115 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^
+
+error: type `A` is not a member of trait `PinnedDrop`
+ --> $DIR/invalid.rs:128:5
+ |
+128 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^
+
+error: duplicate definitions with name `drop`
+ --> $DIR/invalid.rs:140:5
+ |
+140 | fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: expected `impl`
+ --> $DIR/invalid.rs:150:1
+ |
+150 | fn drop(_this: Pin<&mut M>) {} //~ ERROR expected `impl`
+ | ^^
+
+error[E0277]: the trait bound `M: pin_project::__private::PinnedDrop` is not satisfied
+ --> $DIR/invalid.rs:143:15
+ |
+143 | #[pin_project(PinnedDrop)] //~ ERROR E0277
+ | ^^^^^^^^^^ the trait `pin_project::__private::PinnedDrop` is not implemented for `M`
+ |
+ = note: required by `pin_project::__private::PinnedDrop::drop`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
new file mode 100644
index 0000000000..1241b5be84
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
@@ -0,0 +1,15 @@
+use pin_project::{pin_project, pinned_drop};
+use std::pin::Pin;
+
+#[pin_project]
+struct Foo {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for Foo { //~ ERROR E0119
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
new file mode 100644
index 0000000000..7353dc483b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
@@ -0,0 +1,8 @@
+error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `Foo`:
+ --> $DIR/pinned-drop-no-attr-arg.rs:11:1
+ |
+4 | #[pin_project]
+ | -------------- first implementation here
+...
+11 | impl PinnedDrop for Foo { //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.rs
new file mode 100644
index 0000000000..79ae05cd7e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.rs
@@ -0,0 +1,14 @@
+// `ref (mut) self` are rejected by rustc.
+
+use std::pin::Pin;
+
+pub struct Struct {
+ field: u8,
+}
+
+impl Struct {
+ fn method_ref(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+ fn method_ref_mut(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.stderr
new file mode 100644
index 0000000000..3ab489813c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/ref-self.stderr
@@ -0,0 +1,11 @@
+error: expected identifier, found keyword `self`
+ --> $DIR/ref-self.rs:10:23
+ |
+10 | fn method_ref(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+ | ^^^^ expected identifier, found keyword
+
+error: expected identifier, found keyword `self`
+ --> $DIR/ref-self.rs:11:31
+ |
+11 | fn method_ref_mut(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+ | ^^^^ expected identifier, found keyword
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs
new file mode 100644
index 0000000000..6d552a71a6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs
@@ -0,0 +1,93 @@
+use pin_project::{pin_project, pinned_drop};
+use std::pin::Pin;
+
+fn self_expr() {
+ #[pin_project(PinnedDrop)]
+ pub struct Struct {
+ x: usize,
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Struct {
+ fn drop(mut self: Pin<&mut Self>) {
+ let _: Self = Self { x: 0 };
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct TupleStruct(usize);
+
+ #[pinned_drop]
+ impl PinnedDrop for TupleStruct {
+ fn drop(mut self: Pin<&mut Self>) {
+ let _: Self = Self(0);
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub enum Enum {
+ StructVariant { x: usize },
+ TupleVariant(usize),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Enum {
+ fn drop(mut self: Pin<&mut Self>) {
+ let _: Self = Self::StructVariant { x: 0 }; //~ ERROR can't use generic parameters from outer function [E0401]
+ let _: Self = Self::TupleVariant(0);
+ }
+ }
+}
+
+fn self_pat() {
+ #[pin_project(PinnedDrop)]
+ pub struct Struct {
+ x: usize,
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Struct {
+ fn drop(mut self: Pin<&mut Self>) {
+ match *self {
+ Self { x: _ } => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ }
+ if let Self { x: _ } = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ let Self { x: _ } = *self; //~ ERROR can't use generic parameters from outer function [E0401]
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct TupleStruct(usize);
+
+ #[pinned_drop]
+ impl PinnedDrop for TupleStruct {
+ #[allow(irrefutable_let_patterns)]
+ fn drop(mut self: Pin<&mut Self>) {
+ match *self {
+ Self(_) => {}
+ }
+ if let Self(_) = *self {}
+ let Self(_) = *self;
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub enum Enum {
+ StructVariant { x: usize },
+ TupleVariant(usize),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Enum {
+ fn drop(mut self: Pin<&mut Self>) {
+ match *self {
+ Self::StructVariant { x: _ } => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ Self::TupleVariant(_) => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ }
+ if let Self::StructVariant { x: _ } = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ if let Self::TupleVariant(_) = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ }
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr
new file mode 100644
index 0000000000..54c7b676a3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr
@@ -0,0 +1,95 @@
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:36:27
+ |
+34 | impl PinnedDrop for Enum {
+ | ---- `Self` type implicitly declared here, by this `impl`
+35 | fn drop(mut self: Pin<&mut Self>) {
+36 | let _: Self = Self::StructVariant { x: 0 }; //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^^^^^^^^^^^^^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:52:17
+ |
+49 | impl PinnedDrop for Struct {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+52 | Self { x: _ } => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:54:20
+ |
+49 | impl PinnedDrop for Struct {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+54 | if let Self { x: _ } = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:55:17
+ |
+49 | impl PinnedDrop for Struct {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+55 | let Self { x: _ } = *self; //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:84:17
+ |
+81 | impl PinnedDrop for Enum {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+84 | Self::StructVariant { x: _ } => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^^^^^^^^^^^^^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:85:17
+ |
+81 | impl PinnedDrop for Enum {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+85 | Self::TupleVariant(_) => {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^^^^^^^^^^^^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:87:20
+ |
+81 | impl PinnedDrop for Enum {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+87 | if let Self::StructVariant { x: _ } = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^^^^^^^^^^^^^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/self.rs:88:20
+ |
+81 | impl PinnedDrop for Enum {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+88 | if let Self::TupleVariant(_) = *self {} //~ ERROR can't use generic parameters from outer function [E0401]
+ | ^^^^^^^^^^^^^^^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.rs
new file mode 100644
index 0000000000..78f8a11ced
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.rs
@@ -0,0 +1,17 @@
+use pin_project::{pin_project, pinned_drop};
+use std::pin::Pin;
+
+#[pin_project(PinnedDrop)]
+pub struct Struct {
+ #[pin]
+ field: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for Struct {
+ fn drop(self: Pin<&mut Self>) {
+ self.project().field.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.stderr
new file mode 100644
index 0000000000..98a945f6eb
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-code.stderr
@@ -0,0 +1,7 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+ --> $DIR/unsafe-code.rs:13:9
+ |
+13 | self.project().field.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
diff --git a/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs
new file mode 100644
index 0000000000..a7067494ec
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.rs
@@ -0,0 +1,24 @@
+use pin_project::{pin_project, project};
+
+#[pin_project]
+enum Enum<A, B> {
+ A(#[pin] A),
+ B(B),
+}
+
+struct Struct<T>(T);
+
+#[project]
+fn foo() {
+ let mut foo: Enum<bool, bool> = Enum::A(true);
+
+ #[project]
+ let Struct(x) = match Pin::new(&mut foo).project() {
+ //~^ ERROR Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
+ Enum::A(_) => Struct(true),
+ Enum::B(_) => unreachable!(),
+ };
+ assert!(x);
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/project/ambiguous-let.stderr b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.stderr
new file mode 100644
index 0000000000..e6552c83ec
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/ambiguous-let.stderr
@@ -0,0 +1,5 @@
+error: Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
+ --> $DIR/ambiguous-let.rs:16:9
+ |
+16 | let Struct(x) = match Pin::new(&mut foo).project() {
+ | ^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/project/invalid.rs b/third_party/rust/pin-project/tests/ui/project/invalid.rs
new file mode 100644
index 0000000000..bc7226deb2
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/invalid.rs
@@ -0,0 +1,24 @@
+use pin_project::{pin_project, project};
+
+#[pin_project]
+struct A<T> {
+ #[pin]
+ future: T,
+}
+
+#[project]
+fn foo() {
+ let mut x = A { future: 0 };
+ #[project(foo)] //~ ERROR unexpected token
+ let A { future } = Pin::new(&mut x).project();
+}
+
+#[project]
+fn bar() {
+ let mut x = A { future: 0 };
+ #[project]
+ #[project] //~ ERROR duplicate #[project] attribute
+ let A { future } = Pin::new(&mut x).project();
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/project/invalid.stderr b/third_party/rust/pin-project/tests/ui/project/invalid.stderr
new file mode 100644
index 0000000000..a361b72aa3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/invalid.stderr
@@ -0,0 +1,11 @@
+error: unexpected token: (foo)
+ --> $DIR/invalid.rs:12:14
+ |
+12 | #[project(foo)] //~ ERROR unexpected token
+ | ^^^^^
+
+error: duplicate #[project] attribute
+ --> $DIR/invalid.rs:20:5
+ |
+20 | #[project] //~ ERROR duplicate #[project] attribute
+ | ^^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/project/type-mismatch.rs b/third_party/rust/pin-project/tests/ui/project/type-mismatch.rs
new file mode 100644
index 0000000000..41a70eb87b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/type-mismatch.rs
@@ -0,0 +1,74 @@
+#![feature(proc_macro_hygiene, stmt_expr_attributes)]
+
+use pin_project::{pin_project, project};
+use std::pin::Pin;
+
+#[project]
+fn type_mismatch() {
+ #[pin_project]
+ enum Enum<A, B, C, D> {
+ Variant1(#[pin] A, B),
+ Variant2 {
+ #[pin]
+ field1: C,
+ field2: D,
+ },
+ None,
+ }
+
+ let mut foo = Enum::Variant1(1, 2);
+ let mut foo = Pin::new(&mut foo).project();
+
+ #[project]
+ match &mut foo {
+ Enum::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Enum::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ None => {} //~ ERROR mismatched types
+ }
+}
+
+//~ ERROR mismatched types
+// span is lost.
+// Refs: https://github.com/rust-lang/rust/issues/43081
+fn type_mismatch_span_issue() {
+ #[pin_project]
+ enum Enum<A, B, C, D> {
+ Variant1(#[pin] A, B),
+ Variant2 {
+ #[pin]
+ field1: C,
+ field2: D,
+ },
+ None,
+ }
+
+ let mut foo = Enum::Variant1(1, 2);
+ let mut foo = Pin::new(&mut foo).project();
+
+ #[project]
+ match &mut foo {
+ Enum::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Enum::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ None => {}
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/project/type-mismatch.stderr b/third_party/rust/pin-project/tests/ui/project/type-mismatch.stderr
new file mode 100644
index 0000000000..b4c97d5a99
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/type-mismatch.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+ --> $DIR/type-mismatch.rs:35:9
+ |
+23 | match &mut foo {
+ | -------- this expression has type `&mut type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
+...
+35 | None => {} //~ ERROR mismatched types
+ | ^^^^ expected enum `type_mismatch::__EnumProjection`, found enum `std::option::Option`
+ |
+ = note: expected enum `type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
+ found enum `std::option::Option<_>`
+
+error[E0308]: mismatched types
+ |
+ = note: expected enum `type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
+ found enum `std::option::Option<_>`
diff --git a/third_party/rust/pin-project/tests/ui/project/use-public.rs b/third_party/rust/pin-project/tests/ui/project/use-public.rs
new file mode 100644
index 0000000000..23c9b89d00
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/use-public.rs
@@ -0,0 +1,15 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct A {
+ field: u8,
+}
+
+pub mod b {
+ use pin_project::project;
+
+ #[project]
+ pub use crate::A; //~ ERROR E0365
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/project/use-public.stderr b/third_party/rust/pin-project/tests/ui/project/use-public.stderr
new file mode 100644
index 0000000000..7919d65cbe
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/use-public.stderr
@@ -0,0 +1,7 @@
+error[E0365]: `__AProjection` is private, and cannot be re-exported
+ --> $DIR/use-public.rs:12:13
+ |
+12 | pub use crate::A; //~ ERROR E0365
+ | ^^^^^^^^ re-export of private `__AProjection`
+ |
+ = note: consider declaring type or module `__AProjection` with `pub`
diff --git a/third_party/rust/pin-project/tests/ui/project/use.rs b/third_party/rust/pin-project/tests/ui/project/use.rs
new file mode 100644
index 0000000000..d4b02c1d60
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/use.rs
@@ -0,0 +1,17 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct A {
+ field: u8,
+}
+
+mod b {
+ use pin_project::project;
+
+ #[project]
+ use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
+ #[project]
+ use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/project/use.stderr b/third_party/rust/pin-project/tests/ui/project/use.stderr
new file mode 100644
index 0000000000..07d024160b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/project/use.stderr
@@ -0,0 +1,11 @@
+error: #[project] attribute may not be used on renamed imports
+ --> $DIR/use.rs:12:16
+ |
+12 | use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
+ | ^^^^^^
+
+error: #[project] attribute may not be used on glob imports
+ --> $DIR/use.rs:14:16
+ |
+14 | use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
+ | ^
diff --git a/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs b/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs
new file mode 100644
index 0000000000..429d60f044
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(UnsafeUnpin)]
+struct Struct<T, U> {
+ #[pin]
+ inner: T,
+ other: U,
+}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<(), ()>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr b/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr
new file mode 100644
index 0000000000..0baefe3e1a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr
@@ -0,0 +1,11 @@
+error[E0277]: the trait bound `Struct<(), ()>: pin_project::UnsafeUnpin` is not satisfied
+ --> $DIR/not-implement-unsafe-unpin.rs:13:16
+ |
+10 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+13 | is_unpin::<Struct<(), ()>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^ the trait `pin_project::UnsafeUnpin` is not implemented for `Struct<(), ()>`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Struct<(), ()>>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Struct<(), ()>`
diff --git a/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.rs b/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.rs
new file mode 100644
index 0000000000..8896bfd2ae
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.rs
@@ -0,0 +1,43 @@
+use pin_project::{pin_project, UnsafeUnpin};
+use std::marker::PhantomPinned;
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project(UnsafeUnpin)]
+pub struct Blah<T, U> {
+ field1: U,
+ #[pin]
+ field2: T,
+}
+
+#[allow(unsafe_code)]
+unsafe impl<T: Unpin, U> UnsafeUnpin for Blah<T, U> {}
+
+#[pin_project(UnsafeUnpin)]
+pub struct TrivialBounds {
+ #[pin]
+ field1: PhantomPinned,
+}
+
+#[pin_project(UnsafeUnpin)]
+pub struct OverlappingLifetimeNames<'pin, T, U> {
+ #[pin]
+ field1: U,
+ #[pin]
+ field2: Option<T>,
+ field3: &'pin (),
+}
+
+#[allow(unsafe_code)]
+unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
+
+fn main() {
+ is_unpin::<Blah<PhantomPinned, ()>>(); //~ ERROR E0277
+ is_unpin::<Blah<(), PhantomPinned>>(); // Ok
+ is_unpin::<Blah<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
+
+ is_unpin::<TrivialBounds>(); //~ ERROR E0277
+
+ is_unpin::<OverlappingLifetimeNames<'_, PhantomPinned, ()>>(); //~ ERROR E0277
+ is_unpin::<OverlappingLifetimeNames<'_, (), PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.stderr b/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.stderr
new file mode 100644
index 0000000000..5494666ecc
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/proper_unpin.stderr
@@ -0,0 +1,63 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:35:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+35 | is_unpin::<Blah<PhantomPinned, ()>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, ()>`
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, ()>>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, ()>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:37:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+37 | is_unpin::<Blah<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>`
+
+error[E0277]: the trait bound `TrivialBounds: pin_project::UnsafeUnpin` is not satisfied
+ --> $DIR/proper_unpin.rs:39:16
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+39 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^ the trait `pin_project::UnsafeUnpin` is not implemented for `TrivialBounds`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, TrivialBounds>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:41:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+41 | is_unpin::<OverlappingLifetimeNames<'_, PhantomPinned, ()>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>`
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/proper_unpin.rs:42:5
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ----- required by this bound in `is_unpin`
+...
+42 | is_unpin::<OverlappingLifetimeNames<'_, (), PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>>`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>`
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/README.md b/third_party/rust/pin-project/tests/ui/unstable-features/README.md
new file mode 100644
index 0000000000..b9215b6500
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/README.md
@@ -0,0 +1,5 @@
+# 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.
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
new file mode 100644
index 0000000000..22185eeaf4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
@@ -0,0 +1,19 @@
+// NB: If you change this test, change 'marker_trait_attr.rs' at the same time.
+
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T> {
+ #[pin]
+ x: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Foo<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr
new file mode 100644
index 0000000000..da2c8ea695
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_>`:
+ --> $DIR/marker_trait_attr-feature-gate.rs:6:1
+ |
+6 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_>`
+...
+13 | impl<T> Unpin for Foo<T> {}
+ | ------------------------ first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs
new file mode 100644
index 0000000000..0b8b30ad64
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs
@@ -0,0 +1,25 @@
+// NB: 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 pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project] //~ ERROR E0119
+struct Struct<T> {
+ #[pin]
+ x: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr
new file mode 100644
index 0000000000..9b3ec57ea4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`:
+ --> $DIR/marker_trait_attr.rs:12:1
+ |
+12 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+19 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
new file mode 100644
index 0000000000..0bd4a32cc1
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
@@ -0,0 +1,19 @@
+// NB: If you change this test, change 'overlapping_marker_traits.rs' at the same time.
+
+use pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project] //~ ERROR E0119
+struct Struct<T> {
+ #[pin]
+ x: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr
new file mode 100644
index 0000000000..4a8e23843c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`:
+ --> $DIR/overlapping_marker_traits-feature-gate.rs:6:1
+ |
+6 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+13 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs
new file mode 100644
index 0000000000..28b23fe394
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs
@@ -0,0 +1,29 @@
+// NB: 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 pin_project::pin_project;
+use std::marker::PhantomPinned;
+
+#[pin_project]
+struct Foo<T> {
+ #[pin]
+ x: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Foo<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr
new file mode 100644
index 0000000000..13ad810f69
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr
@@ -0,0 +1,18 @@
+error[E0557]: feature has been removed
+ --> $DIR/overlapping_marker_traits.rs:11:12
+ |
+11 | #![feature(overlapping_marker_traits)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
+ |
+ = note: removed in favor of `#![feature(marker_trait_attr)]`
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_>`:
+ --> $DIR/overlapping_marker_traits.rs:16:1
+ |
+16 | #[pin_project]
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_>`
+...
+23 | impl<T> Unpin for Foo<T> {}
+ | ------------------------ first implementation here
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs b/third_party/rust/pin-project/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
new file mode 100644
index 0000000000..8ad8e41bb1
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
@@ -0,0 +1,62 @@
+// NB: If you change this test, change 'stmt_expr_attributes-feature-gate.rs' at the same time.
+
+// proc_macro_hygiene
+// Tracking issue: https://github.com/rust-lang/rust/issues/54727
+#![feature(proc_macro_hygiene)]
+// stmt_expr_attributes
+// Tracking issue: https://github.com/rust-lang/rust/issues/15701
+#![feature(stmt_expr_attributes)]
+
+use pin_project::{pin_project, project};
+use std::pin::Pin;
+
+fn project_stmt_expr_nightly() {
+ #[pin_project]
+ enum Baz<A, B, C, D> {
+ Variant1(#[pin] A, B),
+ Variant2 {
+ #[pin]
+ field1: C,
+ field2: D,
+ },
+ None,
+ }
+
+ let mut baz = Baz::Variant1(1, 2);
+
+ let mut baz = Pin::new(&mut baz).project();
+
+ #[project]
+ match &mut baz {
+ Baz::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Baz::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ Baz::None => {}
+ }
+
+ let () = #[project]
+ match &mut baz {
+ Baz::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Baz::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ Baz::None => {}
+ };
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
new file mode 100644
index 0000000000..82267238f4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
@@ -0,0 +1,55 @@
+// NB: If you change this test, change 'stmt_expr_attributes.rs' at the same time.
+
+use pin_project::{pin_project, project};
+use std::pin::Pin;
+
+fn project_stmt_expr_nightly() {
+ #[pin_project]
+ enum Enum<A, B, C, D> {
+ Variant1(#[pin] A, B),
+ Variant2 {
+ #[pin]
+ field1: C,
+ field2: D,
+ },
+ None,
+ }
+
+ let mut baz = Enum::Variant1(1, 2);
+
+ let mut baz = Pin::new(&mut baz).project();
+
+ #[project] //~ ERROR E0658
+ match &mut baz {
+ Enum::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Enum::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ Enum::None => {}
+ }
+
+ let () = #[project] //~ ERROR E0658
+ match &mut baz {
+ Enum::Variant1(x, y) => {
+ let x: &mut Pin<&mut i32> = x;
+ assert_eq!(**x, 1);
+
+ let y: &mut &mut i32 = y;
+ assert_eq!(**y, 2);
+ }
+ Enum::Variant2 { field1, field2 } => {
+ let _x: &mut Pin<&mut i32> = field1;
+ let _y: &mut &mut i32 = field2;
+ }
+ Enum::None => {}
+ };
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
new file mode 100644
index 0000000000..6510ec760b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
@@ -0,0 +1,35 @@
+error[E0658]: attributes on expressions are experimental
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:22:5
+ |
+22 | #[project] //~ ERROR E0658
+ | ^^^^^^^^^^
+ |
+ = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
+ = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
+
+error[E0658]: attributes on expressions are experimental
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:38:14
+ |
+38 | let () = #[project] //~ ERROR E0658
+ | ^^^^^^^^^^
+ |
+ = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
+ = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
+
+error[E0658]: custom attributes cannot be applied to expressions
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:22:5
+ |
+22 | #[project] //~ ERROR E0658
+ | ^^^^^^^^^^
+ |
+ = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
+ = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
+
+error[E0658]: custom attributes cannot be applied to expressions
+ --> $DIR/stmt_expr_attributes-feature-gate.rs:38:14
+ |
+38 | let () = #[project] //~ ERROR E0658
+ | ^^^^^^^^^^
+ |
+ = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
+ = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.rs
new file mode 100644
index 0000000000..66e0ec4a4f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.rs
@@ -0,0 +1,33 @@
+// NB: If you change this test, change 'trivial_bounds-feature-gate.rs' at the same time.
+
+// trivial_bounds
+// Tracking issue: https://github.com/rust-lang/rust/issues/48214
+#![feature(trivial_bounds)]
+
+use std::marker::{PhantomData, PhantomPinned};
+
+fn phantom_pinned() {
+ struct A(PhantomPinned);
+
+ // bug of trivial_bounds?
+ 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 {} //~ Ok
+
+ 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
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.stderr
new file mode 100644
index 0000000000..8370c456cc
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-bug.stderr
@@ -0,0 +1,5 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-bug.rs:13:43
+ |
+13 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
+ | ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
new file mode 100644
index 0000000000..a6a4d84e61
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
@@ -0,0 +1,52 @@
+// NB: If you change this test, change 'trivial_bounds.rs' at the same time.
+
+use std::marker::{PhantomData, PhantomPinned};
+
+fn phantom_pinned() {
+ 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
+}
+
+fn inner() {
+ 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() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
new file mode 100644
index 0000000000..f8ef886065
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
@@ -0,0 +1,45 @@
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:8:5
+ |
+8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:8:43
+ |
+8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
+ | ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:16:5
+ |
+16 | impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `phantom_pinned::Wrapper<std::marker::PhantomPinned>`
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:33:5
+ |
+33 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `inner::Inner`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `inner::Inner`
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:41:5
+ |
+41 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `inner::Inner`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ |
+ = note: required because it appears within the type `inner::Inner`
+ = note: required because of the requirements on the impl of `std::marker::Unpin` for `inner::Wrapper<inner::Inner>`
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs
new file mode 100644
index 0000000000..680effe61d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs
@@ -0,0 +1,34 @@
+// NB: If you change this test, change 'trivial_bounds-feature-gate.rs' at the same time.
+
+// trivial_bounds
+// Tracking issue: https://github.com/rust-lang/rust/issues/48214
+#![feature(trivial_bounds)]
+#![deny(trivial_bounds)]
+
+use std::marker::{PhantomData, PhantomPinned};
+
+fn inner() {
+ struct Inner(PhantomPinned);
+
+ struct A(Inner);
+
+ impl Unpin for A where Inner: Unpin {} //~ ERROR std::marker::Unpin does not depend on any type or lifetime parameters
+
+ 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 std::marker::Unpin does not depend on any type or lifetime parameters
+
+ 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() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr
new file mode 100644
index 0000000000..03d0161443
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr
@@ -0,0 +1,17 @@
+error: Trait bound inner::Inner: std::marker::Unpin does not depend on any type or lifetime parameters
+ --> $DIR/trivial_bounds.rs:15:35
+ |
+15 | impl Unpin for A where Inner: Unpin {} //~ ERROR std::marker::Unpin does not depend on any type or lifetime parameters
+ | ^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/trivial_bounds.rs:6:9
+ |
+6 | #![deny(trivial_bounds)]
+ | ^^^^^^^^^^^^^^
+
+error: Trait bound inner::Wrapper<inner::Inner>: std::marker::Unpin does not depend on any type or lifetime parameters
+ --> $DIR/trivial_bounds.rs:23:44
+ |
+23 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR std::marker::Unpin does not depend on any type or lifetime parameters
+ | ^^^^^