aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2023-11-02 14:27:31 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-11-02 14:27:31 +0000
commit52cf71f6ec7d544e4445ce471e166b5df549f6cc (patch)
treebcc836bce9f75104f15f1a48d456668fb6bd28b8
parentaaed4fca4bdcd5e2763a5da20ea384bae31fc644 (diff)
parent3f20d0e9f523688f464126191638b34254068f91 (diff)
downloadpin-project-lite-52cf71f6ec7d544e4445ce471e166b5df549f6cc.tar.gz
Update pin-project-lite to 0.2.13 am: befbae5e27 am: 80d5871f3a am: 3f20d0e9f5
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pin-project-lite/+/2815213 Change-Id: Id26738acdb140c01de8fac8788a5b577d411b386 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp2
-rw-r--r--CHANGELOG.md24
-rw-r--r--Cargo.toml28
-rw-r--r--Cargo.toml.orig24
-rw-r--r--METADATA12
-rw-r--r--README.md13
-rw-r--r--patches/std.diff8
-rw-r--r--src/lib.rs345
-rw-r--r--tests/README.md46
-rw-r--r--tests/compiletest.rs1
-rw-r--r--tests/expand/.rustfmt.toml1
-rw-r--r--tests/expand/default/enum.expanded.rs50
-rw-r--r--tests/expand/default/struct.expanded.rs14
-rw-r--r--tests/expand/multifields/enum.expanded.rs41
-rw-r--r--tests/expand/multifields/struct.expanded.rs47
-rw-r--r--tests/expand/naming/enum-all.expanded.rs50
-rw-r--r--tests/expand/naming/enum-mut.expanded.rs23
-rw-r--r--tests/expand/naming/enum-none.expanded.rs8
-rw-r--r--tests/expand/naming/enum-ref.expanded.rs23
-rw-r--r--tests/expand/naming/struct-all.expanded.rs21
-rw-r--r--tests/expand/naming/struct-mut.expanded.rs14
-rw-r--r--tests/expand/naming/struct-none.expanded.rs14
-rw-r--r--tests/expand/naming/struct-ref.expanded.rs14
-rw-r--r--tests/expand/not_unpin/enum.expanded.rs99
-rw-r--r--tests/expand/not_unpin/enum.rs17
-rw-r--r--tests/expand/not_unpin/struct.expanded.rs88
-rw-r--r--tests/expand/not_unpin/struct.rs14
-rw-r--r--tests/expand/pinned_drop/enum.expanded.rs49
-rw-r--r--tests/expand/pinned_drop/enum.rs3
-rw-r--r--tests/expand/pinned_drop/struct.expanded.rs25
-rw-r--r--tests/expand/pinned_drop/struct.rs3
-rw-r--r--tests/expand/pub/enum.expanded.rs38
-rw-r--r--tests/expand/pub/struct.expanded.rs14
-rw-r--r--tests/expandtest.rs5
-rw-r--r--tests/lint.rs26
-rw-r--r--tests/proper_unpin.rs33
-rw-r--r--tests/test.rs3
-rw-r--r--tests/ui/pin_project/conflict-drop.stderr4
-rw-r--r--tests/ui/pin_project/conflict-unpin.rs24
-rw-r--r--tests/ui/pin_project/conflict-unpin.stderr48
-rw-r--r--tests/ui/pin_project/invalid-bounds.stderr90
-rw-r--r--tests/ui/pin_project/invalid.stderr78
-rw-r--r--tests/ui/pin_project/overlapping_lifetime_names.stderr40
-rw-r--r--tests/ui/pin_project/overlapping_unpin_struct.stderr15
-rw-r--r--tests/ui/pin_project/packed.rs2
-rw-r--r--tests/ui/pin_project/packed.stderr136
-rw-r--r--tests/ui/pin_project/unpin_sneaky.stderr6
-rw-r--r--tests/ui/pin_project/unsupported.stderr80
-rw-r--r--tests/ui/pinned_drop/call-drop-inner.stderr11
-rw-r--r--tests/ui/pinned_drop/conditional-drop-impl.stderr8
51 files changed, 1244 insertions, 540 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index b377c22..f7a93e2 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "1ccf058c2ba13fd7eee2154951ac64a84590d886"
+ "sha1": "dc4b07a1fa1166131e64c02a487dd121e2eebebb"
},
"path_in_vcs": ""
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index f37c97e..150a9f0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -44,7 +44,7 @@ rust_library {
host_supported: true,
crate_name: "pin_project_lite",
cargo_env_compat: true,
- cargo_pkg_version: "0.2.9",
+ cargo_pkg_version: "0.2.13",
srcs: ["src/lib.rs"],
edition: "2018",
apex_available: [
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 127e467..dc463fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,9 +10,25 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]
+## [0.2.13] - 2023-08-25
+
+- Allow attributes in impl and method of `PinnedDrop` implementation.
+
+## [0.2.12] - 2023-08-09
+
+- Work around an issue where the projected types/methods appear in the documentation as if they were part of the public API if the visibility is not correctly parsed due to the rustc bug. See [#77](https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180) for details.
+
+## [0.2.11] - 2023-08-06
+
+- Add support for `#[project(!Unpin)]`. This is equivalent to pin-project's [!Unpin](https://docs.rs/pin-project/latest/pin_project/attr.pin_project.html#unpin) option. ([#76](https://github.com/taiki-e/pin-project-lite/pull/76), thanks @matheus-consoli)
+
+## [0.2.10] - 2023-07-02
+
+- Inline project methods. ([#74](https://github.com/taiki-e/pin-project-lite/pull/74), thanks @EFanZh)
+
## [0.2.9] - 2022-04-26
-- Improve compile time of `pin_project!` calls. (#71, thanks @nnethercote)
+- Improve compile time of `pin_project!` calls. ([#71](https://github.com/taiki-e/pin-project-lite/pull/71), thanks @nnethercote)
## [0.2.8] - 2021-12-31
@@ -196,7 +212,11 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
Initial release
-[Unreleased]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.9...HEAD
+[Unreleased]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.13...HEAD
+[0.2.13]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.12...v0.2.13
+[0.2.12]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.11...v0.2.12
+[0.2.11]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.10...v0.2.11
+[0.2.10]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.9...v0.2.10
[0.2.9]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.8...v0.2.9
[0.2.8]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.7...v0.2.8
[0.2.7]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.6...v0.2.7
diff --git a/Cargo.toml b/Cargo.toml
index 8a9436d..ae3d4fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,20 +13,23 @@
edition = "2018"
rust-version = "1.37"
name = "pin-project-lite"
-version = "0.2.9"
+version = "0.2.13"
exclude = [
"/.*",
"/tools",
+ "/DEVELOPMENT.md",
]
description = """
A lightweight version of pin-project written with declarative macros.
"""
+readme = "README.md"
keywords = [
"pin",
"macros",
]
categories = [
"no-std",
+ "no-std::no-alloc",
"rust-patterns",
]
license = "Apache-2.0 OR MIT"
@@ -35,11 +38,32 @@ repository = "https://github.com/taiki-e/pin-project-lite"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
+[lib]
+doc-scrape-examples = false
+
+[dev-dependencies.macrotest]
+version = "1.0.9"
+
+[dev-dependencies.once_cell]
+version = "=1.14"
+
+[dev-dependencies.proc-macro2]
+version = "=1.0.65"
+
+[dev-dependencies.quote]
+version = "=1.0.30"
+
[dev-dependencies.rustversion]
version = "1"
+[dev-dependencies.serde]
+version = "=1.0.156"
+
[dev-dependencies.static_assertions]
version = "1"
+[dev-dependencies.toml]
+version = "=0.5.9"
+
[dev-dependencies.trybuild]
-version = "1.0.49"
+version = "=1.0.67"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 3528633..59f41c5 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,13 +1,13 @@
[package]
name = "pin-project-lite"
-version = "0.2.9"
+version = "0.2.13"
edition = "2018"
rust-version = "1.37"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/taiki-e/pin-project-lite"
keywords = ["pin", "macros"]
-categories = ["no-std", "rust-patterns"]
-exclude = ["/.*", "/tools"]
+categories = ["no-std", "no-std::no-alloc", "rust-patterns"]
+exclude = ["/.*", "/tools", "/DEVELOPMENT.md"]
description = """
A lightweight version of pin-project written with declarative macros.
"""
@@ -17,13 +17,25 @@ targets = ["x86_64-unknown-linux-gnu"]
[workspace]
members = [
- "tests/doc",
"tests/no-core",
"tests/no-std",
]
+[lib]
+doc-scrape-examples = false
+
[dev-dependencies]
-macrotest = { git = "https://github.com/taiki-e/macrotest.git", rev = "779cfa5" } # https://github.com/eupn/macrotest/pull/69
+macrotest = "1.0.9"
rustversion = "1"
static_assertions = "1"
-trybuild = "1.0.49"
+trybuild = "=1.0.67"
+
+# For test on MSRV.
+once_cell = "=1.14"
+proc-macro2 = "=1.0.65"
+quote = "=1.0.30"
+serde = "=1.0.156"
+toml = "=0.5.9"
+
+[patch.crates-io]
+prettyplease = { git = "https://github.com/taiki-e/prettyplease.git", branch = "dev" } # lower MSRV
diff --git a/METADATA b/METADATA
index 880866f..ba19ea9 100644
--- a/METADATA
+++ b/METADATA
@@ -1,6 +1,4 @@
-# This project was upgraded with external_updater.
-# Usage: tools/external_updater/updater.sh update rust/crates/pin-project-lite
-# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+# This project was upgraded manually.
name: "pin-project-lite"
description: "A lightweight version of pin-project written with declarative macros."
@@ -13,11 +11,11 @@ third_party {
type: ARCHIVE
value: "https://static.crates.io/crates/pin-project-lite/pin-project-lite-0.2.9.crate"
}
- version: "0.2.9"
+ version: "0.2.13"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 12
- day: 13
+ year: 2023
+ month: 10
+ day: 25
}
}
diff --git a/README.md b/README.md
index 78adb7e..40b909a 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
# pin-project-lite
[![crates.io](https://img.shields.io/crates/v/pin-project-lite?style=flat-square&logo=rust)](https://crates.io/crates/pin-project-lite)
-[![docs.rs](https://img.shields.io/badge/docs.rs-pin--project--lite-blue?style=flat-square)](https://docs.rs/pin-project-lite)
+[![docs.rs](https://img.shields.io/badge/docs.rs-pin--project--lite-blue?style=flat-square&logo=docs.rs)](https://docs.rs/pin-project-lite)
[![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)](#license)
[![rustc](https://img.shields.io/badge/rustc-1.37+-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)
-[![build status](https://img.shields.io/github/workflow/status/taiki-e/pin-project-lite/CI/main?style=flat-square&logo=github)](https://github.com/taiki-e/pin-project-lite/actions)
+[![build status](https://img.shields.io/github/actions/workflow/status/taiki-e/pin-project-lite/ci.yml?branch=main&style=flat-square&logo=github)](https://github.com/taiki-e/pin-project-lite/actions)
+<!-- tidy:crate-doc:start -->
A lightweight version of [pin-project] written with declarative macros.
## Usage
@@ -104,17 +105,21 @@ description of the compile error.
### Different: No support for custom Unpin implementation
-pin-project supports this by [`UnsafeUnpin`][unsafe-unpin] and [`!Unpin`][not-unpin].
+pin-project supports this by [`UnsafeUnpin`][unsafe-unpin]. (`!Unpin` is supported by both [pin-project][not-unpin] and [pin-project-lite][not-unpin-lite].)
### Different: No support for tuple structs and tuple variants
pin-project supports this.
-[`pin_project!`]: https://docs.rs/pin-project-lite/0.2/pin_project_lite/macro.pin_project.html
[not-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin
+[not-unpin-lite]: https://docs.rs/pin-project-lite/0.2/pin_project_lite/macro.pin_project.html#unpin
[pin-project]: https://github.com/taiki-e/pin-project
[unsafe-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unsafeunpin
+<!-- tidy:crate-doc:end -->
+
+[`pin_project!`]: https://docs.rs/pin-project-lite/0.2/pin_project_lite/macro.pin_project.html
+
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
diff --git a/patches/std.diff b/patches/std.diff
index 4ae8c47..1bc1240 100644
--- a/patches/std.diff
+++ b/patches/std.diff
@@ -1,10 +1,10 @@
diff --git a/src/lib.rs b/src/lib.rs
-index 304b0da..4c70e26 100644
+index 6ec2021..7e46d02 100644
--- a/src/lib.rs
+++ b/src/lib.rs
-@@ -81,6 +81,9 @@
- // mem::take and #[non_exhaustive] requires Rust 1.40
- #![allow(clippy::mem_replace_with_default, clippy::manual_non_exhaustive)]
+@@ -137,6 +137,9 @@ pin-project supports this.
+ clippy::undocumented_unsafe_blocks,
+ )]
+// ANDROID: Use std to allow building as a dylib.
+extern crate std;
diff --git a/src/lib.rs b/src/lib.rs
index d71afe8..7e46d02 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,98 +1,116 @@
-//! A lightweight version of [pin-project] written with declarative macros.
-//!
-//! # Examples
-//!
-//! [`pin_project!`] macro creates a projection type covering all the fields of struct.
-//!
-//! ```rust
-//! use std::pin::Pin;
-//!
-//! use pin_project_lite::pin_project;
-//!
-//! pin_project! {
-//! struct Struct<T, U> {
-//! #[pin]
-//! pinned: T,
-//! unpinned: U,
-//! }
-//! }
-//!
-//! impl<T, U> Struct<T, U> {
-//! fn method(self: Pin<&mut Self>) {
-//! let this = self.project();
-//! let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
-//! let _: &mut U = this.unpinned; // Normal reference to the field
-//! }
-//! }
-//! ```
-//!
-//! To use [`pin_project!`] on enums, you need to name the projection type
-//! returned from the method.
-//!
-//! ```rust
-//! use std::pin::Pin;
-//!
-//! use pin_project_lite::pin_project;
-//!
-//! pin_project! {
-//! #[project = EnumProj]
-//! enum Enum<T, U> {
-//! Variant { #[pin] pinned: T, unpinned: U },
-//! }
-//! }
-//!
-//! impl<T, U> Enum<T, U> {
-//! fn method(self: Pin<&mut Self>) {
-//! match self.project() {
-//! EnumProj::Variant { pinned, unpinned } => {
-//! let _: Pin<&mut T> = pinned;
-//! let _: &mut U = unpinned;
-//! }
-//! }
-//! }
-//! }
-//! ```
-//!
-//! # [pin-project] vs pin-project-lite
-//!
-//! Here are some similarities and differences compared to [pin-project].
-//!
-//! ## Similar: Safety
-//!
-//! pin-project-lite guarantees safety in much the same way as [pin-project].
-//! Both are completely safe unless you write other unsafe code.
-//!
-//! ## Different: Minimal design
-//!
-//! This library does not tackle as expansive of a range of use cases as
-//! [pin-project] does. If your use case is not already covered, please use
-//! [pin-project].
-//!
-//! ## Different: No proc-macro related dependencies
-//!
-//! This is the **only** reason to use this crate. However, **if you already
-//! have proc-macro related dependencies in your crate's dependency graph, there
-//! is no benefit from using this crate.** (Note: There is almost no difference
-//! in the amount of code generated between [pin-project] and pin-project-lite.)
-//!
-//! ## Different: No useful error messages
-//!
-//! This macro does not handle any invalid input. So error messages are not to
-//! be useful in most cases. If you do need useful error messages, then upon
-//! error you can pass the same input to [pin-project] to receive a helpful
-//! description of the compile error.
-//!
-//! ## Different: No support for custom Unpin implementation
-//!
-//! pin-project supports this by [`UnsafeUnpin`][unsafe-unpin] and [`!Unpin`][not-unpin].
-//!
-//! ## Different: No support for tuple structs and tuple variants
-//!
-//! pin-project supports this.
-//!
-//! [not-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin
-//! [pin-project]: https://github.com/taiki-e/pin-project
-//! [unsafe-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unsafeunpin
+/*!
+<!-- tidy:crate-doc:start -->
+A lightweight version of [pin-project] written with declarative macros.
+
+## Usage
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+pin-project-lite = "0.2"
+```
+
+*Compiler support: requires rustc 1.37+*
+
+## Examples
+
+[`pin_project!`] macro creates a projection type covering all the fields of
+struct.
+
+```rust
+use std::pin::Pin;
+
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+impl<T, U> Struct<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ let this = self.project();
+ let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+ let _: &mut U = this.unpinned; // Normal reference to the field
+ }
+}
+```
+
+To use [`pin_project!`] on enums, you need to name the projection type
+returned from the method.
+
+```rust
+use std::pin::Pin;
+
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ enum Enum<T, U> {
+ Variant { #[pin] pinned: T, unpinned: U },
+ }
+}
+
+impl<T, U> Enum<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ match self.project() {
+ EnumProj::Variant { pinned, unpinned } => {
+ let _: Pin<&mut T> = pinned;
+ let _: &mut U = unpinned;
+ }
+ }
+ }
+}
+```
+
+## [pin-project] vs pin-project-lite
+
+Here are some similarities and differences compared to [pin-project].
+
+### Similar: Safety
+
+pin-project-lite guarantees safety in much the same way as [pin-project].
+Both are completely safe unless you write other unsafe code.
+
+### Different: Minimal design
+
+This library does not tackle as expansive of a range of use cases as
+[pin-project] does. If your use case is not already covered, please use
+[pin-project].
+
+### Different: No proc-macro related dependencies
+
+This is the **only** reason to use this crate. However, **if you already
+have proc-macro related dependencies in your crate's dependency graph, there
+is no benefit from using this crate.** (Note: There is almost no difference
+in the amount of code generated between [pin-project] and pin-project-lite.)
+
+### Different: No useful error messages
+
+This macro does not handle any invalid input. So error messages are not to
+be useful in most cases. If you do need useful error messages, then upon
+error you can pass the same input to [pin-project] to receive a helpful
+description of the compile error.
+
+### Different: No support for custom Unpin implementation
+
+pin-project supports this by [`UnsafeUnpin`][unsafe-unpin]. (`!Unpin` is supported by both [pin-project][not-unpin] and [pin-project-lite][not-unpin-lite].)
+
+### Different: No support for tuple structs and tuple variants
+
+pin-project supports this.
+
+[not-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin
+[not-unpin-lite]: https://docs.rs/pin-project-lite/0.2/pin_project_lite/macro.pin_project.html#unpin
+[pin-project]: https://github.com/taiki-e/pin-project
+[unsafe-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unsafeunpin
+
+<!-- tidy:crate-doc:end -->
+*/
#![no_std]
#![doc(test(
@@ -103,7 +121,21 @@
)
))]
#![warn(rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
-#![warn(clippy::default_trait_access, clippy::wildcard_imports)]
+#![warn(
+ clippy::pedantic,
+ // lints for public library
+ clippy::alloc_instead_of_core,
+ clippy::exhaustive_enums,
+ clippy::exhaustive_structs,
+ clippy::std_instead_of_alloc,
+ clippy::std_instead_of_core,
+ // lints that help writing unsafe code
+ clippy::as_ptr_cast_mut,
+ clippy::default_union_representation,
+ clippy::trailing_empty_array,
+ clippy::transmute_undefined_repr,
+ clippy::undocumented_unsafe_blocks,
+)]
// ANDROID: Use std to allow building as a dylib.
extern crate std;
@@ -267,8 +299,22 @@ extern crate std;
///
/// # `!Unpin`
///
-/// If you want to ensure that [`Unpin`] is not implemented, use `#[pin]`
-/// attribute for a [`PhantomPinned`] field.
+/// If you want to make sure `Unpin` is not implemented, use the `#[project(!Unpin)]`
+/// attribute.
+///
+/// ```
+/// use pin_project_lite::pin_project;
+///
+/// pin_project! {
+/// #[project(!Unpin)]
+/// struct Struct<T> {
+/// #[pin]
+/// field: T,
+/// }
+/// }
+/// ```
+///
+/// This is equivalent to using `#[pin]` attribute for a [`PhantomPinned`] field.
///
/// ```rust
/// use std::marker::PhantomPinned;
@@ -278,13 +324,14 @@ extern crate std;
/// pin_project! {
/// struct Struct<T> {
/// field: T,
-/// #[pin] // <------ This `#[pin]` is required to make `Struct` to `!Unpin`.
+/// #[pin]
/// _pin: PhantomPinned,
/// }
/// }
/// ```
///
-/// Note that using [`PhantomPinned`] without `#[pin]` attribute has no effect.
+/// Note that using [`PhantomPinned`] without `#[pin]` or `#[project(!Unpin)]`
+/// attribute has no effect.
///
/// [`PhantomPinned`]: core::marker::PhantomPinned
/// [`Pin::as_mut`]: core::pin::Pin::as_mut
@@ -294,7 +341,7 @@ extern crate std;
macro_rules! pin_project {
($($tt:tt)*) => {
$crate::__pin_project_internal! {
- [][][][]
+ [][][][][]
$($tt)*
}
};
@@ -316,6 +363,7 @@ macro_rules! __pin_project_expand {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$($proj_not_unpin_mark:ident)?]
[$proj_vis:vis]
[$(#[$attrs:meta])* $vis:vis $struct_ty_ident:ident $ident:ident]
[$($def_generics:tt)*]
@@ -323,7 +371,7 @@ macro_rules! __pin_project_expand {
{
$($body_data:tt)*
}
- $(impl $($pinned_drop:tt)*)?
+ $($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
$crate::__pin_project_reconstruct! {
[$(#[$attrs])* $vis $struct_ty_ident $ident]
@@ -365,13 +413,14 @@ macro_rules! __pin_project_expand {
$crate::__pin_project_constant! {
[$(#[$attrs])* $vis $struct_ty_ident $ident]
[$($proj_mut_ident)?] [$($proj_ref_ident)?] [$($proj_replace_ident)?]
+ [$($proj_not_unpin_mark)?]
[$proj_vis]
[$($def_generics)*] [$($impl_generics)*]
[$($ty_generics)*] [$(where $($where_clause)*)?]
{
$($body_data)*
}
- $(impl $($pinned_drop)*)?
+ $($(#[$drop_impl_attrs])* impl $($pinned_drop)*)?
}
};
}
@@ -382,6 +431,7 @@ macro_rules! __pin_project_constant {
(
[$(#[$attrs:meta])* $vis:vis struct $ident:ident]
[$($proj_mut_ident:ident)?] [$($proj_ref_ident:ident)?] [$($proj_replace_ident:ident)?]
+ [$($proj_not_unpin_mark:ident)?]
[$proj_vis:vis]
[$($def_generics:tt)*]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
@@ -391,7 +441,7 @@ macro_rules! __pin_project_constant {
$field_vis:vis $field:ident: $field_ty:ty
),+ $(,)?
}
- $(impl $($pinned_drop:tt)*)?
+ $($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
@@ -469,6 +519,7 @@ macro_rules! __pin_project_constant {
}
$crate::__pin_project_make_unpin_impl! {
+ [$($proj_not_unpin_mark)?]
[$vis $ident]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
$(
@@ -481,7 +532,7 @@ macro_rules! __pin_project_constant {
$crate::__pin_project_make_drop_impl! {
[$ident]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
- $(impl $($pinned_drop)*)?
+ $($(#[$drop_impl_attrs])* impl $($pinned_drop)*)?
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)] struct.
@@ -518,6 +569,7 @@ macro_rules! __pin_project_constant {
(
[$(#[$attrs:meta])* $vis:vis enum $ident:ident]
[$($proj_mut_ident:ident)?] [$($proj_ref_ident:ident)?] [$($proj_replace_ident:ident)?]
+ [$($proj_not_unpin_mark:ident)?]
[$proj_vis:vis]
[$($def_generics:tt)*]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
@@ -532,7 +584,7 @@ macro_rules! __pin_project_constant {
})?
),+ $(,)?
}
- $(impl $($pinned_drop:tt)*)?
+ $($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
@@ -594,6 +646,7 @@ macro_rules! __pin_project_constant {
}
$crate::__pin_project_make_unpin_impl! {
+ [$($proj_not_unpin_mark)?]
[$vis $ident]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
$(
@@ -610,7 +663,7 @@ macro_rules! __pin_project_constant {
$crate::__pin_project_make_drop_impl! {
[$ident]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
- $(impl $($pinned_drop)*)?
+ $($(#[$drop_impl_attrs])* impl $($pinned_drop)*)?
}
// We don't need to check for '#[repr(packed)]',
@@ -755,6 +808,7 @@ macro_rules! __pin_project_make_proj_ty_body {
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
[$($body_data:tt)+]
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
@@ -848,6 +902,7 @@ macro_rules! __pin_project_make_proj_replace_ty_body {
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
[$($body_data:tt)+]
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
@@ -926,6 +981,8 @@ macro_rules! __pin_project_struct_make_proj_method {
),+
}
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
+ #[inline]
$proj_vis fn $method_ident<'__pin>(
self: $crate::__private::Pin<&'__pin $($mut)? Self>,
) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
@@ -959,6 +1016,8 @@ macro_rules! __pin_project_struct_make_proj_replace_method {
),+
}
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
+ #[inline]
$proj_vis fn project_replace(
self: $crate::__private::Pin<&mut Self>,
replacement: Self,
@@ -1006,6 +1065,8 @@ macro_rules! __pin_project_enum_make_proj_method {
),+
}
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
+ #[inline]
$proj_vis fn $method_ident<'__pin>(
self: $crate::__private::Pin<&'__pin $($mut)? Self>,
) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
@@ -1049,6 +1110,8 @@ macro_rules! __pin_project_enum_make_proj_replace_method {
),+
}
) => {
+ #[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
+ #[inline]
$proj_vis fn project_replace(
self: $crate::__private::Pin<&mut Self>,
replacement: Self,
@@ -1086,6 +1149,7 @@ macro_rules! __pin_project_enum_make_proj_replace_method {
#[macro_export]
macro_rules! __pin_project_make_unpin_impl {
(
+ []
[$vis:vis $ident:ident]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
$($field:tt)*
@@ -1130,6 +1194,23 @@ macro_rules! __pin_project_make_unpin_impl {
{
}
};
+ (
+ [$proj_not_unpin_mark:ident]
+ [$vis:vis $ident:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ $($field:tt)*
+ ) => {
+ #[doc(hidden)]
+ impl <'__pin, $($impl_generics)*> $crate::__private::Unpin for $ident <$($ty_generics)*>
+ where
+ (
+ ::core::marker::PhantomData<&'__pin ()>,
+ ::core::marker::PhantomPinned,
+ ): $crate::__private::Unpin
+ $(, $($where_clause)*)?
+ {
+ }
+ }
}
#[doc(hidden)]
@@ -1138,6 +1219,7 @@ macro_rules! __pin_project_make_drop_impl {
(
[$_ident:ident]
[$($_impl_generics:tt)*] [$($_ty_generics:tt)*] [$(where $($_where_clause:tt)*)?]
+ $(#[$drop_impl_attrs:meta])*
impl $(<
$( $lifetime:lifetime $(: $lifetime_bound:lifetime)? ),* $(,)?
$( $generics:ident
@@ -1154,11 +1236,13 @@ macro_rules! __pin_project_make_drop_impl {
),* $(,)?
)?
{
+ $(#[$drop_fn_attrs:meta])*
fn drop($($arg:ident)+: Pin<&mut Self>) {
$($tt:tt)*
}
}
) => {
+ $(#[$drop_impl_attrs])*
impl $(<
$( $lifetime $(: $lifetime_bound)? ,)*
$( $generics
@@ -1175,6 +1259,7 @@ macro_rules! __pin_project_make_drop_impl {
),*
)?
{
+ $(#[$drop_fn_attrs])*
fn drop(&mut self) {
// Implementing `__DropInner::__drop_inner` is safe, but calling it is not safe.
// This is because destructors can be called multiple times in safe code and
@@ -1328,6 +1413,7 @@ macro_rules! __pin_project_internal {
[]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
#[project = $proj_mut_ident:ident]
@@ -1337,6 +1423,7 @@ macro_rules! __pin_project_internal {
[$proj_mut_ident]
[$($proj_ref_ident)?]
[$($proj_replace_ident)?]
+ [$( ! $proj_not_unpin_mark)?]
[$($attrs)*]
$($tt)*
}
@@ -1346,6 +1433,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident:ident)?]
[]
[$($proj_replace_ident:ident)?]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
#[project_ref = $proj_ref_ident:ident]
@@ -1355,6 +1443,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident)?]
[$proj_ref_ident]
[$($proj_replace_ident)?]
+ [$( ! $proj_not_unpin_mark)?]
[$($attrs)*]
$($tt)*
}
@@ -1364,6 +1453,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
#[project_replace = $proj_replace_ident:ident]
@@ -1373,6 +1463,27 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident)?]
[$($proj_ref_ident)?]
[$proj_replace_ident]
+ [$( ! $proj_not_unpin_mark)?]
+ [$($attrs)*]
+ $($tt)*
+ }
+ };
+ // parsing !Unpin
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ []
+ [$($attrs:tt)*]
+
+ #[project( ! $proj_not_unpin_mark:ident)]
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_internal! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [ ! $proj_not_unpin_mark]
[$($attrs)*]
$($tt)*
}
@@ -1383,6 +1494,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
#[$($attr:tt)*]
@@ -1392,6 +1504,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident)?]
[$($proj_ref_ident)?]
[$($proj_replace_ident)?]
+ [$( ! $proj_not_unpin_mark)?]
[$($attrs)* #[$($attr)*]]
$($tt)*
}
@@ -1402,6 +1515,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
pub $struct_ty_ident:ident $ident:ident
$($tt:tt)*
@@ -1410,6 +1524,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident)?]
[$($proj_ref_ident)?]
[$($proj_replace_ident)?]
+ [$($proj_not_unpin_mark)?]
[$($attrs)*]
[pub $struct_ty_ident $ident pub(crate)]
$($tt)*
@@ -1419,6 +1534,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$( ! $proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
$vis:vis $struct_ty_ident:ident $ident:ident
$($tt:tt)*
@@ -1427,6 +1543,7 @@ macro_rules! __pin_project_internal {
[$($proj_mut_ident)?]
[$($proj_ref_ident)?]
[$($proj_replace_ident)?]
+ [$($proj_not_unpin_mark)?]
[$($attrs)*]
[$vis $struct_ty_ident $ident $vis]
$($tt)*
@@ -1441,8 +1558,9 @@ macro_rules! __pin_project_parse_generics {
[$($proj_mut_ident:ident)?]
[$($proj_ref_ident:ident)?]
[$($proj_replace_ident:ident)?]
+ [$($proj_not_unpin_mark:ident)?]
[$($attrs:tt)*]
- [$vis:vis $struct_ty_ident:ident $ident:ident $proj_ty_vis:vis]
+ [$vis:vis $struct_ty_ident:ident $ident:ident $proj_vis:vis]
$(<
$( $lifetime:lifetime $(: $lifetime_bound:lifetime)? ),* $(,)?
$( $generics:ident
@@ -1462,13 +1580,14 @@ macro_rules! __pin_project_parse_generics {
{
$($body_data:tt)*
}
- $(impl $($pinned_drop:tt)*)?
+ $($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
$crate::__pin_project_expand! {
[$($proj_mut_ident)?]
[$($proj_ref_ident)?]
[$($proj_replace_ident)?]
- [$proj_ty_vis]
+ [$($proj_not_unpin_mark)?]
+ [$proj_vis]
[$($attrs)* $vis $struct_ty_ident $ident]
[$(<
$( $lifetime $(: $lifetime_bound)? ,)*
@@ -1496,7 +1615,7 @@ macro_rules! __pin_project_parse_generics {
{
$($body_data)*
}
- $(impl $($pinned_drop)*)?
+ $($(#[$drop_impl_attrs])* impl $($pinned_drop)*)?
}
};
}
@@ -1531,6 +1650,8 @@ pub mod __private {
impl<T: ?Sized> Drop for UnsafeDropInPlaceGuard<T> {
fn drop(&mut self) {
+ // SAFETY: the caller of `UnsafeDropInPlaceGuard::new` must guarantee
+ // that `ptr` is valid for drop when this guard is destructed.
unsafe {
ptr::drop_in_place(self.0);
}
@@ -1554,6 +1675,8 @@ pub mod __private {
impl<T> Drop for UnsafeOverwriteGuard<T> {
fn drop(&mut self) {
+ // SAFETY: the caller of `UnsafeOverwriteGuard::new` must guarantee
+ // that `target` is valid for writes when this guard is destructed.
unsafe {
ptr::write(self.target, ptr::read(&*self.value));
}
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100644
index 4721616..0000000
--- a/tests/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Tests
-
-Many of the tests in this repository are based on [pin-project's tests](https://github.com/taiki-e/pin-project/tree/HEAD/tests).
-
-To run all tests, run the following command:
-
-```sh
-cargo +nightly test --all
-```
-
-## UI tests (`ui`, `compiletest.rs`)
-
-This checks errors detected by the macro or the Rust compiler in the resulting
-expanded code.
-
-To run this test, run the following command:
-
-```sh
-cargo +nightly test --test compiletest
-```
-
-Locally, this test updates the files in the `ui` directory if there are
-changes to the generated code. If there are any changes to the files in the
-`ui` directory after running the test, please commit them.
-
-See also [`trybuild` documentation](https://docs.rs/trybuild).
-
-## Expansion tests (`expand`, `expandtest.rs`)
-
-Similar to ui tests, but instead of checking the compiler output, this checks
-the code generated by macros.
-
-See pin-project's [examples](https://github.com/taiki-e/pin-project/tree/HEAD/examples)
-for descriptions of what the generated code does, and why it needs to be generated.
-
-To run this test, run the following command:
-
-```sh
-cargo +nightly test --test expandtest
-```
-
-Locally, this test updates the files in the `expand` directory if there are
-changes to the generated code. If there are any changes to the files in the
-`expand` directory after running the test, please commit them.
-
-See also [`macrotest` documentation](https://docs.rs/macrotest).
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index 70d2358..06712d0 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -1,4 +1,5 @@
#![cfg(not(miri))]
+#![cfg(not(careful))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::env;
diff --git a/tests/expand/.rustfmt.toml b/tests/expand/.rustfmt.toml
new file mode 100644
index 0000000..c7ad93b
--- /dev/null
+++ b/tests/expand/.rustfmt.toml
@@ -0,0 +1 @@
+disable_all_formatting = true
diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs
index eae0aac..456b8cc 100644
--- a/tests/expand/default/enum.expanded.rs
+++ b/tests/expand/default/enum.expanded.rs
@@ -3,6 +3,7 @@ enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -20,6 +21,7 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -37,16 +39,14 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjReplace<T, U> {
- Struct {
- pinned: ::pin_project_lite::__private::PhantomData<T>,
- unpinned: U,
- },
+ Struct { pinned: ::pin_project_lite::__private::PhantomData<T>, unpinned: U },
Unit,
}
#[allow(single_use_lifetimes)]
@@ -54,32 +54,46 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
- Self::Struct { pinned, unpinned } => EnumProj::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProj::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
unsafe {
match self.get_ref() {
- Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProjRef::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
@@ -98,7 +112,9 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ ),
(),
);
}
@@ -115,10 +131,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs
index 8ab318c..a9792e1 100644
--- a/tests/expand/default/struct.expanded.rs
+++ b/tests/expand/default/struct.expanded.rs
@@ -9,6 +9,7 @@ struct Struct<T, U> {
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -23,6 +24,7 @@ const _: () = {
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
unpinned: &'__pin mut (U),
}
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,8 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
@@ -49,6 +53,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
@@ -67,10 +73,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs
index fca0feb..f722a14 100644
--- a/tests/expand/multifields/enum.expanded.rs
+++ b/tests/expand/multifields/enum.expanded.rs
@@ -1,13 +1,9 @@
use pin_project_lite::pin_project;
enum Enum<T, U> {
- Struct {
- pinned1: T,
- pinned2: T,
- unpinned1: U,
- unpinned2: U,
- },
+ Struct { pinned1: T, pinned2: T, unpinned1: U, unpinned2: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
@@ -27,6 +23,8 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
@@ -38,22 +36,25 @@ const _: () = {
replacement,
);
match &mut *__self_ptr {
- Self::Struct {
- pinned1,
- pinned2,
- unpinned1,
- unpinned2,
- } => {
+ Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
let result = EnumProjReplace::Struct {
pinned1: ::pin_project_lite::__private::PhantomData,
pinned2: ::pin_project_lite::__private::PhantomData,
- unpinned1: ::pin_project_lite::__private::ptr::read(unpinned1),
- unpinned2: ::pin_project_lite::__private::ptr::read(unpinned2),
+ unpinned1: ::pin_project_lite::__private::ptr::read(
+ unpinned1,
+ ),
+ unpinned2: ::pin_project_lite::__private::ptr::read(
+ unpinned2,
+ ),
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned1,
+ ),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned2,
+ ),
(),
(),
);
@@ -76,10 +77,10 @@ const _: () = {
),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs
index 4320f68..83ebefe 100644
--- a/tests/expand/multifields/struct.expanded.rs
+++ b/tests/expand/multifields/struct.expanded.rs
@@ -5,6 +5,7 @@ struct Struct<T, U> {
unpinned1: U,
unpinned2: U,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
@@ -22,6 +23,7 @@ struct StructProjReplace<T, U> {
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,7 @@ const _: () = {
unpinned1: &'__pin mut (U),
unpinned2: &'__pin mut (U),
}
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -55,16 +58,14 @@ const _: () = {
unpinned2: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
unsafe {
- let Self {
- pinned1,
- pinned2,
- unpinned1,
- unpinned2,
- } = self.get_unchecked_mut();
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = self
+ .get_unchecked_mut();
Projection {
pinned1: ::pin_project_lite::__private::Pin::new_unchecked(pinned1),
pinned2: ::pin_project_lite::__private::Pin::new_unchecked(pinned2),
@@ -73,16 +74,13 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
unsafe {
- let Self {
- pinned1,
- pinned2,
- unpinned1,
- unpinned2,
- } = self.get_ref();
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = self.get_ref();
ProjectionRef {
pinned1: ::pin_project_lite::__private::Pin::new_unchecked(pinned1),
pinned2: ::pin_project_lite::__private::Pin::new_unchecked(pinned2),
@@ -91,6 +89,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
@@ -101,12 +101,7 @@ const _: () = {
__self_ptr,
replacement,
);
- let Self {
- pinned1,
- pinned2,
- unpinned1,
- unpinned2,
- } = &mut *__self_ptr;
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = &mut *__self_ptr;
let result = StructProjReplace {
pinned1: ::pin_project_lite::__private::PhantomData,
pinned2: ::pin_project_lite::__private::PhantomData,
@@ -115,8 +110,12 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned1,
+ ),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned2,
+ ),
(),
(),
);
@@ -133,10 +132,10 @@ const _: () = {
unpinned1: ::pin_project_lite::__private::AlwaysUnpin<U>,
unpinned2: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs
index eae0aac..456b8cc 100644
--- a/tests/expand/naming/enum-all.expanded.rs
+++ b/tests/expand/naming/enum-all.expanded.rs
@@ -3,6 +3,7 @@ enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -20,6 +21,7 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -37,16 +39,14 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjReplace<T, U> {
- Struct {
- pinned: ::pin_project_lite::__private::PhantomData<T>,
- unpinned: U,
- },
+ Struct { pinned: ::pin_project_lite::__private::PhantomData<T>, unpinned: U },
Unit,
}
#[allow(single_use_lifetimes)]
@@ -54,32 +54,46 @@ enum EnumProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
- Self::Struct { pinned, unpinned } => EnumProj::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProj::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
unsafe {
match self.get_ref() {
- Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProjRef::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
@@ -98,7 +112,9 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ ),
(),
);
}
@@ -115,10 +131,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/enum-mut.expanded.rs b/tests/expand/naming/enum-mut.expanded.rs
index 7c4d6af..342588c 100644
--- a/tests/expand/naming/enum-mut.expanded.rs
+++ b/tests/expand/naming/enum-mut.expanded.rs
@@ -3,6 +3,7 @@ enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -25,15 +26,21 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
- Self::Struct { pinned, unpinned } => EnumProj::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProj::Unit,
}
}
@@ -45,10 +52,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/enum-none.expanded.rs b/tests/expand/naming/enum-none.expanded.rs
index 28ce97d..fc3b3dc 100644
--- a/tests/expand/naming/enum-none.expanded.rs
+++ b/tests/expand/naming/enum-none.expanded.rs
@@ -14,10 +14,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/enum-ref.expanded.rs b/tests/expand/naming/enum-ref.expanded.rs
index a1a013b..5270e12 100644
--- a/tests/expand/naming/enum-ref.expanded.rs
+++ b/tests/expand/naming/enum-ref.expanded.rs
@@ -3,6 +3,7 @@ enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -25,15 +26,21 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
unsafe {
match self.get_ref() {
- Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProjRef::Unit,
}
}
@@ -45,10 +52,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs
index b91c24e..13c4079 100644
--- a/tests/expand/naming/struct-all.expanded.rs
+++ b/tests/expand/naming/struct-all.expanded.rs
@@ -3,6 +3,7 @@ struct Struct<T, U> {
pinned: T,
unpinned: U,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -17,6 +18,7 @@ where
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
unpinned: &'__pin mut (U),
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -31,6 +33,7 @@ where
pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
unpinned: &'__pin (U),
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
@@ -47,6 +50,8 @@ struct StructProjReplace<T, U> {
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> StructProj<'__pin, T, U> {
@@ -58,6 +63,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> StructProjRef<'__pin, T, U> {
@@ -69,6 +76,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_replace(
self: ::pin_project_lite::__private::Pin<&mut Self>,
replacement: Self,
@@ -86,7 +95,9 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ ),
(),
);
}
@@ -100,10 +111,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs
index aaa41cd..9b6dae8 100644
--- a/tests/expand/naming/struct-mut.expanded.rs
+++ b/tests/expand/naming/struct-mut.expanded.rs
@@ -3,6 +3,7 @@ struct Struct<T, U> {
pinned: T,
unpinned: U,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -23,6 +24,7 @@ where
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,8 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> StructProj<'__pin, T, U> {
@@ -49,6 +53,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
@@ -67,10 +73,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs
index 8ab318c..a9792e1 100644
--- a/tests/expand/naming/struct-none.expanded.rs
+++ b/tests/expand/naming/struct-none.expanded.rs
@@ -9,6 +9,7 @@ struct Struct<T, U> {
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -23,6 +24,7 @@ const _: () = {
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
unpinned: &'__pin mut (U),
}
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,8 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
@@ -49,6 +53,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
@@ -67,10 +73,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs
index 3d97ab8..9fea20d 100644
--- a/tests/expand/naming/struct-ref.expanded.rs
+++ b/tests/expand/naming/struct-ref.expanded.rs
@@ -3,6 +3,7 @@ struct Struct<T, U> {
pinned: T,
unpinned: U,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -23,6 +24,7 @@ where
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,8 @@ const _: () = {
unpinned: &'__pin mut (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
@@ -49,6 +53,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> StructProjRef<'__pin, T, U> {
@@ -67,10 +73,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/not_unpin/enum.expanded.rs b/tests/expand/not_unpin/enum.expanded.rs
new file mode 100644
index 0000000..02cdc23
--- /dev/null
+++ b/tests/expand/not_unpin/enum.expanded.rs
@@ -0,0 +1,99 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[doc(hidden)]
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[doc(hidden)]
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[doc(hidden)]
+ #[inline]
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[doc(hidden)]
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ (
+ ::core::marker::PhantomData<&'__pin ()>,
+ ::core::marker::PhantomPinned,
+ ): ::pin_project_lite::__private::Unpin,
+ {}
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/tests/expand/not_unpin/enum.rs b/tests/expand/not_unpin/enum.rs
new file mode 100644
index 0000000..0896716
--- /dev/null
+++ b/tests/expand/not_unpin/enum.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project(!Unpin)]
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/tests/expand/not_unpin/struct.expanded.rs b/tests/expand/not_unpin/struct.expanded.rs
new file mode 100644
index 0000000..2e590b6
--- /dev/null
+++ b/tests/expand/not_unpin/struct.expanded.rs
@@ -0,0 +1,88 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[doc(hidden)]
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProj<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+}
+#[doc(hidden)]
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProjRef<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> StructProj<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ StructProj {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ #[doc(hidden)]
+ #[inline]
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> StructProjRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ StructProjRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[doc(hidden)]
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ (
+ ::core::marker::PhantomData<&'__pin ()>,
+ ::core::marker::PhantomPinned,
+ ): ::pin_project_lite::__private::Unpin,
+ {}
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/tests/expand/not_unpin/struct.rs b/tests/expand/not_unpin/struct.rs
new file mode 100644
index 0000000..0a2967f
--- /dev/null
+++ b/tests/expand/not_unpin/struct.rs
@@ -0,0 +1,14 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = StructProj]
+ #[project(!Unpin)]
+ #[project_ref = StructProjRef]
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs
index 665ff63..03901ce 100644
--- a/tests/expand/pinned_drop/enum.expanded.rs
+++ b/tests/expand/pinned_drop/enum.expanded.rs
@@ -1,9 +1,10 @@
-use pin_project_lite::pin_project;
use std::pin::Pin;
+use pin_project_lite::pin_project;
enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -21,6 +22,7 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -43,28 +45,40 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
- Self::Struct { pinned, unpinned } => EnumProj::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProj::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
unsafe {
match self.get_ref() {
- Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProjRef::Unit,
}
}
@@ -76,18 +90,21 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
impl<T, U> ::pin_project_lite::__private::Drop for Enum<T, U> {
fn drop(&mut self) {
- fn __drop_inner<T, U>(this: ::pin_project_lite::__private::Pin<&mut Enum<T, U>>) {
+ fn __drop_inner<T, U>(
+ this: ::pin_project_lite::__private::Pin<&mut Enum<T, U>>,
+ ) {
fn __drop_inner() {}
let _ = this;
}
- let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> =
- unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
+ let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> = unsafe {
+ ::pin_project_lite::__private::Pin::new_unchecked(self)
+ };
__drop_inner(pinned_self);
}
}
diff --git a/tests/expand/pinned_drop/enum.rs b/tests/expand/pinned_drop/enum.rs
index 1855cb7..5f3508c 100644
--- a/tests/expand/pinned_drop/enum.rs
+++ b/tests/expand/pinned_drop/enum.rs
@@ -1,6 +1,7 @@
-use pin_project_lite::pin_project;
use std::pin::Pin;
+use pin_project_lite::pin_project;
+
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs
index 5b82b7a..f3fa923 100644
--- a/tests/expand/pinned_drop/struct.expanded.rs
+++ b/tests/expand/pinned_drop/struct.expanded.rs
@@ -1,5 +1,5 @@
-use pin_project_lite::pin_project;
use std::pin::Pin;
+use pin_project_lite::pin_project;
struct Struct<T, U> {
pinned: T,
unpinned: U,
@@ -10,6 +10,7 @@ struct Struct<T, U> {
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -24,6 +25,7 @@ const _: () = {
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
unpinned: &'__pin mut (U),
}
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -39,6 +41,8 @@ const _: () = {
unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
@@ -50,6 +54,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
@@ -68,18 +74,21 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
impl<T, U> ::pin_project_lite::__private::Drop for Struct<T, U> {
fn drop(&mut self) {
- fn __drop_inner<T, U>(this: ::pin_project_lite::__private::Pin<&mut Struct<T, U>>) {
+ fn __drop_inner<T, U>(
+ this: ::pin_project_lite::__private::Pin<&mut Struct<T, U>>,
+ ) {
fn __drop_inner() {}
let _ = this;
}
- let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> =
- unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
+ let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> = unsafe {
+ ::pin_project_lite::__private::Pin::new_unchecked(self)
+ };
__drop_inner(pinned_self);
}
}
diff --git a/tests/expand/pinned_drop/struct.rs b/tests/expand/pinned_drop/struct.rs
index 0cc7567..5400ecb 100644
--- a/tests/expand/pinned_drop/struct.rs
+++ b/tests/expand/pinned_drop/struct.rs
@@ -1,6 +1,7 @@
-use pin_project_lite::pin_project;
use std::pin::Pin;
+use pin_project_lite::pin_project;
+
pin_project! {
struct Struct<T, U> {
#[pin]
diff --git a/tests/expand/pub/enum.expanded.rs b/tests/expand/pub/enum.expanded.rs
index 6f190cb..85c7770 100644
--- a/tests/expand/pub/enum.expanded.rs
+++ b/tests/expand/pub/enum.expanded.rs
@@ -3,6 +3,7 @@ pub enum Enum<T, U> {
Struct { pinned: T, unpinned: U },
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -20,6 +21,7 @@ where
},
Unit,
}
+#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -42,28 +44,40 @@ where
#[allow(clippy::used_underscore_binding)]
const _: () = {
impl<T, U> Enum<T, U> {
+ #[doc(hidden)]
+ #[inline]
pub(crate) fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> EnumProj<'__pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
- Self::Struct { pinned, unpinned } => EnumProj::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProj::Unit,
}
}
}
+ #[doc(hidden)]
+ #[inline]
pub(crate) fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> EnumProjRef<'__pin, T, U> {
unsafe {
match self.get_ref() {
- Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
- pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
- unpinned: unpinned,
- },
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(
+ pinned,
+ ),
+ unpinned: unpinned,
+ }
+ }
Self::Unit => EnumProjRef::Unit,
}
}
@@ -75,10 +89,10 @@ const _: () = {
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
Unit: (),
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs
index 7b5826d..a06783d 100644
--- a/tests/expand/pub/struct.expanded.rs
+++ b/tests/expand/pub/struct.expanded.rs
@@ -9,6 +9,7 @@ pub struct Struct<T, U> {
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -23,6 +24,7 @@ const _: () = {
pub pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
pub unpinned: &'__pin mut (U),
}
+ #[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
@@ -38,6 +40,8 @@ const _: () = {
pub unpinned: &'__pin (U),
}
impl<T, U> Struct<T, U> {
+ #[doc(hidden)]
+ #[inline]
pub(crate) fn project<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, T, U> {
@@ -49,6 +53,8 @@ const _: () = {
}
}
}
+ #[doc(hidden)]
+ #[inline]
pub(crate) fn project_ref<'__pin>(
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, T, U> {
@@ -67,10 +73,10 @@ const _: () = {
pinned: T,
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
}
- impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
- __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
- {
- }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U>
+ where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin,
+ {}
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
diff --git a/tests/expandtest.rs b/tests/expandtest.rs
index 3f0d5c1..04a0666 100644
--- a/tests/expandtest.rs
+++ b/tests/expandtest.rs
@@ -1,4 +1,5 @@
#![cfg(not(miri))]
+#![cfg(not(careful))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::{
@@ -13,9 +14,9 @@ const PATH: &str = "tests/expand/**/*.rs";
fn expandtest() {
let is_ci = env::var_os("CI").is_some();
let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into());
- if !has_command(&[cargo, "expand"]) || !has_command(&[cargo, "fmt"]) {
+ if !has_command(&[cargo, "expand"]) {
if is_ci {
- panic!("expandtest requires rustfmt and cargo-expand");
+ panic!("expandtest requires cargo-expand");
}
return;
}
diff --git a/tests/lint.rs b/tests/lint.rs
index 852f940..94f72fd 100644
--- a/tests/lint.rs
+++ b/tests/lint.rs
@@ -10,7 +10,7 @@
// lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below.
// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms
// unsafe_op_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn.
-// non_exhaustive_omitted_patterns: unstable
+// non_exhaustive_omitted_patterns, multiple_supertrait_upcastable: unstable
// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features
// unused_crate_dependencies, must_not_suspend: unrelated
// unsafe_code: checked in forbid_unsafe module
@@ -18,6 +18,8 @@
box_pointers,
deprecated_in_future,
fuzzy_provenance_casts,
+ invalid_reference_casting,
+ let_underscore_drop,
lossy_provenance_casts,
macro_use_extern_crate,
meta_variable_misuse,
@@ -27,19 +29,28 @@
missing_docs,
non_ascii_idents,
noop_method_call,
+ private_bounds,
+ private_interfaces,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
+ unnameable_types,
unreachable_pub,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
unused_results,
+ unused_tuple_struct_fields,
variant_size_differences
)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)]
#![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
-#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums, clippy::single_char_lifetime_names)] // TODO
+#![allow(
+ clippy::exhaustive_enums,
+ clippy::exhaustive_structs,
+ clippy::min_ident_chars,
+ clippy::single_char_lifetime_names
+)] // TODO
pub mod basic {
include!("include/basic.rs");
@@ -60,6 +71,7 @@ pub mod box_pointers {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[derive(Debug)]
pub enum Enum {
Struct {
@@ -91,6 +103,7 @@ pub mod explicit_outlives_requirements {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[derive(Debug)]
pub enum Enum<'a, T, U>
where
@@ -113,6 +126,7 @@ pub mod variant_size_differences {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[allow(missing_debug_implementations, missing_copy_implementations)] // https://github.com/rust-lang/rust/pull/74060
#[allow(variant_size_differences)] // for the type itself
#[allow(clippy::large_enum_variant)] // for the type itself
@@ -138,6 +152,7 @@ pub mod clippy_mut_mut {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[derive(Debug)]
pub enum Enum<'a, T, U> {
Struct {
@@ -166,6 +181,7 @@ mod clippy_redundant_pub_crate {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[derive(Debug)]
pub enum Enum<T, U> {
Struct {
@@ -197,6 +213,7 @@ pub mod clippy_type_repetition_in_bounds {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
#[derive(Debug)]
pub enum Enum<T, U>
where
@@ -212,11 +229,11 @@ pub mod clippy_type_repetition_in_bounds {
}
}
+#[allow(missing_debug_implementations)]
pub mod clippy_used_underscore_binding {
use pin_project_lite::pin_project;
pin_project! {
- #[derive(Debug)]
pub struct Struct<T, U> {
#[pin]
pub _pinned: T,
@@ -227,7 +244,7 @@ pub mod clippy_used_underscore_binding {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
- #[derive(Debug)]
+ #[project(!Unpin)]
pub enum Enum<T, U> {
Struct {
#[pin]
@@ -252,6 +269,7 @@ pub mod clippy_ref_option_ref {
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
+ #[project(!Unpin)]
pub enum Enum<'a> {
Struct {
#[pin]
diff --git a/tests/proper_unpin.rs b/tests/proper_unpin.rs
index 668e975..89235a4 100644
--- a/tests/proper_unpin.rs
+++ b/tests/proper_unpin.rs
@@ -47,6 +47,18 @@ pub mod default {
assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>);
pin_project! {
+ #[project(!Unpin)]
+ enum NotUnpinEnum<T, U> {
+ V1 {
+ #[pin] f1: Inner<T>,
+ f2: U,
+ }
+ }
+ }
+
+ assert_not_unpin!(NotUnpinEnum<(), ()>);
+
+ pin_project! {
struct TrivialBounds {
#[pin]
f: PhantomPinned,
@@ -64,4 +76,25 @@ pub mod default {
}
assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>);
+
+ pin_project! {
+ #[project(!Unpin)]
+ struct NotUnpin<U> {
+ #[pin]
+ u: U
+ }
+ }
+
+ assert_not_unpin!(NotUnpin<()>);
+
+ pin_project! {
+ #[project(!Unpin)]
+ struct NotUnpinRef<'a, T, U> {
+ #[pin]
+ f1: &'a mut Inner<T>,
+ f2: U
+ }
+ }
+
+ assert_not_unpin!(NotUnpinRef<'_, (), ()>);
}
diff --git a/tests/test.rs b/tests/test.rs
index ed9b75c..d128930 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -616,6 +616,7 @@ fn attrs() {
pin_project! {
/// dox1
#[derive(Clone)]
+ #[project(!Unpin)]
#[project = Enum2Proj]
#[project_ref = Enum2ProjRef]
/// dox2
@@ -682,11 +683,13 @@ fn pinned_drop() {
req: Request,
}
+ /// dox1
impl<T, Request> PinnedDrop for Struct3<'_, T, Request>
where
T: Service<Request>,
T::Error: std::error::Error,
{
+ /// dox2
fn drop(mut this: Pin<&mut Self>) {
**this.as_mut().project().was_dropped = true;
}
diff --git a/tests/ui/pin_project/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr
index 66872bd..8c870d7 100644
--- a/tests/ui/pin_project/conflict-drop.stderr
+++ b/tests/ui/pin_project/conflict-drop.stderr
@@ -1,4 +1,4 @@
-error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type `Foo<_, _>`
+error[E0119]: conflicting implementations of trait `MustNotImplDrop` for type `Foo<_, _>`
--> tests/ui/pin_project/conflict-drop.rs:3:1
|
3 | / pin_project! { //~ ERROR E0119
@@ -13,4 +13,4 @@ error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type
| |_first implementation here
| conflicting implementation for `Foo<_, _>`
|
- = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/conflict-unpin.rs b/tests/ui/pin_project/conflict-unpin.rs
index f702f06..bdab20f 100644
--- a/tests/ui/pin_project/conflict-unpin.rs
+++ b/tests/ui/pin_project/conflict-unpin.rs
@@ -37,4 +37,28 @@ pin_project! { //~ ERROR E0119
// conflicting implementations
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+pin_project! { //~ ERROR E0119
+ #[project(!Unpin)]
+ struct Qux<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+ }
+}
+
+// conflicting implementations
+impl<T, U> Unpin for Qux<T, U> {} // Non-conditional Unpin impl
+
+pin_project! { //~ ERROR E0119
+ #[project(!Unpin)]
+ struct Fred<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+ }
+}
+
+// conflicting implementations
+impl<T: Unpin, U: Unpin> Unpin for Fred<T, U> {} // Conditional Unpin impl
+
fn main() {}
diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr
index bd30faf..cf9818e 100644
--- a/tests/ui/pin_project/conflict-unpin.stderr
+++ b/tests/ui/pin_project/conflict-unpin.stderr
@@ -1,4 +1,4 @@
-error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
+error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:5:1
|
5 | / pin_project! { //~ ERROR E0119
@@ -11,11 +11,11 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type
| |_^ conflicting implementation for `Foo<_, _>`
...
14 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
- | --------------------------------------------- first implementation here
+ | ------------------------------ first implementation here
|
- = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
+error[E0119]: conflicting implementations of trait `Unpin` for type `Bar<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:18:1
|
18 | / pin_project! { //~ ERROR E0119
@@ -30,9 +30,9 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type
27 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
| ------------------------------ first implementation here
|
- = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
+error[E0119]: conflicting implementations of trait `Unpin` for type `Baz<_, _>`
--> tests/ui/pin_project/conflict-unpin.rs:29:1
|
29 | / pin_project! { //~ ERROR E0119
@@ -47,4 +47,38 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type
38 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
| -------------------------------------------- first implementation here
|
- = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `Unpin` for type `Qux<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:40:1
+ |
+40 | / pin_project! { //~ ERROR E0119
+41 | | #[project(!Unpin)]
+42 | | struct Qux<T, U> {
+43 | | #[pin]
+... |
+46 | | }
+47 | | }
+ | |_^ conflicting implementation for `Qux<_, _>`
+...
+50 | impl<T, U> Unpin for Qux<T, U> {} // Non-conditional Unpin impl
+ | ------------------------------ first implementation here
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `Unpin` for type `Fred<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:52:1
+ |
+52 | / pin_project! { //~ ERROR E0119
+53 | | #[project(!Unpin)]
+54 | | struct Fred<T, U> {
+55 | | #[pin]
+... |
+58 | | }
+59 | | }
+ | |_^ conflicting implementation for `Fred<_, _>`
+...
+62 | impl<T: Unpin, U: Unpin> Unpin for Fred<T, U> {} // Conditional Unpin impl
+ | --------------------------------------------- first implementation here
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/invalid-bounds.stderr b/tests/ui/pin_project/invalid-bounds.stderr
index 40e79bf..ae15b7a 100644
--- a/tests/ui/pin_project/invalid-bounds.stderr
+++ b/tests/ui/pin_project/invalid-bounds.stderr
@@ -3,12 +3,24 @@ error: no rules expected the token `:`
|
4 | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `>`
+ --> src/lib.rs
+ |
+ | >)?
+ | ^
error: no rules expected the token `:`
--> tests/ui/pin_project/invalid-bounds.rs:10:33
|
10 | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `>`
+ --> src/lib.rs
+ |
+ | >)?
+ | ^
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:15:1
@@ -24,7 +36,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:15:1
@@ -39,7 +51,8 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_expected one of `+`, `,`, `=`, or `>`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:15:1
@@ -55,7 +68,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:15:1
@@ -71,7 +84,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:21:1
@@ -87,7 +100,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:21:1
@@ -102,7 +115,8 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_expected one of `+`, `,`, `=`, or `>`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:21:1
@@ -118,7 +132,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:21:1
@@ -134,7 +148,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:27:1
@@ -150,7 +164,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:27:1
@@ -165,7 +179,8 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_expected one of `+`, `,`, `=`, or `>`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:27:1
@@ -181,7 +196,7 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:27:1
@@ -197,25 +212,43 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
| |_unexpected token
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `Sized`
--> tests/ui/pin_project/invalid-bounds.rs:34:34
|
34 | struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized`
| ^^^^^ no rules expected this token in macro call
+ |
+note: while trying to match meta-variable `$generics_lifetime_bound:lifetime`
+ --> src/lib.rs
+ |
+ | $(: $generics_lifetime_bound:lifetime)?
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no rules expected the token `:`
--> tests/ui/pin_project/invalid-bounds.rs:42:20
|
42 | T: 'static : Sized //~ ERROR no rules expected the token `:`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `{`
+ --> src/lib.rs
+ |
+ | {
+ | ^
error: no rules expected the token `:`
--> tests/ui/pin_project/invalid-bounds.rs:51:20
|
51 | T: 'static : ?Sized //~ ERROR no rules expected the token `:`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `{`
+ --> src/lib.rs
+ |
+ | {
+ | ^
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:57:1
@@ -232,7 +265,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, or `{`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:57:1
@@ -249,7 +282,8 @@ error: expected one of `+`, `,`, or `{`, found `:`
| |_expected one of `+`, `,`, or `{`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:57:1
@@ -266,7 +300,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:57:1
@@ -283,7 +317,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:66:1
@@ -300,7 +334,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, or `{`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:66:1
@@ -317,7 +351,8 @@ error: expected one of `+`, `,`, or `{`, found `:`
| |_expected one of `+`, `,`, or `{`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:66:1
@@ -334,7 +369,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:66:1
@@ -351,7 +386,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:75:1
@@ -368,7 +403,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, or `{`, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:75:1
@@ -385,7 +420,8 @@ error: expected one of `+`, `,`, or `{`, found `:`
| |_expected one of `+`, `,`, or `{`
| unexpected token
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:75:1
@@ -402,7 +438,7 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `{` after struct name, found `:`
--> tests/ui/pin_project/invalid-bounds.rs:75:1
@@ -419,10 +455,16 @@ error: expected `{` after struct name, found `:`
| |_expected `{` after struct name
| in this macro invocation
|
- = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `Sized`
--> tests/ui/pin_project/invalid-bounds.rs:87:21
|
87 | T: ?Sized : Sized //~ ERROR no rules expected the token `Sized`
| ^^^^^ no rules expected this token in macro call
+ |
+note: while trying to match meta-variable `$where_clause_lifetime_bound:lifetime`
+ --> src/lib.rs
+ |
+ | $(: $where_clause_lifetime_bound:lifetime)?
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr
index 623a886..5d2e305 100644
--- a/tests/ui/pin_project/invalid.stderr
+++ b/tests/ui/pin_project/invalid.stderr
@@ -1,56 +1,50 @@
-error: no rules expected the token `struct`
- --> tests/ui/pin_project/invalid.rs:3:1
+error: no rules expected the token `(`
+ --> tests/ui/pin_project/invalid.rs:5:14
|
-3 | / pin_project! {
-4 | | struct A<T> {
-5 | | #[pin()] //~ ERROR no rules expected the token `(`
-6 | | pinned: T,
-7 | | }
-8 | | }
- | |_^ no rules expected this token in macro call
+5 | #[pin()] //~ ERROR no rules expected the token `(`
+ | ^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match `]`
+ --> src/lib.rs
+ |
+ | $(#[$pin:ident])?
+ | ^
-error: no rules expected the token `struct`
- --> tests/ui/pin_project/invalid.rs:3:1
+error: no rules expected the token `(`
+ --> tests/ui/pin_project/invalid.rs:5:14
+ |
+5 | #[pin()] //~ ERROR no rules expected the token `(`
+ | ^ no rules expected this token in macro call
|
-3 | / pin_project! {
-4 | | struct A<T> {
-5 | | #[pin()] //~ ERROR no rules expected the token `(`
-6 | | pinned: T,
-7 | | }
-8 | | }
- | |_^ no rules expected this token in macro call
+note: while trying to match `]`
+ --> src/lib.rs
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+ | $(#[$pin:ident])?
+ | ^
-error: no rules expected the token `struct`
- --> tests/ui/pin_project/invalid.rs:17:1
+error: no rules expected the token `#`
+ --> tests/ui/pin_project/invalid.rs:20:9
|
-17 | / pin_project! {
-18 | | struct C<T> {
-19 | | #[pin]
-20 | | #[pin] //~ ERROR no rules expected the token `#`
-21 | | pinned: T,
-22 | | }
-23 | | }
- | |_^ no rules expected this token in macro call
+20 | #[pin] //~ ERROR no rules expected the token `#`
+ | ^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match meta-variable `$field_vis:vis`
+ --> src/lib.rs
+ |
+ | $field_vis:vis $field:ident: $field_ty:ty
+ | ^^^^^^^^^^^^^^
-error: no rules expected the token `struct`
- --> tests/ui/pin_project/invalid.rs:17:1
+error: no rules expected the token `#`
+ --> tests/ui/pin_project/invalid.rs:20:9
+ |
+20 | #[pin] //~ ERROR no rules expected the token `#`
+ | ^ no rules expected this token in macro call
|
-17 | / pin_project! {
-18 | | struct C<T> {
-19 | | #[pin]
-20 | | #[pin] //~ ERROR no rules expected the token `#`
-21 | | pinned: T,
-22 | | }
-23 | | }
- | |_^ no rules expected this token in macro call
+note: while trying to match meta-variable `$field_vis:vis`
+ --> src/lib.rs
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+ | $field_vis:vis $field:ident: $field_ty:ty
+ | ^^^^^^^^^^^^^^
error: cannot find attribute `pin` in this scope
--> tests/ui/pin_project/invalid.rs:11:7
diff --git a/tests/ui/pin_project/overlapping_lifetime_names.stderr b/tests/ui/pin_project/overlapping_lifetime_names.stderr
index 35074d0..cfdffb2 100644
--- a/tests/ui/pin_project/overlapping_lifetime_names.stderr
+++ b/tests/ui/pin_project/overlapping_lifetime_names.stderr
@@ -1,38 +1,40 @@
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
+error[E0403]: the name `'__pin` is already used for a generic parameter in this item's generic parameters
--> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
- | | ^^^^^^ declared twice
+ | | ^^^^^^ already used
5 | | #[pin]
6 | | field: &'__pin mut T,
7 | | }
8 | | }
- | |_- previous declaration here
+ | |_- first use of `'__pin`
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
+error[E0403]: the name `'__pin` is already used for a generic parameter in this item's generic parameters
--> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
- | | ^^^^^^ declared twice
+ | | ^^^^^^ already used
5 | | #[pin]
6 | | field: &'__pin mut T,
7 | | }
8 | | }
- | |_- previous declaration here
+ | |_- first use of `'__pin`
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
- --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
+error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
- | | ^^^^^^ declared twice
+ | | ------ first declared here
5 | | #[pin]
6 | | field: &'__pin mut T,
7 | | }
8 | | }
- | |_- previous declaration here
+ | |_^ lifetime `'__pin` already in scope
+ |
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope
--> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
@@ -46,30 +48,28 @@ error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in
8 | | }
| |_^ lifetime `'__pin` already in scope
|
- = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope
- --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
+error[E0403]: the name `'__pin` is already used for a generic parameter in this item's generic parameters
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
- | | ------ first declared here
+ | | ^^^^^^ already used
5 | | #[pin]
6 | | field: &'__pin mut T,
7 | | }
8 | | }
- | |_^ lifetime `'__pin` already in scope
- |
- = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` (in Nightly builds, run with -Z macro-backtrace for more info)
+ | |_- first use of `'__pin`
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
+error[E0403]: the name `'__pin` is already used for a generic parameter in this item's generic parameters
--> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
- | | ^^^^^^ declared twice
+ | | ^^^^^^ already used
5 | | #[pin]
6 | | field: &'__pin mut T,
7 | | }
8 | | }
- | |_- previous declaration here
+ | |_- first use of `'__pin`
diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr
index 303e7cb..fd7d64f 100644
--- a/tests/ui/pin_project/overlapping_unpin_struct.stderr
+++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -1,11 +1,12 @@
error[E0277]: `PhantomPinned` cannot be unpinned
- --> tests/ui/pin_project/overlapping_unpin_struct.rs:19:5
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:19:16
|
19 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Origin<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^ within `_::__Origin<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: consider using `Box::pin`
-note: required because it appears within the type `_::__Origin<'_, PhantomPinned>`
+ = note: consider using the `pin!` macro
+ consider using `Box::pin` if you need to access the pinned value outside of the current scope
+note: required because it appears within the type `__Origin<'_, PhantomPinned>`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
|
5 | / pin_project! {
@@ -15,7 +16,7 @@ note: required because it appears within the type `_::__Origin<'_, PhantomPinned
9 | | }
10 | | }
| |_^
-note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>`
+note: required for `Foo<PhantomPinned>` to implement `Unpin`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
|
5 | / pin_project! {
@@ -24,10 +25,10 @@ note: required because of the requirements on the impl of `Unpin` for `Foo<Phant
8 | | inner: T,
9 | | }
10 | | }
- | |_^
+ | |_^ unsatisfied trait bound introduced here
note: required by a bound in `is_unpin`
--> tests/ui/pin_project/overlapping_unpin_struct.rs:16:16
|
16 | fn is_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `is_unpin`
- = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/packed.rs b/tests/ui/pin_project/packed.rs
index 50afb11..507a038 100644
--- a/tests/ui/pin_project/packed.rs
+++ b/tests/ui/pin_project/packed.rs
@@ -1,5 +1,3 @@
-#![allow(unaligned_references)]
-
use pin_project_lite::pin_project;
pin_project! { //~ ERROR reference to packed field is unaligned
diff --git a/tests/ui/pin_project/packed.stderr b/tests/ui/pin_project/packed.stderr
index 81fb4f1..710ec08 100644
--- a/tests/ui/pin_project/packed.stderr
+++ b/tests/ui/pin_project/packed.stderr
@@ -1,57 +1,101 @@
-error: reference to packed field is unaligned
- --> tests/ui/pin_project/packed.rs:5:1
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR reference to packed field is unaligned
+4 | | #[repr(packed, C)]
+5 | | struct Packed {
+6 | | #[pin]
+7 | | field: u16,
+8 | | }
+9 | | }
+ | |_^
+ |
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR reference to packed field is unaligned
+4 | | #[repr(packed, C)]
+5 | | struct Packed {
+6 | | #[pin]
+7 | | field: u16,
+8 | | }
+9 | | }
+ | |_^
+ |
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR reference to packed field is unaligned
+4 | | #[repr(packed, C)]
+5 | | struct Packed {
+6 | | #[pin]
+7 | | field: u16,
+8 | | }
+9 | | }
+ | |_^
+ |
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_constant` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:11:1
|
-5 | / pin_project! { //~ ERROR reference to packed field is unaligned
-6 | | #[repr(packed, C)]
-7 | | struct Packed {
-8 | | #[pin]
-9 | | field: u16,
-10 | | }
-11 | | }
+11 | / pin_project! { //~ ERROR reference to packed field is unaligned
+12 | | #[repr(packed(2))]
+13 | | struct PackedN {
+14 | | #[pin]
+15 | | field: u32,
+16 | | }
+17 | | }
| |_^
|
-note: the lint level is defined here
- --> tests/ui/pin_project/packed.rs:5:1
- |
-5 | / pin_project! { //~ ERROR reference to packed field is unaligned
-6 | | #[repr(packed, C)]
-7 | | struct Packed {
-8 | | #[pin]
-9 | | field: u16,
-10 | | }
-11 | | }
- | |_^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: reference to packed field is unaligned
- --> tests/ui/pin_project/packed.rs:13:1
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:11:1
|
-13 | / pin_project! { //~ ERROR reference to packed field is unaligned
-14 | | #[repr(packed(2))]
-15 | | struct PackedN {
-16 | | #[pin]
-17 | | field: u32,
-18 | | }
-19 | | }
+11 | / pin_project! { //~ ERROR reference to packed field is unaligned
+12 | | #[repr(packed(2))]
+13 | | struct PackedN {
+14 | | #[pin]
+15 | | field: u32,
+16 | | }
+17 | | }
| |_^
|
-note: the lint level is defined here
- --> tests/ui/pin_project/packed.rs:13:1
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0793]: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:11:1
|
-13 | / pin_project! { //~ ERROR reference to packed field is unaligned
-14 | | #[repr(packed(2))]
-15 | | struct PackedN {
-16 | | #[pin]
-17 | | field: u32,
-18 | | }
-19 | | }
+11 | / pin_project! { //~ ERROR reference to packed field is unaligned
+12 | | #[repr(packed(2))]
+13 | | struct PackedN {
+14 | | #[pin]
+15 | | field: u32,
+16 | | }
+17 | | }
| |_^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
- = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ |
+ = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+ = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
- = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_constant` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr
index 4eb6eff..aadd1f9 100644
--- a/tests/ui/pin_project/unpin_sneaky.stderr
+++ b/tests/ui/pin_project/unpin_sneaky.stderr
@@ -3,9 +3,3 @@ error[E0412]: cannot find type `__Origin` in this scope
|
10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321
| ^^^^^^^^ not found in this scope
-
-error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]`
- --> tests/ui/pin_project/unpin_sneaky.rs:10:1
- |
-10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321
- | ^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
diff --git a/tests/ui/pin_project/unsupported.stderr b/tests/ui/pin_project/unsupported.stderr
index a7d215a..f1d3b9c 100644
--- a/tests/ui/pin_project/unsupported.stderr
+++ b/tests/ui/pin_project/unsupported.stderr
@@ -6,7 +6,12 @@ error: no rules expected the token `}`
5 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match meta-variable `$field_vis:vis`
+ --> src/lib.rs
+ |
+ | $field_vis:vis $field:ident: $field_ty:ty
+ | ^^^^^^^^^^^^^^
+ = note: this error originates in the macro `$crate::__pin_project_expand` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `}`
--> tests/ui/pin_project/unsupported.rs:3:1
@@ -16,43 +21,60 @@ error: no rules expected the token `}`
5 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match meta-variable `$field_vis:vis`
+ --> src/lib.rs
+ |
+ | $field_vis:vis $field:ident: $field_ty:ty
+ | ^^^^^^^^^^^^^^
+ = note: this error originates in the macro `$crate::__pin_project_expand` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `(`
--> tests/ui/pin_project/unsupported.rs:8:19
|
8 | struct Struct2(); //~ ERROR no rules expected the token `(`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `{`
+ --> src/lib.rs
+ |
+ | {
+ | ^
error: no rules expected the token `;`
--> tests/ui/pin_project/unsupported.rs:12:19
|
12 | struct Struct3; //~ ERROR no rules expected the token `;`
| ^ no rules expected this token in macro call
+ |
+note: while trying to match `{`
+ --> src/lib.rs
+ |
+ | {
+ | ^
-error: no rules expected the token `enum`
- --> tests/ui/pin_project/unsupported.rs:15:1
+error: no rules expected the token `(`
+ --> tests/ui/pin_project/unsupported.rs:17:10
|
-15 | / pin_project! {
-16 | | enum Enum { //~ ERROR no rules expected the token `enum`
-17 | | A(u8)
-18 | | }
-19 | | }
- | |_^ no rules expected this token in macro call
+17 | A(u8)
+ | ^ no rules expected this token in macro call
+ |
+note: while trying to match `}`
+ --> src/lib.rs
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+ | }
+ | ^
-error: no rules expected the token `enum`
- --> tests/ui/pin_project/unsupported.rs:15:1
+error: no rules expected the token `(`
+ --> tests/ui/pin_project/unsupported.rs:17:10
|
-15 | / pin_project! {
-16 | | enum Enum { //~ ERROR no rules expected the token `enum`
-17 | | A(u8)
-18 | | }
-19 | | }
- | |_^ no rules expected this token in macro call
+17 | A(u8)
+ | ^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match `}`
+ --> src/lib.rs
+ |
+ | }
+ | ^
error: no rules expected the token `union`
--> tests/ui/pin_project/unsupported.rs:21:1
@@ -64,7 +86,14 @@ error: no rules expected the token `union`
25 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match `struct`
+ --> src/lib.rs
+ |
+ | [$(#[$attrs:meta])* $vis:vis struct $ident:ident]
+ | ^^^^^^
+ = note: captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens
+ = note: see <https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment> for more information
+ = note: this error originates in the macro `$crate::__pin_project_expand` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `union`
--> tests/ui/pin_project/unsupported.rs:21:1
@@ -76,4 +105,11 @@ error: no rules expected the token `union`
25 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match `struct`
+ --> src/lib.rs
+ |
+ | [$(#[$attrs:meta])* $vis:vis struct $ident:ident]
+ | ^^^^^^
+ = note: captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens
+ = note: see <https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment> for more information
+ = note: this error originates in the macro `$crate::__pin_project_expand` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr
index 597f67c..a622621 100644
--- a/tests/ui/pinned_drop/call-drop-inner.stderr
+++ b/tests/ui/pinned_drop/call-drop-inner.stderr
@@ -2,7 +2,10 @@ 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
+ | ^^^^^^^^^^^^ ----
+ | |
+ | unexpected argument of type `Pin<&mut S>`
+ | help: remove the extra argument
|
note: function defined here
--> tests/ui/pinned_drop/call-drop-inner.rs:3:1
@@ -15,8 +18,4 @@ note: function defined here
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();
- | ~~~~~~~~~~~~~~
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr
index d70009c..fe0ee79 100644
--- a/tests/ui/pinned_drop/conditional-drop-impl.stderr
+++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -7,10 +7,8 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented f
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 | | }
- | |_^
+5 | struct DropImpl<T> {
+ | ^^^^^^^^^^^^^^^^^^
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
@@ -35,4 +33,4 @@ note: the implementor must specify the same requirement
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)
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` which comes from the expansion of the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)