更新libclamav库1.0.0版本

This commit is contained in:
2023-01-14 18:28:39 +08:00
parent b879ee0b2e
commit 45fe15f472
8531 changed files with 1222046 additions and 177272 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,758 @@
# Changelog
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org).
<!--
Note: In this file, do not use the hard wrap in the middle of a sentence for compatibility with GitHub comment style markdown rendering.
-->
## [Unreleased]
## [1.0.12] - 2022-08-15
- Suppress `unused_tuple_struct_fields` lint in generated code.
## [1.0.11] - 2022-07-02
- [Suppress `dead_code` lint in generated code.](https://github.com/taiki-e/pin-project/pull/346)
## [1.0.10] - 2021-12-31
- Revert the increase of the minimal version of `syn` that was done in 1.0.9.
## [1.0.9] - 2021-12-26
- [Prevent abuse of private module.](https://github.com/taiki-e/pin-project/pull/336)
- Update minimal version of `syn` to 1.0.84.
## [1.0.8] - 2021-07-21
- [Suppress `clippy::use_self` and `clippy::type_repetition_in_bounds` lints in generated code.](https://github.com/taiki-e/pin-project/pull/331)
## [1.0.7] - 2021-04-16
- [Fix compile error when using `self::` as prefix of path inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/326)
## [1.0.6] - 2021-03-25
- [Suppress `clippy::semicolon_if_nothing_returned` lint in generated code.](https://github.com/taiki-e/pin-project/pull/318)
## [1.0.5] - 2021-02-03
- [Suppress `deprecated` lint in generated code.](https://github.com/taiki-e/pin-project/pull/313)
## [1.0.4] - 2021-01-09
- [Suppress `clippy::ref_option_ref` lint in generated code.](https://github.com/taiki-e/pin-project/pull/308)
## [1.0.3] - 2021-01-05
- Exclude unneeded files from crates.io.
## [1.0.2] - 2020-11-18
- [Suppress `clippy::unknown_clippy_lints` lint in generated code.](https://github.com/taiki-e/pin-project/pull/303)
## [1.0.1] - 2020-10-15
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/commit/ddcd88079ba2d82857c365f2a3543ad146ade54c).
- [Fix warnings when `#[pin_project]` attribute used within `macro_rules!` macros.](https://github.com/taiki-e/pin-project/pull/298)
## [1.0.0] - 2020-10-13
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/commit/ddcd88079ba2d82857c365f2a3543ad146ade54c).
- [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
```diff
- #[pin_project]
+ #[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
- #[project]
fn func<T>(x: Pin<&mut Enum<T>>) {
- #[project]
match x.project() {
- Enum::Variant(_) => { /* ... */ }
+ EnumProj::Variant(_) => { /* ... */ }
}
}
```
- [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
- [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
- [Raise the minimum supported Rust version of this crate from Rust 1.34 to Rust 1.37.](https://github.com/taiki-e/pin-project/pull/292)
- Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, `clippy::implicit_return`, and `clippy::redundant_pub_crate` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277), [#284](https://github.com/taiki-e/pin-project/pull/284))
- Diagnostic improvements.
Changes since the 1.0.0-alpha.1 release:
- [Fix drop order of pinned fields in `project_replace`.](https://github.com/taiki-e/pin-project/pull/287)
- Update minimal version of `syn` to 1.0.44.
## [1.0.0-alpha.1] - 2020-09-22
- [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
```diff
- #[pin_project]
+ #[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
- #[project]
fn func<T>(x: Pin<&mut Enum<T>>) {
- #[project]
match x.project() {
- Enum::Variant(_) => { /* ... */ }
+ EnumProj::Variant(_) => { /* ... */ }
}
}
```
- [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
- [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
- Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, and `clippy::implicit_return` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277))
- Diagnostic improvements.
See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project/issues/264).
## [0.4.30] - 2022-07-02
- [Suppress `dead_code` lint in generated code.](https://github.com/taiki-e/pin-project/pull/347)
## [0.4.29] - 2021-12-26
- [Fix compile error with `syn` 1.0.84 and later.](https://github.com/taiki-e/pin-project/pull/335)
## [0.4.28] - 2021-03-28
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix `unused_must_use` warning on unused borrows, which will be added to rustc in the future.](https://github.com/taiki-e/pin-project/pull/322) See [#322](https://github.com/taiki-e/pin-project/pull/322) for more details.
(Note: 1.0 does not have this problem.)
## [0.4.27] - 2020-10-11
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- Update minimal version of `syn` to 1.0.44.
## [0.4.26] - 2020-10-04
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix drop order of pinned fields in `project_replace`.](https://github.com/taiki-e/pin-project/pull/287)
## [0.4.25] - 2020-10-01
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Suppress `drop_bounds` lint, which will be added to rustc in the future.](https://github.com/taiki-e/pin-project/pull/273) See [#272](https://github.com/taiki-e/pin-project/issues/272) for more details.
(Note: 1.0.0-alpha.1 already contains this change.)
## [0.4.24] - 2020-09-26
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix compatibility of generated code with `forbid(future_incompatible)`.](https://github.com/taiki-e/pin-project/pull/282)
Note: This does not guarantee compatibility with `forbid(future_incompatible)` in the future.
If rustc adds a new lint, we may not be able to keep this.
## [0.4.23] - 2020-07-27
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix compile error with `?Sized` type parameters.](https://github.com/taiki-e/pin-project/pull/263)
## [0.4.22] - 2020-06-14
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- Documentation improvements.
## [0.4.21] - 2020-06-13
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes due to some unfixable limitations.](https://github.com/taiki-e/pin-project/pull/244)
Consider naming the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead.
```rust
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
fn func<T>(x: Pin<&mut Enum<T>>) {
match x.project() {
EnumProj::Variant(y) => {
let _: Pin<&mut T> = y;
}
}
}
```
See [#225](https://github.com/taiki-e/pin-project/pull/225) for more details.
- [Support `Self` in fields and generics in type definitions.](https://github.com/taiki-e/pin-project/pull/245)
- [Fix errors involving *"`self` value is a keyword only available in methods with `self` parameter"* in apparently correct code.](https://github.com/taiki-e/pin-project/pull/250)
- Diagnostic improvements.
## [0.4.20] - 2020-06-07
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [You can now use `project_replace` argument without Replace argument.](https://github.com/taiki-e/pin-project/pull/243)
This used to require you to specify both.
```diff
- #[pin_project(Replace, project_replace = EnumProjOwn)]
+ #[pin_project(project_replace = EnumProjOwn)]
enum Enum<T> {
Variant(#[pin] T)
}
```
- [Make `project_replace` argument an alias for `Replace` argument so that it can be used without a value.](https://github.com/taiki-e/pin-project/pull/243)
```rust
#[pin_project(project_replace)]
enum Enum<T> {
Variant(#[pin] T)
}
```
*The `Replace` argument will be deprecated in the future.*
- [Suppress `unreachable_pub` lint in generated code.](https://github.com/taiki-e/pin-project/pull/240)
## [0.4.19] - 2020-06-04
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Suppress `unused_results` lint in generated code.](https://github.com/taiki-e/pin-project/pull/239)
## [0.4.18] - 2020-06-04
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Support `Self` in more syntax positions inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/230)
- [Suppress `clippy::type_repetition_in_bounds` and `clippy::used_underscore_binding` lints in generated code.](https://github.com/taiki-e/pin-project/pull/233)
- Documentation improvements.
- Diagnostic improvements.
## [0.4.17] - 2020-05-18
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Support naming the projection types.](https://github.com/taiki-e/pin-project/pull/202)
By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:
```rust
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
fn func<T>(x: Pin<&mut Enum<T>>) {
match x.project() {
EnumProj::Variant(y) => {
let _: Pin<&mut T> = y;
}
}
}
```
## [0.4.16] - 2020-05-11
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix an issue that users can call internal function generated by `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/223)
## [0.4.15] - 2020-05-10
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [`#[project]` attribute can now handle all `project*` attributes in that scope with one wrapper attribute.](https://github.com/taiki-e/pin-project/pull/220)
## [0.4.14] - 2020-05-09
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Add `!Unpin` option to `#[pin_project]` attribute for guarantee the type is `!Unpin`.](https://github.com/taiki-e/pin-project/pull/219)
```rust
#[pin_project(!Unpin)]
struct Struct<T, U> {
field: T,
}
```
This is equivalent to use `#[pin]` attribute for `PhantomPinned` field.
```rust
#[pin_project]
struct Struct<T, U> {
field: T,
#[pin] // Note that using `PhantomPinned` without `#[pin]` attribute has no effect.
_pin: PhantomPinned,
}
```
*[Note: This raises the minimum supported Rust version of this crate from Rust 1.33 to Rust 1.34.](https://github.com/taiki-e/pin-project/pull/219#pullrequestreview-408644187)*
- [Fix an issue where duplicate `#[project]` attributes were ignored.](https://github.com/taiki-e/pin-project/pull/218)
- [Suppress `single_use_lifetimes` lint in generated code.](https://github.com/taiki-e/pin-project/pull/217)
- [Support overlapping lifetime names in HRTB.](https://github.com/taiki-e/pin-project/pull/217)
- [Hide generated items from --document-private-items.](https://github.com/taiki-e/pin-project/pull/211) See [#211](https://github.com/taiki-e/pin-project/pull/211) for details.
- Documentation improvements.
## [0.4.13] - 2020-05-07
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix a regression in 0.4.11.](https://github.com/taiki-e/pin-project/pull/207)
Changes from [0.4.10](https://github.com/taiki-e/pin-project/releases/tag/v0.4.10) and [0.4.12](https://github.com/taiki-e/pin-project/releases/tag/v0.4.12):
- [Fix an issue that `#[project]` on non-statement expression does not work without unstable features.](https://github.com/taiki-e/pin-project/pull/197)
- [Support overwriting the name of core crate.](https://github.com/taiki-e/pin-project/pull/199)
- [Suppress `clippy::needless_pass_by_value` lint in generated code of `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/200)
- Documentation improvements.
- Diagnostic improvements.
## [0.4.12] - 2020-05-07
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- A release to avoid [a regression in 0.4.11](https://github.com/taiki-e/pin-project/issues/206). No code changes from [0.4.10](https://github.com/taiki-e/pin-project/releases/tag/v0.4.10).
## [0.4.11] - 2020-05-07
**Note:** This release has been yanked. See [#206](https://github.com/taiki-e/pin-project/issues/206) for details.
- [Fix an issue that `#[project]` on non-statement expression does not work without unstable features.](https://github.com/taiki-e/pin-project/pull/197)
- [Support overwriting the name of core crate.](https://github.com/taiki-e/pin-project/pull/199)
- [Suppress `clippy::needless_pass_by_value` lint in generated code of `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/200)
- Documentation improvements.
- Diagnostic improvements.
## [0.4.10] - 2020-05-04
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Add `project_replace` method and `#[project_replace]` attribute.](https://github.com/taiki-e/pin-project/pull/194)
`project_replace` method is optional and can be enabled by passing the `Replace` argument to `#[pin_project]` attribute.
See [the documentation](https://docs.rs/pin-project/0.4/pin_project/attr.pin_project.html#project_replace) for more details.
- [Support `Self` and `self` in more syntax positions inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/190)
- [Hide all generated items except for projected types from calling code.](https://github.com/taiki-e/pin-project/pull/192) See [#192](https://github.com/taiki-e/pin-project/pull/192) for details.
## [0.4.9] - 2020-04-14
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix lifetime inference error when associated types are used in fields.](https://github.com/taiki-e/pin-project/pull/188)
- [Fix compile error with tuple structs with `where` clauses.](https://github.com/taiki-e/pin-project/pull/186)
- [`#[project]` attribute can now be used for `if let` expressions.](https://github.com/taiki-e/pin-project/pull/181)
## [0.4.8] - 2020-01-27
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Ensure that users cannot implement `PinnedDrop` without proper attribute argument.](https://github.com/taiki-e/pin-project/pull/180)
- [Fix use of `Self` in expression position inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/177)
## [0.4.7] - 2020-01-20
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix support for lifetime bounds.](https://github.com/taiki-e/pin-project/pull/176)
## [0.4.6] - 2019-11-20
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix compile error when there is `Self` in the where clause.](https://github.com/taiki-e/pin-project/pull/169)
## [0.4.5] - 2019-10-21
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix compile error with `dyn` types.](https://github.com/taiki-e/pin-project/pull/158)
## [0.4.4] - 2019-10-17
**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
- [Fix an issue where `PinnedDrop` implementations can call unsafe code without an unsafe block.](https://github.com/taiki-e/pin-project/pull/149)
## [0.4.3] - 2019-10-15
**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
- [`#[pin_project]` can now interoperate with `#[cfg_attr()]`.](https://github.com/taiki-e/pin-project/pull/135)
- [`#[pin_project]` can now interoperate with `#[cfg()]` on tuple structs and tuple variants.](https://github.com/taiki-e/pin-project/pull/135)
- [Fix support for DSTs(Dynamically Sized Types) on `#[pin_project(UnsafeUnpin)]`](https://github.com/taiki-e/pin-project/pull/120)
- Diagnostic improvements.
## [0.4.2] - 2019-09-29
**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
- [Fix support for DSTs(Dynamically Sized Types).](https://github.com/taiki-e/pin-project/pull/113)
## [0.4.1] - 2019-09-26
**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
- [Fix an issue that caused an error when using `#[pin_project]` on a type that has `#[pin]` + `!Unpin` field with no generics or lifetime.](https://github.com/taiki-e/pin-project/pull/111)
## [0.4.0] - 2019-09-25
**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
- [**Pin projection has become a safe operation.**](https://github.com/taiki-e/pin-project/pull/18) In the absence of other unsafe code that you write, it is impossible to cause undefined behavior.
- `#[unsafe_project]` attribute has been replaced with `#[pin_project]` attribute. ([#18](https://github.com/taiki-e/pin-project/pull/18), [#33](https://github.com/taiki-e/pin-project/pull/33))
- [The `Unpin` argument has been removed - an `Unpin` impl is now generated by default.](https://github.com/taiki-e/pin-project/pull/18)
- Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl. ([#18](https://github.com/taiki-e/pin-project/pull/18), [#33](https://github.com/taiki-e/pin-project/pull/33), [#86](https://github.com/taiki-e/pin-project/pull/86))
- [`Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait.](https://github.com/taiki-e/pin-project/pull/18)
- [`#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type.](https://github.com/taiki-e/pin-project/pull/96)
- [`#[pin_project]` can now be used for public type with private field types.](https://github.com/taiki-e/pin-project/pull/53)
- [`#[pin_project]` can now interoperate with `#[cfg()]`.](https://github.com/taiki-e/pin-project/pull/77)
- [Add `project_ref` method to `#[pin_project]` types.](https://github.com/taiki-e/pin-project/pull/93)
- [Add `#[project_ref]` attribute.](https://github.com/taiki-e/pin-project/pull/93)
- [Remove "project_attr" feature and always enable `#[project]` attribute.](https://github.com/taiki-e/pin-project/pull/94)
- [`#[project]` attribute can now be used for `impl` blocks.](https://github.com/taiki-e/pin-project/pull/46)
- [`#[project]` attribute can now be used for `use` statements.](https://github.com/taiki-e/pin-project/pull/85)
- [`#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions.](https://github.com/taiki-e/pin-project/pull/51)
Changes since the 0.4.0-beta.1 release:
- [Fix an issue that caused an error when using `#[pin_project(UnsafeUnpin)]` and not providing a manual `UnsafeUnpin` implementation on a type with no generics or lifetime.](https://github.com/taiki-e/pin-project/pull/107)
## [0.4.0-beta.1] - 2019-09-21
- [Change the argument type of project method back to `self: Pin<&mut Self>`.](https://github.com/taiki-e/pin-project/pull/90)
- [Remove "project_attr" feature and always enable `#[project]` attribute.](https://github.com/taiki-e/pin-project/pull/94)
- [Remove "renamed" feature.](https://github.com/taiki-e/pin-project/pull/100)
- [`#[project]` attribute can now be used for `use` statements.](https://github.com/taiki-e/pin-project/pull/85)
- [Add `project_ref` method and `#[project_ref]` attribute.](https://github.com/taiki-e/pin-project/pull/93)
- [`#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type.](https://github.com/taiki-e/pin-project/pull/96)
## [0.4.0-alpha.11] - 2019-09-11
- [Change #[pinned_drop] to trait implementation.](https://github.com/taiki-e/pin-project/pull/86)
```rust
#[pinned_drop]
impl<T> PinnedDrop for Foo<'_, T> {
fn drop(mut self: Pin<&mut Self>) {
**self.project().was_dropped = true;
}
}
```
- Add some examples and generated code.
- Diagnostic improvements.
## [0.4.0-alpha.10] - 2019-09-07
- [`#[pin_project]` can now interoperate with `#[cfg()]`.](https://github.com/taiki-e/pin-project/pull/77)
- Documentation improvements.
## [0.4.0-alpha.9] - 2019-09-05
- [Add `project_into` method to `#[pin_project]` types](https://github.com/taiki-e/pin-project/pull/69). This can be useful when returning a pin projection from a method.
```rust
fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
self.project_into().pinned
}
```
- [Prevent `UnpinStruct` from appearing in the document by default.](https://github.com/taiki-e/pin-project/pull/71) See [#71](https://github.com/taiki-e/pin-project/pull/71) for more details.
## [0.4.0-alpha.8] - 2019-09-03
- [Improve document of generated code.](https://github.com/taiki-e/pin-project/pull/62). Also added an option to control the document of generated code. See [#62](https://github.com/taiki-e/pin-project/pull/62) for more details.
- [Diagnostic improvements.](https://github.com/taiki-e/pin-project/pull/61)
## [0.4.0-alpha.7] - 2019-09-02
- [Suppress `dead_code` lint in generated types.](https://github.com/taiki-e/pin-project/pull/57)
## [0.4.0-alpha.6] - 2019-09-01
- [Allow using `#[pin_project]` type with private field types](https://github.com/taiki-e/pin-project/pull/53)
## [0.4.0-alpha.5] - 2019-08-24
- [`#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions.](https://github.com/taiki-e/pin-project/pull/51)
## [0.4.0-alpha.4] - 2019-08-23
- Suppress `clippy::drop_bounds` lint in generated code.
## [0.4.0-alpha.3] - 2019-08-23
- [Change `project` method generated by `#[pin_project]` attribute to take an `&mut Pin<&mut Self>` argument.](https://github.com/taiki-e/pin-project/pull/47)
- [`#[project]` attribute can now be used for impl blocks.](https://github.com/taiki-e/pin-project/pull/46)
- [`#[pin_project]` attribute can now detect that the type used does not have its own drop implementation without actually implementing drop.](https://github.com/taiki-e/pin-project/pull/48) This removed some restrictions.
## [0.4.0-alpha.2] - 2019-08-13
- Update `proc-macro2`, `syn`, and `quote` to 1.0.
## [0.4.0-alpha.1] - 2019-08-11
- **Pin projection has become a safe operation.**
- `#[unsafe_project]` has been replaced with `#[pin_project]`.
- The `Unpin` argument has been removed - an `Unpin` impl is now generated by default.
- Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl.
- `Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait.
- Make `#[project]` attribute disabled by default.
See also [tracking issue for 0.4 release](https://github.com/taiki-e/pin-project/issues/21).
## [0.3.5] - 2019-08-14
- Update `proc-macro2`, `syn`, and `quote` to 1.0.
## [0.3.4] - 2019-07-21
- Diagnostic improvements.
## [0.3.3] - 2019-07-15
**Note:** This release has been yanked. See [#16](https://github.com/taiki-e/pin-project/issues/16) for details.
- Diagnostic improvements.
## [0.3.2] - 2019-03-30
- Avoid suffixes on tuple index.
## [0.3.1] - 2019-03-02
- Documentation improvements.
- Update minimum `syn` version to 0.15.22.
## [0.3.0] - 2019-02-20
- Remove `unsafe_fields` attribute.
- Remove `unsafe_variants` attribute.
## [0.2.2] - 2019-02-20
- Fix a bug that generates incorrect code for the some structures with trait bounds on type generics.
## [0.2.1] - 2019-02-20
- Fix a bug that generates incorrect code for the structures with where clause and associated type fields.
## [0.2.0] - 2019-02-11
- Make `unsafe_fields` optional.
- Documentation improvements.
## [0.1.8] - 2019-02-02
- Add the feature to create projected enums to `unsafe_project`.
- Add `project` attribute to support pattern matching.
## [0.1.7] - 2019-01-19
- Fix documentation.
## [0.1.6] - 2019-01-19
- `unsafe_fields` can now opt-out.
- Add `unsafe_variants` attribute. This attribute is available if pin-project is built with the "unsafe_variants" feature.
## [0.1.5] - 2019-01-17
- Add support for tuple struct to `unsafe_project`.
## [0.1.4] - 2019-01-12
- Add options for automatically implementing `Unpin` to both `unsafe_project` and `unsafe_fields`.
## [0.1.3] - 2019-01-11
- Fix dependencies.
- Add `unsafe_fields` attribute.
## [0.1.2] - 2019-01-09
- Documentation improvements.
## [0.1.1] - 2019-01-08
- Rename from `unsafe_pin_project` to `unsafe_project`.
## [0.1.0] - 2019-01-08
**Note:** This release has been yanked.
Initial release
[Unreleased]: https://github.com/taiki-e/pin-project/compare/v1.0.12...HEAD
[1.0.12]: https://github.com/taiki-e/pin-project/compare/v1.0.11...v1.0.12
[1.0.11]: https://github.com/taiki-e/pin-project/compare/v1.0.10...v1.0.11
[1.0.10]: https://github.com/taiki-e/pin-project/compare/v1.0.9...v1.0.10
[1.0.9]: https://github.com/taiki-e/pin-project/compare/v1.0.8...v1.0.9
[1.0.8]: https://github.com/taiki-e/pin-project/compare/v1.0.7...v1.0.8
[1.0.7]: https://github.com/taiki-e/pin-project/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/taiki-e/pin-project/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/taiki-e/pin-project/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/taiki-e/pin-project/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/taiki-e/pin-project/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/taiki-e/pin-project/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/taiki-e/pin-project/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/taiki-e/pin-project/compare/v1.0.0-alpha.1...v1.0.0
[1.0.0-alpha.1]: https://github.com/taiki-e/pin-project/compare/v0.4.23...v1.0.0-alpha.1
[0.4.30]: https://github.com/taiki-e/pin-project/compare/v0.4.29...v0.4.30
[0.4.29]: https://github.com/taiki-e/pin-project/compare/v0.4.28...v0.4.29
[0.4.28]: https://github.com/taiki-e/pin-project/compare/v0.4.27...v0.4.28
[0.4.27]: https://github.com/taiki-e/pin-project/compare/v0.4.26...v0.4.27
[0.4.26]: https://github.com/taiki-e/pin-project/compare/v0.4.25...v0.4.26
[0.4.25]: https://github.com/taiki-e/pin-project/compare/v0.4.24...v0.4.25
[0.4.24]: https://github.com/taiki-e/pin-project/compare/v0.4.23...v0.4.24
[0.4.23]: https://github.com/taiki-e/pin-project/compare/v0.4.22...v0.4.23
[0.4.22]: https://github.com/taiki-e/pin-project/compare/v0.4.21...v0.4.22
[0.4.21]: https://github.com/taiki-e/pin-project/compare/v0.4.20...v0.4.21
[0.4.20]: https://github.com/taiki-e/pin-project/compare/v0.4.19...v0.4.20
[0.4.19]: https://github.com/taiki-e/pin-project/compare/v0.4.18...v0.4.19
[0.4.18]: https://github.com/taiki-e/pin-project/compare/v0.4.17...v0.4.18
[0.4.17]: https://github.com/taiki-e/pin-project/compare/v0.4.16...v0.4.17
[0.4.16]: https://github.com/taiki-e/pin-project/compare/v0.4.15...v0.4.16
[0.4.15]: https://github.com/taiki-e/pin-project/compare/v0.4.14...v0.4.15
[0.4.14]: https://github.com/taiki-e/pin-project/compare/v0.4.13...v0.4.14
[0.4.13]: https://github.com/taiki-e/pin-project/compare/v0.4.11...v0.4.13
[0.4.12]: https://github.com/taiki-e/pin-project/compare/v0.4.10...v0.4.12
[0.4.11]: https://github.com/taiki-e/pin-project/compare/v0.4.10...v0.4.11
[0.4.10]: https://github.com/taiki-e/pin-project/compare/v0.4.9...v0.4.10
[0.4.9]: https://github.com/taiki-e/pin-project/compare/v0.4.8...v0.4.9
[0.4.8]: https://github.com/taiki-e/pin-project/compare/v0.4.7...v0.4.8
[0.4.7]: https://github.com/taiki-e/pin-project/compare/v0.4.6...v0.4.7
[0.4.6]: https://github.com/taiki-e/pin-project/compare/v0.4.5...v0.4.6
[0.4.5]: https://github.com/taiki-e/pin-project/compare/v0.4.4...v0.4.5
[0.4.4]: https://github.com/taiki-e/pin-project/compare/v0.4.3...v0.4.4
[0.4.3]: https://github.com/taiki-e/pin-project/compare/v0.4.2...v0.4.3
[0.4.2]: https://github.com/taiki-e/pin-project/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/taiki-e/pin-project/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/taiki-e/pin-project/compare/v0.4.0-beta.1...v0.4.0
[0.4.0-beta.1]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.11...v0.4.0-beta.1
[0.4.0-alpha.11]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.10...v0.4.0-alpha.11
[0.4.0-alpha.10]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.9...v0.4.0-alpha.10
[0.4.0-alpha.9]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.8...v0.4.0-alpha.9
[0.4.0-alpha.8]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.7...v0.4.0-alpha.8
[0.4.0-alpha.7]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.6...v0.4.0-alpha.7
[0.4.0-alpha.6]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.5...v0.4.0-alpha.6
[0.4.0-alpha.5]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.4...v0.4.0-alpha.5
[0.4.0-alpha.4]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.3...v0.4.0-alpha.4
[0.4.0-alpha.3]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.2...v0.4.0-alpha.3
[0.4.0-alpha.2]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.1...v0.4.0-alpha.2
[0.4.0-alpha.1]: https://github.com/taiki-e/pin-project/compare/v0.3.5...v0.4.0-alpha.1
[0.3.5]: https://github.com/taiki-e/pin-project/compare/v0.3.4...v0.3.5
[0.3.4]: https://github.com/taiki-e/pin-project/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/taiki-e/pin-project/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/taiki-e/pin-project/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/taiki-e/pin-project/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/taiki-e/pin-project/compare/v0.2.2...v0.3.0
[0.2.2]: https://github.com/taiki-e/pin-project/compare/v0.2.1...v0.2.2
[0.2.1]: https://github.com/taiki-e/pin-project/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/taiki-e/pin-project/compare/v0.1.8...v0.2.0
[0.1.8]: https://github.com/taiki-e/pin-project/compare/v0.1.7...v0.1.8
[0.1.7]: https://github.com/taiki-e/pin-project/compare/v0.1.6...v0.1.7
[0.1.6]: https://github.com/taiki-e/pin-project/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/taiki-e/pin-project/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/taiki-e/pin-project/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/taiki-e/pin-project/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/taiki-e/pin-project/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/taiki-e/pin-project/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/taiki-e/pin-project/releases/tag/v0.1.0

View File

@@ -0,0 +1,222 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "diff"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "itoa"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
[[package]]
name = "macrotest"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7489ae0986ce45414b7b3122c2e316661343ecf396b206e3e15f07c846616f10"
dependencies = [
"diff",
"glob",
"prettyplease",
"serde",
"serde_json",
"syn",
"toml",
]
[[package]]
name = "once_cell"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "pin-project"
version = "1.0.12"
dependencies = [
"macrotest",
"pin-project-internal",
"rustversion",
"static_assertions",
"trybuild",
]
[[package]]
name = "pin-project-internal"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "prettyplease"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "697ae720ee02011f439e0701db107ffe2916d83f718342d65d7f8bf7b8a5fee9"
dependencies = [
"proc-macro2",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustversion"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
[[package]]
name = "ryu"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]]
name = "serde"
version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
[[package]]
name = "trybuild"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7f408301c7480f9e6294eb779cfc907f54bd901a9660ef24d7f233ed5376485"
dependencies = [
"glob",
"once_cell",
"serde",
"serde_derive",
"serde_json",
"termcolor",
"toml",
]
[[package]]
name = "unicode-ident"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@@ -0,0 +1,54 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.37"
name = "pin-project"
version = "1.0.12"
exclude = [
"/.*",
"/ci",
"/tools",
]
description = """
A crate for safe and ergonomic pin-projection.
"""
readme = "README.md"
keywords = [
"pin",
"macros",
"attribute",
]
categories = [
"no-std",
"rust-patterns",
]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/taiki-e/pin-project"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies.pin-project-internal]
version = "=1.0.12"
[dev-dependencies.macrotest]
version = "1.0.9"
[dev-dependencies.rustversion]
version = "1"
[dev-dependencies.static_assertions]
version = "1"
[dev-dependencies.trybuild]
version = "1.0.49"

View File

@@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,99 @@
# pin-project
[![crates.io](https://img.shields.io/crates/v/pin-project?style=flat-square&logo=rust)](https://crates.io/crates/pin-project)
[![docs.rs](https://img.shields.io/badge/docs.rs-pin--project-blue?style=flat-square&logo=docs.rs)](https://docs.rs/pin-project)
[![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/CI/main?style=flat-square&logo=github)](https://github.com/taiki-e/pin-project/actions)
A crate for safe and ergonomic [pin-projection].
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
pin-project = "1"
```
*Compiler support: requires rustc 1.37+*
## Examples
[`#[pin_project]`][`pin_project`] attribute creates projection types
covering all the fields of struct or enum.
```rust
use pin_project::pin_project;
use std::pin::Pin;
#[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
}
}
```
[*code like this will be generated*][struct-default-expanded]
To use `#[pin_project]` on enums, you need to name the projection type
returned from the method.
```rust
use pin_project::pin_project;
use std::pin::Pin;
#[pin_project(project = EnumProj)]
enum Enum<T, U> {
Pinned(#[pin] T),
Unpinned(U),
}
impl<T, U> Enum<T, U> {
fn method(self: Pin<&mut Self>) {
match self.project() {
EnumProj::Pinned(x) => {
let _: Pin<&mut T> = x;
}
EnumProj::Unpinned(y) => {
let _: &mut U = y;
}
}
}
}
```
[*code like this will be generated*][enum-default-expanded]
See [documentation](https://docs.rs/pin-project) for more details, and
see [examples] directory for more examples and generated code.
## Related Projects
- [pin-project-lite]: A lightweight version of pin-project written with declarative macros.
[`pin_project`]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html
[enum-default-expanded]: examples/enum-default-expanded.rs
[examples]: examples/README.md
[pin-project-lite]: https://github.com/taiki-e/pin-project-lite
[pin-projection]: https://doc.rust-lang.org/std/pin/index.html#projections-and-structural-pinning
[struct-default-expanded]: examples/struct-default-expanded.rs
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
[MIT license](LICENSE-MIT) at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.

View File

@@ -0,0 +1,39 @@
# Examples and generated code of each feature of pin-project
### Basic usage of `#[pin_project]` on structs
- [example](struct-default.rs)
- [generated code](struct-default-expanded.rs)
### Basic usage of `#[pin_project]` on enums
- [example](enum-default.rs)
- [generated code](enum-default-expanded.rs)
### Manual implementation of `Unpin` by `UnsafeUnpin`
- [example](unsafe_unpin.rs)
- [generated code](unsafe_unpin-expanded.rs)
- [`UnsafeUnpin` documentation](https://docs.rs/pin-project/1/pin_project/trait.UnsafeUnpin.html)
### Manual implementation of `Drop` by `#[pinned_drop]`
- [example](pinned_drop.rs)
- [generated code](pinned_drop-expanded.rs)
- [`#[pinned_drop]` documentation](https://docs.rs/pin-project/1/pin_project/attr.pinned_drop.html)
### `project_replace()` method
- [example](project_replace.rs)
- [generated code](project_replace-expanded.rs)
- [`project_replace()` documentation](https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#project_replace-method)
### Ensure `!Unpin` by `#[pin_project(!Unpin)]`
- [example](not_unpin.rs)
- [generated code](not_unpin-expanded.rs)
- [`!Unpin` documentation](https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin)
Note: These generated code examples are the little simplified version of the
actual generated code. See [expansion tests](../tests#expansion-tests-expand-expandtestrs) if you
want to see the exact version of the actual generated code.

View File

@@ -0,0 +1,101 @@
// Original code (./enum-default.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use pin_project::pin_project;
//
// #[pin_project(project = EnumProj)]
// enum Enum<T, U> {
// Pinned(#[pin] T),
// Unpinned(U),
// }
//
// fn main() {}
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(
clippy::needless_lifetimes,
clippy::just_underscores_and_digits,
clippy::used_underscore_binding
)]
use pin_project::pin_project;
// #[pin_project(project = EnumProj)]
enum Enum<T, U> {
Pinned(/* #[pin] */ T),
Unpinned(U),
}
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Pinned(::pin_project::__private::Pin<&'pin mut (T)>),
Unpinned(&'pin mut (U)),
}
const _: () = {
// When `#[pin_project]` is used on enums, only named projection types and
// methods are generated because there is no way to access variants of
// projected types without naming it.
// (When `#[pin_project]` is used on structs, both methods are always generated.)
impl<T, U> Enum<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Pinned(_0) => {
EnumProj::Pinned(::pin_project::__private::Pin::new_unchecked(_0))
}
Self::Unpinned(_0) => EnumProj::Unpinned(_0),
}
}
}
}
// Automatically create the appropriate conditional `Unpin` implementation.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
// for details.
struct __Enum<'pin, T, U> {
__pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
'pin,
(::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
>,
__field0: T,
}
impl<'pin, T, U> ::pin_project::__private::Unpin for Enum<T, U> where
__Enum<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
#[doc(hidden)]
unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Enum<T, U> where
__Enum<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// Ensure that enum does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
// We don't need to check for `#[repr(packed)]`,
// since it does not apply to enums.
};
fn main() {}

View File

@@ -0,0 +1,13 @@
// See ./enum-default-expanded.rs for generated code.
#![allow(dead_code)]
use pin_project::pin_project;
#[pin_project(project = EnumProj)]
enum Enum<T, U> {
Pinned(#[pin] T),
Unpinned(U),
}
fn main() {}

View File

@@ -0,0 +1,125 @@
// Original code (./not_unpin.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use pin_project::pin_project;
//
// #[pin_project(!Unpin)]
// pub struct Struct<T, U> {
// #[pin]
// pinned: T,
// unpinned: U,
// }
//
// fn main() {
// fn _is_unpin<T: Unpin>() {}
// // _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
// }
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
// #[pin_project(!Unpin)]
pub struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
const _: () = {
pub(crate) struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
pub(crate) struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
pub(crate) fn project_ref<'pin>(
self: ::pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)]
// struct.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
// Create `Unpin` impl that has trivial `Unpin` bounds.
//
// See https://github.com/taiki-e/pin-project/issues/102#issuecomment-540472282
// for details.
impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>:
::pin_project::__private::Unpin
{
}
// A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
//
// To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
// impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
// impl, they'll get a "conflicting implementations of trait" error when
// coherence checks are run.
#[doc(hidden)]
unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>:
::pin_project::__private::Unpin
{
}
// Ensure that struct does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {
fn _is_unpin<T: Unpin>() {}
// _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
}

View File

@@ -0,0 +1,17 @@
// See ./not_unpin-expanded.rs for generated code.
#![allow(dead_code)]
use pin_project::pin_project;
#[pin_project(!Unpin)]
pub struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {
fn _is_unpin<T: Unpin>() {}
// _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
}

View File

@@ -0,0 +1,154 @@
// Original code (./pinned_drop.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use std::pin::Pin;
//
// use pin_project::{pin_project, pinned_drop};
//
// #[pin_project(PinnedDrop)]
// pub struct Struct<'a, T> {
// was_dropped: &'a mut bool,
// #[pin]
// field: T,
// }
//
// #[pinned_drop]
// fn drop_Struct<T>(mut this: Pin<&mut Struct<'_, T>>) {
// **this.project().was_dropped = true;
// }
//
// fn main() {}
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(clippy::needless_lifetimes, clippy::mut_mut)]
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
// #[pin_project(PinnedDrop)]
pub struct Struct<'a, T> {
was_dropped: &'a mut bool,
// #[pin]
field: T,
}
const _: () = {
pub(crate) struct __StructProjection<'pin, 'a, T>
where
Struct<'a, T>: 'pin,
{
was_dropped: &'pin mut (&'a mut bool),
field: ::pin_project::__private::Pin<&'pin mut (T)>,
}
pub(crate) struct __StructProjectionRef<'pin, 'a, T>
where
Struct<'a, T>: 'pin,
{
was_dropped: &'pin (&'a mut bool),
field: ::pin_project::__private::Pin<&'pin (T)>,
}
impl<'a, T> Struct<'a, T> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, 'a, T> {
unsafe {
let Self { was_dropped, field } = self.get_unchecked_mut();
__StructProjection {
was_dropped,
field: ::pin_project::__private::Pin::new_unchecked(field),
}
}
}
pub(crate) fn project_ref<'pin>(
self: ::pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, 'a, T> {
unsafe {
let Self { was_dropped, field } = self.get_ref();
__StructProjectionRef {
was_dropped,
field: ::pin_project::__private::Pin::new_unchecked(field),
}
}
}
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)]
// struct.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<'a, T>(this: &Struct<'a, T>) {
let _ = &this.was_dropped;
let _ = &this.field;
}
impl<'a, T> ::pin_project::__private::Drop for Struct<'a, T> {
fn drop(&mut self) {
// Safety - we're in 'drop', so we know that 'self' will
// never move again.
let pinned_self = unsafe { ::pin_project::__private::Pin::new_unchecked(self) };
// We call `pinned_drop` only once. Since `PinnedDrop::drop`
// is an unsafe method and a private API, it is never called again in safe
// code *unless the user uses a maliciously crafted macro*.
unsafe {
::pin_project::__private::PinnedDrop::drop(pinned_self);
}
}
}
// Automatically create the appropriate conditional `Unpin` implementation.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
// for details.
pub struct __Struct<'pin, 'a, T> {
__pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<'pin, (T)>,
__field0: T,
__lifetime0: &'a (),
}
impl<'pin, 'a, T> ::pin_project::__private::Unpin for Struct<'a, T> where
__Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
{
}
// A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
#[doc(hidden)]
unsafe impl<'pin, 'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where
__Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
{
}
};
// Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
// This is because destructors can be called multiple times in safe code and
// [double dropping is unsound](https://github.com/rust-lang/rust/pull/62360).
//
// Ideally, it would be desirable to be able to forbid manual calls in
// the same way as `Drop::drop`, but the library cannot do it. So, by using
// macros and replacing them with private traits, we prevent users from
// calling `PinnedDrop::drop`.
//
// Users can implement [`Drop`] safely using `#[pinned_drop]` and can drop a
// type that implements `PinnedDrop` using the [`drop`] function safely.
// **Do not call or implement this trait directly.**
#[doc(hidden)]
impl<T> ::pin_project::__private::PinnedDrop for Struct<'_, T> {
// Since calling it twice on the same object would be UB,
// this method is unsafe.
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T>(__self: Pin<&mut Struct<'_, T>>) {
// A dummy `__drop_inner` function to prevent users call outer `__drop_inner`.
fn __drop_inner() {}
**__self.project().was_dropped = true;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,23 @@
// See ./pinned_drop-expanded.rs for generated code.
#![allow(dead_code)]
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
pub struct Struct<'a, T> {
was_dropped: &'a mut bool,
#[pin]
field: T,
}
#[pinned_drop]
impl<T> PinnedDrop for Struct<'_, T> {
fn drop(self: Pin<&mut Self>) {
**self.project().was_dropped = true;
}
}
fn main() {}

View File

@@ -0,0 +1,156 @@
// Original code (./struct-default.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use pin_project::pin_project;
//
// #[pin_project(project_replace)]
// struct Struct<T, U> {
// #[pin]
// pinned: T,
// unpinned: U,
// }
//
// fn main() {}
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
// #[pin_project(project_replace)]
struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
const _: () = {
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
struct __StructProjectionOwned<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
impl<T, U> Struct<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
fn project_ref<'pin>(
self: ::pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
fn project_replace(
self: ::pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __StructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
// Destructors will run in reverse order, so next create a guard to overwrite
// `self` with the replacement value without calling destructors.
let __guard =
::pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement);
let Self { pinned, unpinned } = &mut *__self_ptr;
// First, extract all the unpinned fields
let __result = __StructProjectionOwned {
pinned: ::pin_project::__private::PhantomData,
unpinned: ::pin_project::__private::ptr::read(unpinned),
};
// Now create guards to drop all the pinned fields
//
// Due to a compiler bug (https://github.com/rust-lang/rust/issues/47949)
// this must be in its own scope, or else `__result` will not be dropped
// if any of the destructors panic.
{
let __guard = ::pin_project::__private::UnsafeDropInPlaceGuard::new(pinned);
}
// Finally, return the result
__result
}
}
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)]
// struct.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
// Automatically create the appropriate conditional `Unpin` implementation.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
// for details.
struct __Struct<'pin, T, U> {
__pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
'pin,
(::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
>,
__field0: T,
}
impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
__Struct<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
#[doc(hidden)]
unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
__Struct<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// Ensure that struct does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
// See ./struct-default-expanded.rs for generated code.
#![allow(dead_code)]
use pin_project::pin_project;
#[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,155 @@
// Original code (./struct-default.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use pin_project::pin_project;
//
// #[pin_project]
// struct Struct<T, U> {
// #[pin]
// pinned: T,
// unpinned: U,
// }
//
// fn main() {}
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
// #[pin_project]
struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
const _: () = {
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
fn project_ref<'pin>(
self: ::pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)]
// struct.
//
// Taking a reference to a packed field is UB, and applying
// `#[forbid(unaligned_references)]` makes sure that doing this is a hard error.
//
// If the struct ends up having #[repr(packed)] applied somehow,
// this will generate an (unfriendly) error message. Under all reasonable
// circumstances, we'll detect the #[repr(packed)] attribute, and generate
// a much nicer error above.
//
// See https://github.com/taiki-e/pin-project/pull/34 for more details.
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
// Automatically create the appropriate conditional `Unpin` implementation.
//
// Basically this is equivalent to the following code:
//
// ```rust
// impl<T, U> Unpin for Struct<T, U> where T: Unpin {}
// ```
//
// However, if struct is public and there is a private type field,
// this would cause an E0446 (private type in public interface).
//
// When RFC 2145 is implemented (rust-lang/rust#48054),
// this will become a lint, rather then a hard error.
//
// As a workaround for this, we generate a new struct, containing all of
// the pinned fields from our #[pin_project] type. This struct is declared
// within a function, which makes it impossible to be named by user code.
// This guarantees that it will use the default auto-trait impl for Unpin -
// that is, it will implement Unpin iff all of its fields implement Unpin.
// This type can be safely declared as 'public', satisfying the privacy
// checker without actually allowing user code to access it.
//
// This allows users to apply the #[pin_project] attribute to types
// regardless of the privacy of the types of their fields.
//
// See also https://github.com/taiki-e/pin-project/pull/53.
struct __Struct<'pin, T, U> {
__pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
'pin,
(::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
>,
__field0: T,
}
impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
__Struct<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
//
// To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
// impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
// impl, they'll get a "conflicting implementations of trait" error when
// coherence checks are run.
#[doc(hidden)]
unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
__Struct<'pin, T, U>: ::pin_project::__private::Unpin
{
}
// Ensure that struct does not implement `Drop`.
//
// If you attempt to provide an Drop impl, the blanket impl will
// then apply to your type, causing a compile-time error due to
// the conflict with the second impl.
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
// See ./struct-default-expanded.rs for generated code.
#![allow(dead_code)]
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,107 @@
// Original code (./unsafe_unpin.rs):
//
// ```rust
// #![allow(dead_code)]
//
// use pin_project::{pin_project, UnsafeUnpin};
//
// #[pin_project(UnsafeUnpin)]
// pub struct Struct<T, U> {
// #[pin]
// pinned: T,
// unpinned: U,
// }
//
// unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
//
// fn main() {}
// ```
#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
#![allow(clippy::needless_lifetimes)]
use pin_project::{pin_project, UnsafeUnpin};
// #[pin_project(UnsafeUnpin)]
pub struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
const _: () = {
pub(crate) struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
pub(crate) struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
pub(crate) fn project_ref<'pin>(
self: ::pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
// Ensure that it's impossible to use pin projections on a #[repr(packed)]
// struct.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
// for details.
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
// Implement `Unpin` via `UnsafeUnpin`.
impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin
{
}
// Ensure that struct does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,16 @@
// See ./unsafe_unpin-expanded.rs for generated code.
#![allow(dead_code)]
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin)]
pub struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,315 @@
//! A crate for safe and ergonomic [pin-projection].
//!
//! # Examples
//!
//! [`#[pin_project]`][`pin_project`] attribute creates projection types
//! covering all the fields of struct or enum.
//!
//! ```rust
//! use std::pin::Pin;
//!
//! use pin_project::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
//! }
//! }
//! ```
//!
//! [*code like this will be generated*][struct-default-expanded]
//!
//! 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::pin_project;
//!
//! #[pin_project(project = EnumProj)]
//! enum Enum<T, U> {
//! Pinned(#[pin] T),
//! Unpinned(U),
//! }
//!
//! impl<T, U> Enum<T, U> {
//! fn method(self: Pin<&mut Self>) {
//! match self.project() {
//! EnumProj::Pinned(x) => {
//! let _: Pin<&mut T> = x;
//! }
//! EnumProj::Unpinned(y) => {
//! let _: &mut U = y;
//! }
//! }
//! }
//! }
//! ```
//!
//! [*code like this will be generated*][enum-default-expanded]
//!
//! See [`#[pin_project]`][`pin_project`] attribute for more details, and
//! see [examples] directory for more examples and generated code.
//!
//! [examples]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/README.md
//! [enum-default-expanded]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/enum-default-expanded.rs
//! [pin-projection]: core::pin#projections-and-structural-pinning
//! [struct-default-expanded]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/struct-default-expanded.rs
#![no_std]
#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms, single_use_lifetimes),
allow(dead_code, unused_variables)
)
))]
#![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
#![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::default_union_representation,
clippy::trailing_empty_array,
clippy::transmute_undefined_repr,
clippy::undocumented_unsafe_blocks,
)]
#![allow(clippy::needless_doctest_main)]
#[doc(inline)]
pub use pin_project_internal::pin_project;
#[doc(inline)]
pub use pin_project_internal::pinned_drop;
/// A trait used for custom implementations of [`Unpin`].
///
/// This trait is used in conjunction with the `UnsafeUnpin` argument to
/// the [`#[pin_project]`][macro@pin_project] attribute.
///
/// # Safety
///
/// The Rust [`Unpin`] trait is safe to implement - by itself,
/// implementing it cannot lead to [undefined behavior][undefined-behavior].
/// Undefined behavior can only occur when other unsafe code is used.
///
/// It turns out that using pin projections, which requires unsafe code,
/// imposes additional requirements on an [`Unpin`] impl. Normally, all of this
/// unsafety is contained within this crate, ensuring that it's impossible for
/// you to violate any of the guarantees required by pin projection.
///
/// However, things change if you want to provide a custom [`Unpin`] impl
/// for your `#[pin_project]` type. As stated in [the Rust
/// documentation][pin-projection], you must be sure to only implement [`Unpin`]
/// when all of your `#[pin]` fields (i.e. structurally pinned fields) are also
/// [`Unpin`].
///
/// To help highlight this unsafety, the `UnsafeUnpin` trait is provided.
/// Implementing this trait is logically equivalent to implementing [`Unpin`] -
/// this crate will generate an [`Unpin`] impl for your type that 'forwards' to
/// your `UnsafeUnpin` impl. However, this trait is `unsafe` - since your type
/// uses structural pinning (otherwise, you wouldn't be using this crate!),
/// you must be sure that your `UnsafeUnpin` impls follows all of
/// the requirements for an [`Unpin`] impl of a structurally-pinned type.
///
/// Note that if you specify `#[pin_project(UnsafeUnpin)]`, but do *not*
/// provide an impl of `UnsafeUnpin`, your type will never implement [`Unpin`].
/// This is effectively the same thing as adding a [`PhantomPinned`] to your
/// type.
///
/// Since this trait is `unsafe`, impls of it will be detected by the
/// `unsafe_code` lint, and by tools like [`cargo geiger`][cargo-geiger].
///
/// # Examples
///
/// An `UnsafeUnpin` impl which, in addition to requiring that structurally
/// pinned fields be [`Unpin`], imposes an additional requirement:
///
/// ```rust
/// use pin_project::{pin_project, UnsafeUnpin};
///
/// #[pin_project(UnsafeUnpin)]
/// struct Struct<K, V> {
/// #[pin]
/// field_1: K,
/// field_2: V,
/// }
///
/// unsafe impl<K, V> UnsafeUnpin for Struct<K, V> where K: Unpin + Clone {}
/// ```
///
/// [`PhantomPinned`]: core::marker::PhantomPinned
/// [cargo-geiger]: https://github.com/rust-secure-code/cargo-geiger
/// [pin-projection]: core::pin#projections-and-structural-pinning
/// [undefined-behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
pub unsafe trait UnsafeUnpin {}
// Not public API.
#[doc(hidden)]
pub mod __private {
use core::mem::ManuallyDrop;
#[doc(hidden)]
pub use core::{
marker::{PhantomData, PhantomPinned, Unpin},
ops::Drop,
pin::Pin,
ptr,
};
#[doc(hidden)]
pub use pin_project_internal::__PinProjectInternalDerive;
use super::UnsafeUnpin;
// An internal trait used for custom implementations of [`Drop`].
//
// **Do not call or implement this trait directly.**
//
// # Why this trait is private and `#[pinned_drop]` attribute is needed?
//
// Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
// This is because destructors can be called multiple times in safe code and
// [double dropping is unsound][rust-lang/rust#62360].
//
// Ideally, it would be desirable to be able to forbid manual calls in
// the same way as [`Drop::drop`], but the library cannot do it. So, by using
// macros and replacing them with private traits,
// this crate prevent users from calling `PinnedDrop::drop` in safe code.
//
// This allows implementing [`Drop`] safely using `#[pinned_drop]`.
// Also by using the [`drop`] function just like dropping a type that directly
// implements [`Drop`], can drop safely a type that implements `PinnedDrop`.
//
// [rust-lang/rust#62360]: https://github.com/rust-lang/rust/pull/62360
#[doc(hidden)]
pub trait PinnedDrop {
#[doc(hidden)]
unsafe fn drop(self: Pin<&mut Self>);
}
// This is an internal helper struct used by `pin-project-internal`.
// This allows us to force an error if the user tries to provide
// a regular `Unpin` impl when they specify the `UnsafeUnpin` argument.
// This is why we need Wrapper:
//
// Supposed we have the following code:
//
// ```rust
// #[pin_project(UnsafeUnpin)]
// struct MyStruct<T> {
// #[pin] field: T
// }
//
// impl<T> Unpin for MyStruct<T> where MyStruct<T>: UnsafeUnpin {} // generated by pin-project-internal
// impl<T> Unpin for MyStruct<T> where T: Copy // written by the user
// ```
//
// We want this code to be rejected - the user is completely bypassing
// `UnsafeUnpin`, and providing an unsound Unpin impl in safe code!
//
// Unfortunately, the Rust compiler will accept the above code.
// Because MyStruct is declared in the same crate as the user-provided impl,
// the compiler will notice that `MyStruct<T>: UnsafeUnpin` never holds.
//
// The solution is to introduce the `Wrapper` struct, which is defined
// in the `pin-project` crate.
//
// We now have code that looks like this:
//
// ```rust
// impl<T> Unpin for MyStruct<T> where Wrapper<MyStruct<T>>: UnsafeUnpin {} // generated by pin-project-internal
// impl<T> Unpin for MyStruct<T> where T: Copy // written by the user
// ```
//
// We also have `unsafe impl<T> UnsafeUnpin for Wrapper<T> where T: UnsafeUnpin {}`
// in the `pin-project` crate.
//
// Now, our generated impl has a bound involving a type defined in another
// crate - Wrapper. This will cause rust to conservatively assume that
// `Wrapper<MyStruct<T>>: UnsafeUnpin` holds, in the interest of preserving
// forwards compatibility (in case such an impl is added for Wrapper<T> in
// a new version of the crate).
//
// This will cause rust to reject any other `Unpin` impls for MyStruct<T>,
// since it will assume that our generated impl could potentially apply in
// any situation.
//
// This achieves the desired effect - when the user writes
// `#[pin_project(UnsafeUnpin)]`, the user must either provide no impl of
// `UnsafeUnpin` (which is equivalent to making the type never implement
// Unpin), or provide an impl of `UnsafeUnpin`. It is impossible for them to
// provide an impl of `Unpin`
#[doc(hidden)]
pub struct Wrapper<'a, T: ?Sized>(PhantomData<&'a ()>, T);
// SAFETY: `T` implements UnsafeUnpin.
unsafe impl<T: ?Sized + UnsafeUnpin> UnsafeUnpin for Wrapper<'_, T> {}
// This is an internal helper struct used by `pin-project-internal`.
//
// See https://github.com/taiki-e/pin-project/pull/53 for more details.
#[doc(hidden)]
pub struct AlwaysUnpin<'a, T>(PhantomData<&'a ()>, PhantomData<T>);
impl<T> Unpin for AlwaysUnpin<'_, T> {}
// This is an internal helper used to ensure a value is dropped.
#[doc(hidden)]
pub struct UnsafeDropInPlaceGuard<T: ?Sized>(*mut T);
impl<T: ?Sized> UnsafeDropInPlaceGuard<T> {
#[doc(hidden)]
pub unsafe fn new(ptr: *mut T) -> Self {
Self(ptr)
}
}
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);
}
}
}
// This is an internal helper used to ensure a value is overwritten without
// its destructor being called.
#[doc(hidden)]
pub struct UnsafeOverwriteGuard<T> {
target: *mut T,
value: ManuallyDrop<T>,
}
impl<T> UnsafeOverwriteGuard<T> {
#[doc(hidden)]
pub unsafe fn new(target: *mut T, value: T) -> Self {
Self { target, value: ManuallyDrop::new(value) }
}
}
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));
}
}
}
}

View File

@@ -0,0 +1,44 @@
# 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 [examples](../examples/README.md) 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).

View File

@@ -0,0 +1,12 @@
#![allow(dead_code, unused_macros)]
macro_rules! assert_unpin {
($ty:ty) => {
static_assertions::assert_impl_all!($ty: Unpin);
};
}
macro_rules! assert_not_unpin {
($ty:ty) => {
static_assertions::assert_not_impl_all!($ty: Unpin);
};
}

View File

@@ -0,0 +1,184 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
// Refs: https://doc.rust-lang.org/reference/attributes.html
#[macro_use]
mod auxiliary;
use std::{marker::PhantomPinned, pin::Pin};
use pin_project::pin_project;
struct Always;
// Use this type to check that `cfg(any())` is working properly.
struct Never(PhantomPinned);
#[test]
fn cfg() {
// structs
#[pin_project(project_replace)]
struct SameName {
#[cfg(not(any()))]
#[pin]
inner: Always,
#[cfg(any())]
#[pin]
inner: Never,
}
assert_unpin!(SameName);
let _ = SameName { inner: Always };
#[pin_project(project_replace)]
struct DifferentName {
#[cfg(not(any()))]
#[pin]
a: Always,
#[cfg(any())]
#[pin]
n: Never,
}
assert_unpin!(DifferentName);
let _ = DifferentName { a: Always };
#[pin_project(project_replace)]
struct TupleStruct(
#[cfg(not(any()))]
#[pin]
Always,
#[cfg(any())]
#[pin]
Never,
);
assert_unpin!(TupleStruct);
let _ = TupleStruct(Always);
// enums
#[pin_project(
project = VariantProj,
project_ref = VariantProjRef,
project_replace = VariantProjOwn,
)]
enum Variant {
#[cfg(not(any()))]
Inner(#[pin] Always),
#[cfg(any())]
Inner(#[pin] Never),
#[cfg(not(any()))]
A(#[pin] Always),
#[cfg(any())]
N(#[pin] Never),
}
assert_unpin!(Variant);
let _ = Variant::Inner(Always);
let _ = Variant::A(Always);
#[pin_project(
project = FieldProj,
project_ref = FieldProjRef,
project_replace = FieldProjOwn,
)]
enum Field {
SameName {
#[cfg(not(any()))]
#[pin]
inner: Always,
#[cfg(any())]
#[pin]
inner: Never,
},
DifferentName {
#[cfg(not(any()))]
#[pin]
a: Always,
#[cfg(any())]
#[pin]
n: Never,
},
TupleVariant(
#[cfg(not(any()))]
#[pin]
Always,
#[cfg(any())]
#[pin]
Never,
),
}
assert_unpin!(Field);
let _ = Field::SameName { inner: Always };
let _ = Field::DifferentName { a: Always };
let _ = Field::TupleVariant(Always);
}
#[test]
fn cfg_attr() {
#[pin_project(project_replace)]
struct SameCfg {
#[cfg(not(any()))]
#[cfg_attr(not(any()), pin)]
inner: Always,
#[cfg(any())]
#[cfg_attr(any(), pin)]
inner: Never,
}
assert_unpin!(SameCfg);
let mut x = SameCfg { inner: Always };
let x = Pin::new(&mut x).project();
let _: Pin<&mut Always> = x.inner;
#[pin_project(project_replace)]
struct DifferentCfg {
#[cfg(not(any()))]
#[cfg_attr(any(), pin)]
inner: Always,
#[cfg(any())]
#[cfg_attr(not(any()), pin)]
inner: Never,
}
assert_unpin!(DifferentCfg);
let mut x = DifferentCfg { inner: Always };
let x = Pin::new(&mut x).project();
let _: &mut Always = x.inner;
#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
#[cfg_attr(not(any()), pin)]
inner: T,
}
assert_unpin!(Foo<()>);
assert_not_unpin!(Foo<PhantomPinned>);
let mut x = Foo { inner: 0_u8 };
let x = Pin::new(&mut x).project();
let _: Pin<&mut u8> = x.inner;
}
#[test]
fn cfg_attr_any_packed() {
// Since `cfg(any())` can never be true, it is okay for this to pass.
#[pin_project(project_replace)]
#[cfg_attr(any(), repr(packed))]
struct Struct {
#[pin]
f: u32,
}
}

View File

@@ -0,0 +1,16 @@
#![cfg(not(miri))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::env;
#[rustversion::attr(not(nightly), ignore)]
#[test]
fn ui() {
if env::var_os("CI").is_none() {
env::set_var("TRYBUILD", "overwrite");
}
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/**/*.rs");
t.pass("tests/run-pass/**/*.rs");
}

View File

@@ -0,0 +1,162 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
// Refs: https://doc.rust-lang.org/reference/destructors.html
use std::{cell::Cell, pin::Pin, thread};
use pin_project::pin_project;
struct D<'a>(&'a Cell<usize>, usize);
impl Drop for D<'_> {
fn drop(&mut self) {
if !thread::panicking() {
let old = self.0.replace(self.1);
assert_eq!(old, self.1 - 1);
}
}
}
#[pin_project(project_replace)]
struct StructPinned<'a> {
#[pin]
f1: D<'a>,
#[pin]
f2: D<'a>,
}
#[pin_project(project_replace)]
struct StructUnpinned<'a> {
f1: D<'a>,
f2: D<'a>,
}
#[pin_project(project_replace)]
struct TuplePinned<'a>(#[pin] D<'a>, #[pin] D<'a>);
#[pin_project(project_replace)]
struct TupleUnpinned<'a>(D<'a>, D<'a>);
#[pin_project(project_replace = EnumProj)]
enum Enum<'a> {
#[allow(dead_code)] // false positive that fixed in Rust 1.38
StructPinned {
#[pin]
f1: D<'a>,
#[pin]
f2: D<'a>,
},
#[allow(dead_code)] // false positive that fixed in Rust 1.38
StructUnpinned {
f1: D<'a>,
f2: D<'a>,
},
TuplePinned(#[pin] D<'a>, #[pin] D<'a>),
TupleUnpinned(D<'a>, D<'a>),
}
#[test]
fn struct_pinned() {
{
let c = Cell::new(0);
let _x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn struct_unpinned() {
{
let c = Cell::new(0);
let _x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn tuple_pinned() {
{
let c = Cell::new(0);
let _x = TuplePinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = TuplePinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(TuplePinned(D(&c, 3), D(&c, 4)));
}
}
#[test]
fn tuple_unpinned() {
{
let c = Cell::new(0);
let _x = TupleUnpinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = TupleUnpinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(TupleUnpinned(D(&c, 3), D(&c, 4)));
}
}
#[test]
fn enum_struct() {
{
let c = Cell::new(0);
let _x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
}
{
let c = Cell::new(0);
let _x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn enum_tuple() {
{
let c = Cell::new(0);
let _x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::TuplePinned(D(&c, 3), D(&c, 4)));
}
{
let c = Cell::new(0);
let _x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::TupleUnpinned(D(&c, 3), D(&c, 4)));
}
}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,268 @@
use pin_project::pin_project;
#[pin(
__private(
project = EnumProj,
project_ref = EnumProjRef,
project_replace = EnumProjOwn
)
)]
enum Enum<T, U> {
Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U },
Tuple(#[pin] T, #[pin] T, U, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned1: &'pin mut (U),
unpinned2: &'pin mut (U),
},
Tuple(
::pin_project::__private::Pin<&'pin mut (T)>,
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
&'pin mut (U),
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned1: ::pin_project::__private::Pin<&'pin (T)>,
pinned2: ::pin_project::__private::Pin<&'pin (T)>,
unpinned1: &'pin (U),
unpinned2: &'pin (U),
},
Tuple(
::pin_project::__private::Pin<&'pin (T)>,
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
&'pin (U),
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum EnumProjOwn<T, U> {
Struct {
pinned1: ::pin_project::__private::PhantomData<T>,
pinned2: ::pin_project::__private::PhantomData<T>,
unpinned1: U,
unpinned2: U,
},
Tuple(
::pin_project::__private::PhantomData<T>,
::pin_project::__private::PhantomData<T>,
U,
U,
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
EnumProj::Struct {
pinned1: _pin_project::__private::Pin::new_unchecked(
pinned1,
),
pinned2: _pin_project::__private::Pin::new_unchecked(
pinned2,
),
unpinned1,
unpinned2,
}
}
Self::Tuple(_0, _1, _2, _3) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
EnumProjRef::Struct {
pinned1: _pin_project::__private::Pin::new_unchecked(
pinned1,
),
pinned2: _pin_project::__private::Pin::new_unchecked(
pinned2,
),
unpinned1,
unpinned2,
}
}
Self::Tuple(_0, _1, _2, _3) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> EnumProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
let __result = EnumProjOwn::Struct {
pinned1: _pin_project::__private::PhantomData,
pinned2: _pin_project::__private::PhantomData,
unpinned1: _pin_project::__private::ptr::read(unpinned1),
unpinned2: _pin_project::__private::ptr::read(unpinned2),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned2,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned1,
);
}
__result
}
Self::Tuple(_0, _1, _2, _3) => {
let __result = EnumProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_2),
_pin_project::__private::ptr::read(_3),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_1,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = EnumProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
__field2: T,
__field3: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,17 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
},
Tuple(#[pin] T, #[pin] T, U, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,155 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct Struct<T, U> {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned1: &'pin mut (U),
unpinned2: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned1: ::pin_project::__private::Pin<&'pin (T)>,
pinned2: ::pin_project::__private::Pin<&'pin (T)>,
unpinned1: &'pin (U),
unpinned2: &'pin (U),
}
#[allow(dead_code)]
struct __StructProjectionOwned<T, U> {
pinned1: ::pin_project::__private::PhantomData<T>,
pinned2: ::pin_project::__private::PhantomData<T>,
unpinned1: U,
unpinned2: U,
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned1, pinned2, unpinned1, unpinned2 } = self
.get_unchecked_mut();
__StructProjection {
pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
unpinned1,
unpinned2,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned1, pinned2, unpinned1, unpinned2 } = self.get_ref();
__StructProjectionRef {
pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
unpinned1,
unpinned2,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __StructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned1, pinned2, unpinned1, unpinned2 } = &mut *__self_ptr;
let __result = __StructProjectionOwned {
pinned1: _pin_project::__private::PhantomData,
pinned2: _pin_project::__private::PhantomData,
unpinned1: _pin_project::__private::ptr::read(unpinned1),
unpinned2: _pin_project::__private::ptr::read(unpinned2),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned2,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned1,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned1;
let _ = &this.pinned2;
let _ = &this.unpinned1;
let _ = &this.unpinned2;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,13 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
}
fn main() {}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
struct __TupleStructProjectionOwned<T, U>(
::pin_project::__private::PhantomData<T>,
::pin_project::__private::PhantomData<T>,
U,
U,
);
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1, _2, _3) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1, _2, _3) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __TupleStructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1, _2, _3) = &mut *__self_ptr;
let __result = __TupleStructProjectionOwned(
_pin_project::__private::PhantomData,
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_2),
_pin_project::__private::ptr::read(_3),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_1,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
let _ = &this.2;
let _ = &this.3;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
fn main() {}

View File

@@ -0,0 +1,204 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum ProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
Proj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
Self::Unit => Proj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
ProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
ProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => ProjRef::Unit,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = ProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = ProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = ProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,99 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
Proj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
Self::Unit => Proj::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,56 @@
use pin_project::pin_project;
#[pin(__private())]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,119 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum ProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = ProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = ProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = ProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,100 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
ProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
ProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => ProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,163 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
Proj {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
ProjRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = ProjOwn {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,114 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
Proj {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,143 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = ProjOwn {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,114 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
ProjRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,148 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = ProjOwn(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,105 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,134 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = ProjOwn(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,105 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,139 @@
use pin_project::pin_project;
#[pin(__private(!Unpin, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(!Unpin, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,99 @@
use pin_project::pin_project;
#[pin(__private(!Unpin))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(!Unpin)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,93 @@
use pin_project::pin_project;
#[pin(__private(!Unpin))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(!Unpin)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,157 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for Enum<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut Enum<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,23 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[pinned_drop]
impl<T, U> PinnedDrop for Enum<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,116 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for Struct<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut Struct<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,19 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[pinned_drop]
impl<T, U> PinnedDrop for Struct<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,110 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for TupleStruct<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut TupleStruct<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,15 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct TupleStruct<T, U>(#[pin] T, U);
#[pinned_drop]
impl<T, U> PinnedDrop for TupleStruct<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,119 @@
use pin_project::pin_project;
#[pin(__private(project_replace = EnumProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum EnumProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> EnumProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = EnumProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = EnumProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = EnumProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_replace = EnumProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,133 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(dead_code)]
struct __StructProjectionOwned<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __StructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = __StructProjectionOwned {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,127 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
struct __TupleStructProjectionOwned<T, U>(
::pin_project::__private::PhantomData<T>,
U,
);
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __TupleStructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = __TupleStructProjectionOwned(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
pub enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
pub struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
pub enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
pub struct Struct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pub pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
pub unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pub pinned: ::pin_project::__private::Pin<&'pin (T)>,
pub unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
pub struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
pub struct Struct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) struct __TupleStructProjection<'pin, T, U>(
pub ::pin_project::__private::Pin<&'pin mut (T)>,
pub &'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) struct __TupleStructProjectionRef<'pin, T, U>(
pub ::pin_project::__private::Pin<&'pin (T)>,
pub &'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
pub struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
fn main() {}

View File

@@ -0,0 +1,129 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
fn main() {}

View File

@@ -0,0 +1,16 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
fn main() {}

View File

@@ -0,0 +1,89 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,12 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,83 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,8 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin)]
struct TupleStruct<T, U>(#[pin] T, U);
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,43 @@
#![cfg(not(miri))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::{
env,
process::{Command, ExitStatus, Stdio},
};
const PATH: &str = "tests/expand/**/*.rs";
#[rustversion::attr(not(nightly), ignore)]
#[test]
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"]) {
if is_ci {
panic!("expandtest requires cargo-expand");
}
return;
}
let args = &["--all-features"];
if is_ci {
macrotest::expand_without_refresh_args(PATH, args);
} else {
env::set_var("MACROTEST", "overwrite");
macrotest::expand_args(PATH, args);
}
}
fn has_command(command: &[&str]) -> bool {
Command::new(command[0])
.args(&command[1..])
.arg("--version")
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.as_ref()
.map(ExitStatus::success)
.unwrap_or(false)
}

View File

@@ -0,0 +1,193 @@
// default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.
#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(
project = DefaultStructNamedProj,
project_ref = DefaultStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultStructNamed<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = DefaultTupleStructNamedProj,
project_ref = DefaultTupleStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = DefaultEnumProj,
project_ref = DefaultEnumProjRef,
)]
#[derive(Debug)]
pub enum DefaultEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(
PinnedDrop,
project = PinnedDropEnumProj,
project_ref = PinnedDropEnumProjRef,
)]
#[derive(Debug)]
pub enum PinnedDropEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(
project = ReplaceStructNamedProj,
project_ref = ReplaceStructNamedProjRef,
project_replace = ReplaceStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceStructNamed<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = ReplaceTupleStructNamedProj,
project_ref = ReplaceTupleStructNamedProjRef,
project_replace = ReplaceTupleStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = ReplaceEnumProj,
project_ref = ReplaceEnumProjRef,
project_replace = ReplaceEnumProjOwn,
)]
#[derive(Debug)]
pub enum ReplaceEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
UnsafeUnpin,
project = UnsafeUnpinEnumProj,
project_ref = UnsafeUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum UnsafeUnpinEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
!Unpin,
project = NotUnpinEnumProj,
project_ref = NotUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum NotUnpinEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}

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