summaryrefslogtreecommitdiffstats
path: root/third_party/rust/pin-project-lite/tests/ui/pinned_drop
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/pin-project-lite/tests/ui/pinned_drop
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/pin-project-lite/tests/ui/pinned_drop')
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs17
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr22
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs26
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr38
4 files changed, 103 insertions, 0 deletions
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs
new file mode 100644
index 0000000000..609b3bebad
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ pub struct S {
+ #[pin]
+ field: u8,
+ }
+ impl PinnedDrop for S {
+ fn drop(this: Pin<&mut Self>) {
+ __drop_inner(this);
+ }
+ }
+}
+
+fn main() {
+ let _x = S { field: 0 };
+}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr
new file mode 100644
index 0000000000..597f67c84f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr
@@ -0,0 +1,22 @@
+error[E0061]: this function takes 0 arguments but 1 argument was supplied
+ --> tests/ui/pinned_drop/call-drop-inner.rs:10:13
+ |
+10 | __drop_inner(this);
+ | ^^^^^^^^^^^^ ---- argument unexpected
+ |
+note: function defined here
+ --> tests/ui/pinned_drop/call-drop-inner.rs:3:1
+ |
+3 | / pin_project! {
+4 | | pub struct S {
+5 | | #[pin]
+6 | | field: u8,
+... |
+12 | | }
+13 | | }
+ | |_^
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: remove the extra argument
+ |
+10 | __drop_inner();
+ | ~~~~~~~~~~~~~~
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs
new file mode 100644
index 0000000000..68b01b265e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs
@@ -0,0 +1,26 @@
+use pin_project_lite::pin_project;
+
+// In `Drop` impl, the implementor must specify the same requirement as type definition.
+
+struct DropImpl<T> {
+ f: T,
+}
+
+impl<T: Unpin> Drop for DropImpl<T> {
+ //~^ ERROR E0367
+ fn drop(&mut self) {}
+}
+
+pin_project! {
+ //~^ ERROR E0367
+ struct PinnedDropImpl<T> {
+ #[pin]
+ f: T,
+ }
+
+ impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
+ fn drop(_this: Pin<&mut Self>) {}
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr
new file mode 100644
index 0000000000..d70009c97a
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -0,0 +1,38 @@
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:9:9
+ |
+9 | impl<T: Unpin> Drop for DropImpl<T> {
+ | ^^^^^
+ |
+note: the implementor must specify the same requirement
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:5:1
+ |
+5 | / struct DropImpl<T> {
+6 | | f: T,
+7 | | }
+ | |_^
+
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
+ |
+14 | / pin_project! {
+15 | | //~^ ERROR E0367
+16 | | struct PinnedDropImpl<T> {
+17 | | #[pin]
+... |
+23 | | }
+24 | | }
+ | |_^
+ |
+note: the implementor must specify the same requirement
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
+ |
+14 | / pin_project! {
+15 | | //~^ ERROR E0367
+16 | | struct PinnedDropImpl<T> {
+17 | | #[pin]
+... |
+23 | | }
+24 | | }
+ | |_^
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)