From 926348bf52270896ffe3aefa3021ddba5f0aa0c1 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Tue, 13 Dec 2022 10:48:04 +0100 Subject: Upgrade pin-project to 1.0.12 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/pin-project For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: I970f12737ae466548757b47ad4582afce563a778 --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- CHANGELOG.md | 93 +++++---- Cargo.lock.saved | 222 +++++++++++++++++++++ Cargo.toml | 31 ++- Cargo.toml.orig | 9 +- METADATA | 12 +- README.md | 13 +- examples/README.md | 4 +- src/lib.rs | 22 +- tests/compiletest.rs | 1 + tests/expand/default/enum.expanded.rs | 64 +++--- tests/expand/default/struct.expanded.rs | 19 +- tests/expand/default/tuple_struct.expanded.rs | 29 ++- tests/expand/multifields/enum.expanded.rs | 145 ++++++++------ tests/expand/multifields/struct.expanded.rs | 56 +++--- tests/expand/multifields/tuple_struct.expanded.rs | 34 ++-- tests/expand/naming/enum-all.expanded.rs | 85 ++++---- tests/expand/naming/enum-mut.expanded.rs | 41 ++-- tests/expand/naming/enum-none.expanded.rs | 23 +-- tests/expand/naming/enum-own.expanded.rs | 47 ++--- tests/expand/naming/enum-ref.expanded.rs | 47 ++--- tests/expand/naming/struct-all.expanded.rs | 39 ++-- tests/expand/naming/struct-mut.expanded.rs | 26 ++- tests/expand/naming/struct-none.expanded.rs | 19 +- tests/expand/naming/struct-own.expanded.rs | 33 +-- tests/expand/naming/struct-ref.expanded.rs | 22 +- tests/expand/naming/tuple_struct-all.expanded.rs | 49 +++-- tests/expand/naming/tuple_struct-mut.expanded.rs | 36 ++-- tests/expand/naming/tuple_struct-none.expanded.rs | 29 ++- tests/expand/naming/tuple_struct-own.expanded.rs | 43 ++-- tests/expand/naming/tuple_struct-ref.expanded.rs | 32 ++- tests/expand/not_unpin/enum.expanded.rs | 72 ++++--- tests/expand/not_unpin/struct.expanded.rs | 29 ++- tests/expand/not_unpin/tuple_struct.expanded.rs | 39 ++-- tests/expand/pinned_drop/enum.expanded.rs | 64 +++--- tests/expand/pinned_drop/struct.expanded.rs | 19 +- tests/expand/pinned_drop/tuple_struct.expanded.rs | 29 ++- tests/expand/project_replace/enum.expanded.rs | 47 ++--- tests/expand/project_replace/struct.expanded.rs | 30 ++- .../project_replace/tuple_struct.expanded.rs | 45 +++-- tests/expand/pub/enum.expanded.rs | 64 +++--- tests/expand/pub/struct.expanded.rs | 19 +- tests/expand/pub/tuple_struct.expanded.rs | 29 ++- tests/expand/unsafe_unpin/enum.expanded.rs | 56 +++--- tests/expand/unsafe_unpin/struct.expanded.rs | 11 +- tests/expand/unsafe_unpin/tuple_struct.expanded.rs | 21 +- tests/expandtest.rs | 4 +- tests/include/basic.rs | 3 + tests/lint.rs | 41 ++-- tests/ui/not_unpin/conflict-unpin.stderr | 2 +- tests/ui/not_unpin/impl-unsafe-unpin.stderr | 2 +- tests/ui/pin_project/conflict-unpin.stderr | 2 +- tests/ui/pin_project/impl-unsafe-unpin.stderr | 2 +- tests/ui/pin_project/packed_sneaky-1.rs | 9 +- tests/ui/pin_project/packed_sneaky-1.stderr | 16 +- tests/ui/pin_project/packed_sneaky-4.rs | 15 ++ tests/ui/pin_project/packed_sneaky-4.stderr | 16 ++ .../ui/pin_project/project_replace_unsized.stderr | 34 ++-- .../project_replace_unsized_fn_params.stderr | 34 ++-- tests/ui/pin_project/unpin_sneaky.stderr | 6 - tests/ui/pinned_drop/call-drop-inner.stderr | 8 +- tests/ui/pinned_drop/conditional-drop-impl.stderr | 6 +- tests/ui/pinned_drop/self.stderr | 2 +- tests/ui/unsafe_unpin/conflict-unpin.stderr | 2 +- tests/ui/unstable-features/negative_impls.rs | 23 +++ tests/ui/unstable-features/negative_impls.stderr | 19 ++ 67 files changed, 1388 insertions(+), 761 deletions(-) create mode 100644 Cargo.lock.saved create mode 100644 tests/ui/pin_project/packed_sneaky-4.rs create mode 100644 tests/ui/pin_project/packed_sneaky-4.stderr create mode 100644 tests/ui/unstable-features/negative_impls.rs create mode 100644 tests/ui/unstable-features/negative_impls.stderr diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 9e9e67a..401be20 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "0273e6ecd64057f47c3b2ada6fb4e5c37357c185" + "sha1": "d1c11dc50f88330cfb05ac55aaa06c28877eb1d6" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/Android.bp b/Android.bp index 3ebadd0..ac3d414 100644 --- a/Android.bp +++ b/Android.bp @@ -42,7 +42,7 @@ rust_library { host_supported: true, crate_name: "pin_project", cargo_env_compat: true, - cargo_pkg_version: "1.0.10", + cargo_pkg_version: "1.0.12", srcs: ["src/lib.rs"], edition: "2018", proc_macros: ["libpin_project_internal"], diff --git a/CHANGELOG.md b/CHANGELOG.md index ebac043..76e245f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,19 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org). ## [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. @@ -50,13 +58,13 @@ NOTE: In this file, do not use the hard wrap in the middle of a sentence for com ## [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). +**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). +**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) @@ -128,62 +136,66 @@ Changes since the 1.0.0-alpha.1 release: 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). +**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.) + (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). +**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). +**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). +**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.) + (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). +**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. + 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). +**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). +**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). +**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) @@ -214,7 +226,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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. @@ -242,13 +254,13 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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). +**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) @@ -260,7 +272,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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) @@ -283,19 +295,19 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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). +**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). +**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) @@ -317,7 +329,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project } ``` - *[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)* + *[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) @@ -331,7 +343,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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) @@ -349,13 +361,13 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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. +**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) @@ -369,7 +381,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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. @@ -381,7 +393,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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) @@ -391,7 +403,7 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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) @@ -399,31 +411,31 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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). +**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). +**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). +**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). +**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. +**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) @@ -435,19 +447,19 @@ See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project ## [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. +**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. +**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. +**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. @@ -590,7 +602,7 @@ See also [tracking issue for 0.4 release](https://github.com/taiki-e/pin-project ## [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. +**Note:** This release has been yanked. See [#16](https://github.com/taiki-e/pin-project/issues/16) for details. - Diagnostic improvements. @@ -664,11 +676,13 @@ See also [tracking issue for 0.4 release](https://github.com/taiki-e/pin-project ## [0.1.0] - 2019-01-08 -**NOTE:** This release has been yanked. +**Note:** This release has been yanked. Initial release -[Unreleased]: https://github.com/taiki-e/pin-project/compare/v1.0.10...HEAD +[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 @@ -681,6 +695,7 @@ Initial release [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 diff --git a/Cargo.lock.saved b/Cargo.lock.saved new file mode 100644 index 0000000..502ac21 --- /dev/null +++ b/Cargo.lock.saved @@ -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" diff --git a/Cargo.toml b/Cargo.toml index cc234e1..9ad85ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,19 +13,36 @@ edition = "2018" rust-version = "1.37" name = "pin-project" -version = "1.0.10" -exclude = ["/.*", "/ci", "/tools"] -description = "A crate for safe and ergonomic pin-projection.\n" -keywords = ["pin", "macros", "attribute"] -categories = ["no-std", "rust-patterns"] +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.10" +version = "=1.0.12" + [dev-dependencies.macrotest] -version = "1.0.8" +version = "1.0.9" [dev-dependencies.rustversion] version = "1" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 120858b..6ddfa42 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "pin-project" -version = "1.0.10" +version = "1.0.12" edition = "2018" rust-version = "1.37" license = "Apache-2.0 OR MIT" @@ -26,11 +26,14 @@ members = [ ] [dependencies] -pin-project-internal = { version = "=1.0.10", path = "pin-project-internal" } +pin-project-internal = { version = "=1.0.12", path = "pin-project-internal" } [dev-dependencies] pin-project-auxiliary-macro = { path = "tests/auxiliary/macro" } -macrotest = "1.0.8" +macrotest = "1.0.9" rustversion = "1" static_assertions = "1" trybuild = "1.0.49" + +[patch.crates-io] +prettyplease = { git = "https://github.com/taiki-e/prettyplease.git", branch = "dev" } # lower MSRV diff --git a/METADATA b/METADATA index 5087552..5db590f 100644 --- a/METADATA +++ b/METADATA @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/pin-project +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "pin-project" description: "A crate for safe and ergonomic pin-projection." third_party { @@ -7,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/pin-project/pin-project-1.0.10.crate" + value: "https://static.crates.io/crates/pin-project/pin-project-1.0.12.crate" } - version: "1.0.10" + version: "1.0.12" license_type: NOTICE last_upgrade_date { year: 2022 - month: 3 - day: 1 + month: 12 + day: 13 } } diff --git a/README.md b/README.md index 0e21654..0a30654 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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)](https://docs.rs/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) @@ -78,17 +78,16 @@ impl Enum { See [documentation](https://docs.rs/pin-project) for more details, and see [examples] directory for more examples and generated code. -[`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-projection]: https://doc.rust-lang.org/std/pin/index.html#projections-and-structural-pinning -[struct-default-expanded]: examples/struct-default-expanded.rs - ## 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 diff --git a/examples/README.md b/examples/README.md index 9324dc6..0f30a7f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -26,7 +26,7 @@ - [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) +- [`project_replace()` documentation](https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#project_replace-method) ### Ensure `!Unpin` by `#[pin_project(!Unpin)]` @@ -35,5 +35,5 @@ - [`!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/expand/README.md) if you +actual generated code. See [expansion tests](../tests#expansion-tests-expand-expandtestrs) if you want to see the exact version of the actual generated code. diff --git a/src/lib.rs b/src/lib.rs index 00bc931..ca47cea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,7 +75,20 @@ ) ))] #![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)] -#![warn(clippy::default_trait_access, clippy::wildcard_imports)] +#![warn( + clippy::pedantic, + // lints for public library + clippy::alloc_instead_of_core, + clippy::exhaustive_enums, + clippy::exhaustive_structs, + clippy::std_instead_of_alloc, + clippy::std_instead_of_core, + // lints that help writing unsafe code + clippy::default_union_representation, + clippy::trailing_empty_array, + clippy::transmute_undefined_repr, + clippy::undocumented_unsafe_blocks, +)] #![allow(clippy::needless_doctest_main)] // ANDROID: Use std to allow building as a dylib. @@ -246,7 +259,8 @@ pub mod __private { #[doc(hidden)] pub struct Wrapper<'a, T: ?Sized>(PhantomData<&'a ()>, T); - unsafe impl UnsafeUnpin for Wrapper<'_, T> where T: UnsafeUnpin {} + // SAFETY: `T` implements UnsafeUnpin. + unsafe impl UnsafeUnpin for Wrapper<'_, T> {} // This is an internal helper struct used by `pin-project-internal`. // @@ -269,6 +283,8 @@ pub mod __private { impl Drop for UnsafeDropInPlaceGuard { 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); } @@ -292,6 +308,8 @@ pub mod __private { impl Drop for UnsafeOverwriteGuard { fn drop(&mut self) { + // SAFETY: the caller of `UnsafeOverwriteGuard::new` must guarantee + // that `target` is valid for writes when this guard is destructed. unsafe { ptr::write(self.target, ptr::read(&*self.value)); } diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 70d2358..b06e1e8 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -12,4 +12,5 @@ fn ui() { let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/**/*.rs"); + t.pass("tests/run-pass/**/*.rs"); } diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs index a3b0338..490bf2e 100644 --- a/tests/expand/default/enum.expanded.rs +++ b/tests/expand/default/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(project = EnumProj, project_ref = EnumProjRef))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,34 +66,46 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -116,15 +124,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs index 3089a54..0005d86 100644 --- a/tests/expand/default/struct.expanded.rs +++ b/tests/expand/default/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -40,6 +41,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/default/tuple_struct.expanded.rs b/tests/expand/default/tuple_struct.expanded.rs index cc9b75e..1c5e3b0 100644 --- a/tests/expand/default/tuple_struct.expanded.rs +++ b/tests/expand/default/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs index fd31201..8223de3 100644 --- a/tests/expand/multifields/enum.expanded.rs +++ b/tests/expand/multifields/enum.expanded.rs @@ -1,14 +1,13 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef , project_replace = EnumProjOwn))] +#[pin( + __private( + project = EnumProj, + project_ref = EnumProjRef, + project_replace = EnumProjOwn + ) +)] enum Enum { - Struct { - #[pin] - pinned1: T, - #[pin] - pinned2: T, - unpinned1: U, - unpinned2: U, - }, + Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U }, Tuple(#[pin] T, #[pin] T, U, U), Unit, } @@ -17,6 +16,7 @@ enum Enum { #[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)] @@ -46,6 +46,7 @@ where #[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)] @@ -75,6 +76,7 @@ where #[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)] @@ -102,6 +104,7 @@ enum EnumProjOwn { #[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)] @@ -114,74 +117,80 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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::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 { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { - Self::Struct { - pinned1, - pinned2, - unpinned1, - unpinned2, - } => { + Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => { let __result = EnumProjOwn::Struct { pinned1: _pin_project::__private::PhantomData, pinned2: _pin_project::__private::PhantomData, @@ -189,10 +198,12 @@ const _: () = { unpinned2: _pin_project::__private::ptr::read(unpinned2), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned2); - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned1); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); } __result } @@ -204,8 +215,12 @@ const _: () = { _pin_project::__private::ptr::read(_3), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_1); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -232,15 +247,15 @@ const _: () = { __field2: T, __field3: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 7ed1f3e..df8dc92 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -13,6 +13,7 @@ struct Struct { #[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)] @@ -54,16 +55,13 @@ const _: () = { unpinned2: U, } impl Struct { + #[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(); + 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), @@ -72,17 +70,13 @@ const _: () = { } } } + #[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(); + 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), @@ -91,20 +85,18 @@ const _: () = { } } } + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> __StructProjectionOwned { 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 __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, @@ -112,8 +104,12 @@ const _: () = { unpinned2: _pin_project::__private::ptr::read(unpinned2), }; { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned2); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned1); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned2, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned1, + ); } __result } @@ -138,15 +134,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/multifields/tuple_struct.expanded.rs b/tests/expand/multifields/tuple_struct.expanded.rs index 351c084..0c85f9a 100644 --- a/tests/expand/multifields/tuple_struct.expanded.rs +++ b/tests/expand/multifields/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct(#[pin] T, #[pin] T, U, U); #[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)] @@ -45,6 +46,7 @@ const _: () = { U, ); impl TupleStruct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __TupleStructProjection<'pin, T, U> { @@ -58,6 +60,7 @@ const _: () = { ) } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -72,14 +75,17 @@ const _: () = { ) } } + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> __TupleStructProjectionOwned { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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, @@ -88,8 +94,12 @@ const _: () = { _pin_project::__private::ptr::read(_3), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_1); - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _1, + ); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -114,15 +124,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs index 7259a13..8dbe768 100644 --- a/tests/expand/naming/enum-all.expanded.rs +++ b/tests/expand/naming/enum-all.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum ProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -66,10 +62,7 @@ where #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum ProjOwn { - Struct { - pinned: ::pin_project::__private::PhantomData, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData, unpinned: U }, Tuple(::pin_project::__private::PhantomData, U), Unit, } @@ -78,6 +71,7 @@ enum ProjOwn { #[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)] @@ -90,13 +84,18 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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::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) } @@ -104,31 +103,40 @@ const _: () = { } } } + #[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::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) + 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 { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = ProjOwn::Struct { @@ -136,8 +144,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -147,7 +156,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -172,15 +183,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/naming/enum-mut.expanded.rs b/tests/expand/naming/enum-mut.expanded.rs index 09271fd..c6916ec 100644 --- a/tests/expand/naming/enum-mut.expanded.rs +++ b/tests/expand/naming/enum-mut.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[pin(__private(project = Proj))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -48,13 +46,18 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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::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) } @@ -75,15 +78,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/naming/enum-none.expanded.rs b/tests/expand/naming/enum-none.expanded.rs index 54cd1f8..46477d1 100644 --- a/tests/expand/naming/enum-none.expanded.rs +++ b/tests/expand/naming/enum-none.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; #[pin(__private())] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -38,15 +35,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/naming/enum-own.expanded.rs b/tests/expand/naming/enum-own.expanded.rs index 19ec570..ddeb00c 100644 --- a/tests/expand/naming/enum-own.expanded.rs +++ b/tests/expand/naming/enum-own.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[pin(__private(project_replace = ProjOwn))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -22,10 +19,7 @@ enum Enum { #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum ProjOwn { - Struct { - pinned: ::pin_project::__private::PhantomData, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData, unpinned: U }, Tuple(::pin_project::__private::PhantomData, U), Unit, } @@ -34,6 +28,7 @@ enum ProjOwn { #[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)] @@ -46,14 +41,17 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> ProjOwn { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = ProjOwn::Struct { @@ -61,8 +59,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -72,7 +71,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -97,15 +98,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/naming/enum-ref.expanded.rs b/tests/expand/naming/enum-ref.expanded.rs index 4565d08..1a49584 100644 --- a/tests/expand/naming/enum-ref.expanded.rs +++ b/tests/expand/naming/enum-ref.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[pin(__private(project_ref = ProjRef))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -24,10 +21,7 @@ enum ProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -36,6 +30,7 @@ where #[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)] @@ -48,18 +43,24 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + ProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => ProjRef::Unit, } @@ -78,15 +79,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index 4b46e34..e598a4f 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] struct Struct { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -46,6 +48,7 @@ where #[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)] @@ -60,6 +63,7 @@ struct ProjOwn { #[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)] @@ -72,7 +76,10 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Struct { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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 { @@ -81,6 +88,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -93,21 +101,26 @@ const _: () = { } } } + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> ProjOwn { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -129,15 +142,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs index 5803d6b..88782ee 100644 --- a/tests/expand/naming/struct-mut.expanded.rs +++ b/tests/expand/naming/struct-mut.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[pin(__private(project = Proj))] struct Struct { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -49,7 +51,10 @@ const _: () = { unpinned: &'pin (U), } impl Struct { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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 { @@ -58,6 +63,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -87,15 +93,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs index 3089a54..0005d86 100644 --- a/tests/expand/naming/struct-none.expanded.rs +++ b/tests/expand/naming/struct-none.expanded.rs @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -40,6 +41,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/naming/struct-own.expanded.rs b/tests/expand/naming/struct-own.expanded.rs index d05c7d6..cc24862 100644 --- a/tests/expand/naming/struct-own.expanded.rs +++ b/tests/expand/naming/struct-own.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[pin(__private(project_replace = ProjOwn))] struct Struct { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -24,6 +25,7 @@ struct ProjOwn { #[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)] @@ -54,6 +56,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -65,6 +68,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -77,21 +81,26 @@ const _: () = { } } } + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> ProjOwn { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -113,15 +122,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs index c131ec4..e392f6f 100644 --- a/tests/expand/naming/struct-ref.expanded.rs +++ b/tests/expand/naming/struct-ref.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[pin(__private(project_ref = ProjRef))] struct Struct { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -28,6 +29,7 @@ where #[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)] @@ -49,6 +51,7 @@ const _: () = { unpinned: &'pin mut (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -60,6 +63,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -89,15 +93,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/naming/tuple_struct-all.expanded.rs b/tests/expand/naming/tuple_struct-all.expanded.rs index 042a798..8c148ed 100644 --- a/tests/expand/naming/tuple_struct-all.expanded.rs +++ b/tests/expand/naming/tuple_struct-all.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project = Proj , project_ref = ProjRef , project_replace = ProjOwn))] +#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))] struct TupleStruct(#[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)) +struct Proj<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), +) where TupleStruct: 'pin; #[allow(box_pointers)] @@ -20,13 +24,17 @@ where #[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)) +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) where TupleStruct: 'pin; #[allow(box_pointers)] @@ -34,6 +42,7 @@ where #[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)] @@ -45,6 +54,7 @@ struct ProjOwn(::pin_project::__private::PhantomData, U); #[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)] @@ -57,12 +67,16 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl TupleStruct { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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>, @@ -72,21 +86,26 @@ const _: () = { 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 { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -108,15 +127,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/naming/tuple_struct-mut.expanded.rs b/tests/expand/naming/tuple_struct-mut.expanded.rs index 60218d6..79c7901 100644 --- a/tests/expand/naming/tuple_struct-mut.expanded.rs +++ b/tests/expand/naming/tuple_struct-mut.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project = Proj))] +#[pin(__private(project = Proj))] struct TupleStruct(#[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)) +struct Proj<'pin, T, U>( + ::pin_project::__private::Pin<&'pin mut (T)>, + &'pin mut (U), +) where TupleStruct: 'pin; #[allow(box_pointers)] @@ -20,6 +24,7 @@ where #[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)] @@ -40,19 +45,26 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { - fn project<'pin>(self: _pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, 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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -72,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/naming/tuple_struct-none.expanded.rs b/tests/expand/naming/tuple_struct-none.expanded.rs index cc9b75e..1c5e3b0 100644 --- a/tests/expand/naming/tuple_struct-none.expanded.rs +++ b/tests/expand/naming/tuple_struct-none.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/naming/tuple_struct-own.expanded.rs b/tests/expand/naming/tuple_struct-own.expanded.rs index 21e12de..37e4c34 100644 --- a/tests/expand/naming/tuple_struct-own.expanded.rs +++ b/tests/expand/naming/tuple_struct-own.expanded.rs @@ -1,11 +1,12 @@ use pin_project::pin_project; -# [pin (__private (project_replace = ProjOwn))] +#[pin(__private(project_replace = ProjOwn))] struct TupleStruct(#[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)] @@ -17,6 +18,7 @@ struct ProjOwn(::pin_project::__private::PhantomData, U); #[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)] @@ -45,38 +47,51 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __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 { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -98,15 +113,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/naming/tuple_struct-ref.expanded.rs b/tests/expand/naming/tuple_struct-ref.expanded.rs index ea11b6a..8c86868 100644 --- a/tests/expand/naming/tuple_struct-ref.expanded.rs +++ b/tests/expand/naming/tuple_struct-ref.expanded.rs @@ -1,18 +1,22 @@ use pin_project::pin_project; -# [pin (__private (project_ref = ProjRef))] +#[pin(__private(project_ref = ProjRef))] struct TupleStruct(#[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)) +struct ProjRef<'pin, T, U>( + ::pin_project::__private::Pin<&'pin (T)>, + &'pin (U), +) where TupleStruct: 'pin; #[allow(box_pointers)] @@ -20,6 +24,7 @@ where #[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)] @@ -40,14 +45,19 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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>, @@ -74,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/not_unpin/enum.expanded.rs b/tests/expand/not_unpin/enum.expanded.rs index 5173b54..98e7bbe 100644 --- a/tests/expand/not_unpin/enum.expanded.rs +++ b/tests/expand/not_unpin/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (! Unpin , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(!Unpin, project = EnumProj, project_ref = EnumProjRef))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,51 +66,67 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } } } } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + 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 where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/not_unpin/struct.expanded.rs b/tests/expand/not_unpin/struct.expanded.rs index e9d8922..420f21a 100644 --- a/tests/expand/not_unpin/struct.expanded.rs +++ b/tests/expand/not_unpin/struct.expanded.rs @@ -1,5 +1,5 @@ use pin_project::pin_project; -# [pin (__private (! Unpin))] +#[pin(__private(!Unpin))] struct Struct { #[pin] pinned: T, @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -40,6 +41,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -69,17 +72,21 @@ const _: () = { let _ = &this.pinned; let _ = &this.unpinned; } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + 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 where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/not_unpin/tuple_struct.expanded.rs b/tests/expand/not_unpin/tuple_struct.expanded.rs index cefb61d..99621f4 100644 --- a/tests/expand/not_unpin/tuple_struct.expanded.rs +++ b/tests/expand/not_unpin/tuple_struct.expanded.rs @@ -1,11 +1,12 @@ use pin_project::pin_project; -# [pin (__private (! Unpin))] +#[pin(__private(!Unpin))] struct TupleStruct(#[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)] @@ -34,21 +35,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -57,17 +66,21 @@ const _: () = { let _ = &this.0; let _ = &this.1; } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + 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 where - _pin_project::__private::Wrapper<'pin, _pin_project::__private::PhantomPinned>: - _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + _pin_project::__private::Wrapper< + 'pin, + _pin_project::__private::PhantomPinned, + >: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs index e1bc486..1a8e746 100644 --- a/tests/expand/pinned_drop/enum.expanded.rs +++ b/tests/expand/pinned_drop/enum.expanded.rs @@ -1,12 +1,8 @@ use std::pin::Pin; use pin_project::{pin_project, pinned_drop}; -# [pin (__private (PinnedDrop , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(PinnedDrop, project = EnumProj, project_ref = EnumProjRef))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -15,6 +11,7 @@ enum Enum { #[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)] @@ -37,6 +34,7 @@ where #[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)] @@ -47,10 +45,7 @@ enum EnumProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -59,6 +54,7 @@ where #[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)] @@ -71,34 +67,46 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -117,15 +125,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} impl _pin_project::__private::Drop for Enum { fn drop(&mut self) { unsafe { diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs index 2227442..d21440d 100644 --- a/tests/expand/pinned_drop/struct.expanded.rs +++ b/tests/expand/pinned_drop/struct.expanded.rs @@ -11,6 +11,7 @@ struct Struct { #[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)] @@ -41,6 +42,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -52,6 +54,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -81,15 +84,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} impl _pin_project::__private::Drop for Struct { fn drop(&mut self) { unsafe { diff --git a/tests/expand/pinned_drop/tuple_struct.expanded.rs b/tests/expand/pinned_drop/tuple_struct.expanded.rs index 8c7433e..9a614ae 100644 --- a/tests/expand/pinned_drop/tuple_struct.expanded.rs +++ b/tests/expand/pinned_drop/tuple_struct.expanded.rs @@ -7,6 +7,7 @@ struct TupleStruct(#[pin] T, U); #[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)] @@ -35,21 +36,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -69,15 +78,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} impl _pin_project::__private::Drop for TupleStruct { fn drop(&mut self) { unsafe { diff --git a/tests/expand/project_replace/enum.expanded.rs b/tests/expand/project_replace/enum.expanded.rs index d2b2094..178cb99 100644 --- a/tests/expand/project_replace/enum.expanded.rs +++ b/tests/expand/project_replace/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project_replace = EnumProjOwn))] +#[pin(__private(project_replace = EnumProjOwn))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -22,10 +19,7 @@ enum Enum { #[allow(variant_size_differences)] #[allow(clippy::large_enum_variant)] enum EnumProjOwn { - Struct { - pinned: ::pin_project::__private::PhantomData, - unpinned: U, - }, + Struct { pinned: ::pin_project::__private::PhantomData, unpinned: U }, Tuple(::pin_project::__private::PhantomData, U), Unit, } @@ -34,6 +28,7 @@ enum EnumProjOwn { #[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)] @@ -46,14 +41,17 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> EnumProjOwn { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + let __guard = _pin_project::__private::UnsafeOverwriteGuard::new( + __self_ptr, + __replacement, + ); match &mut *__self_ptr { Self::Struct { pinned, unpinned } => { let __result = EnumProjOwn::Struct { @@ -61,8 +59,9 @@ const _: () = { unpinned: _pin_project::__private::ptr::read(unpinned), }; { - let __guard = - _pin_project::__private::UnsafeDropInPlaceGuard::new(pinned); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -72,7 +71,9 @@ const _: () = { _pin_project::__private::ptr::read(_1), ); { - let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(_0); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -97,15 +98,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/project_replace/struct.expanded.rs b/tests/expand/project_replace/struct.expanded.rs index aa5fd54..45839a2 100644 --- a/tests/expand/project_replace/struct.expanded.rs +++ b/tests/expand/project_replace/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -45,6 +46,7 @@ const _: () = { unpinned: U, } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -56,6 +58,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -68,21 +71,26 @@ const _: () = { } } } + #[allow(dead_code)] fn project_replace( self: _pin_project::__private::Pin<&mut Self>, __replacement: Self, ) -> __StructProjectionOwned { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + pinned, + ); } __result } @@ -104,15 +112,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/project_replace/tuple_struct.expanded.rs b/tests/expand/project_replace/tuple_struct.expanded.rs index 529f0b2..cdee3d1 100644 --- a/tests/expand/project_replace/tuple_struct.expanded.rs +++ b/tests/expand/project_replace/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct(#[pin] T, U); #[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)] @@ -34,40 +35,56 @@ const _: () = { where TupleStruct: 'pin; #[allow(dead_code)] - struct __TupleStructProjectionOwned(::pin_project::__private::PhantomData, U); + struct __TupleStructProjectionOwned( + ::pin_project::__private::PhantomData, + U, + ); impl TupleStruct { + #[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) + __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) + __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 { unsafe { let __self_ptr: *mut Self = self.get_unchecked_mut(); - let __guard = - _pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement); + 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); + let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new( + _0, + ); } __result } @@ -89,15 +106,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/pub/enum.expanded.rs b/tests/expand/pub/enum.expanded.rs index 530eca9..90be268 100644 --- a/tests/expand/pub/enum.expanded.rs +++ b/tests/expand/pub/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::pin_project; -# [pin (__private (project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(project = EnumProj, project_ref = EnumProjRef))] pub enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ pub enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ pub(crate) enum EnumProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,34 +66,46 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } @@ -116,15 +124,15 @@ const _: () = { __field0: T, __field1: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum where - __Enum<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum + where + __Enum<'pin, T, U>: _pin_project::__private::Unpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs index 71ae3a3..ca31f3d 100644 --- a/tests/expand/pub/struct.expanded.rs +++ b/tests/expand/pub/struct.expanded.rs @@ -10,6 +10,7 @@ pub struct Struct { #[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)] @@ -40,6 +41,7 @@ const _: () = { pub unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] pub(crate) fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] pub(crate) fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -80,15 +83,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct where - __Struct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct + where + __Struct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/pub/tuple_struct.expanded.rs b/tests/expand/pub/tuple_struct.expanded.rs index 02c3f24..5c7efbf 100644 --- a/tests/expand/pub/tuple_struct.expanded.rs +++ b/tests/expand/pub/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ pub struct TupleStruct(#[pin] pub T, pub U); #[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)] @@ -34,21 +35,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -68,15 +77,15 @@ const _: () = { >, __field0: T, } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} #[doc(hidden)] - unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct where - __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin - { - } + unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct + where + __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expand/unsafe_unpin/enum.expanded.rs b/tests/expand/unsafe_unpin/enum.expanded.rs index 3d53a1e..1f88ccc 100644 --- a/tests/expand/unsafe_unpin/enum.expanded.rs +++ b/tests/expand/unsafe_unpin/enum.expanded.rs @@ -1,11 +1,7 @@ use pin_project::{pin_project, UnsafeUnpin}; -# [pin (__private (UnsafeUnpin , project = EnumProj , project_ref = EnumProjRef))] +#[pin(__private(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef))] enum Enum { - Struct { - #[pin] - pinned: T, - unpinned: U, - }, + Struct { #[pin] pinned: T, unpinned: U }, Tuple(#[pin] T, U), Unit, } @@ -14,6 +10,7 @@ enum Enum { #[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)] @@ -36,6 +33,7 @@ where #[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)] @@ -46,10 +44,7 @@ enum EnumProjRef<'pin, T, U> where Enum: 'pin, { - Struct { - pinned: ::pin_project::__private::Pin<&'pin (T)>, - unpinned: &'pin (U), - }, + Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) }, Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)), Unit, } @@ -58,6 +53,7 @@ where #[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)] @@ -70,44 +66,56 @@ const _: () = { #[allow(unused_extern_crates)] extern crate pin_project as _pin_project; impl Enum { + #[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::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) + 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::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) + EnumProjRef::Tuple( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } Self::Unit => EnumProjRef::Unit, } } } } - impl<'pin, T, U> _pin_project::__private::Unpin for Enum where - _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Enum + where + _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin, + {} trait EnumMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl EnumMustNotImplDrop for T {} diff --git a/tests/expand/unsafe_unpin/struct.expanded.rs b/tests/expand/unsafe_unpin/struct.expanded.rs index a866ab3..5fa7271 100644 --- a/tests/expand/unsafe_unpin/struct.expanded.rs +++ b/tests/expand/unsafe_unpin/struct.expanded.rs @@ -10,6 +10,7 @@ struct Struct { #[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)] @@ -40,6 +41,7 @@ const _: () = { unpinned: &'pin (U), } impl Struct { + #[allow(dead_code)] fn project<'pin>( self: _pin_project::__private::Pin<&'pin mut Self>, ) -> __StructProjection<'pin, T, U> { @@ -51,6 +53,7 @@ const _: () = { } } } + #[allow(dead_code)] #[allow(clippy::missing_const_for_fn)] fn project_ref<'pin>( self: _pin_project::__private::Pin<&'pin Self>, @@ -69,10 +72,10 @@ const _: () = { let _ = &this.pinned; let _ = &this.unpinned; } - impl<'pin, T, U> _pin_project::__private::Unpin for Struct where - _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for Struct + where + _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin, + {} trait StructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl StructMustNotImplDrop for T {} diff --git a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs index 1a41976..de4e926 100644 --- a/tests/expand/unsafe_unpin/tuple_struct.expanded.rs +++ b/tests/expand/unsafe_unpin/tuple_struct.expanded.rs @@ -6,6 +6,7 @@ struct TupleStruct(#[pin] T, U); #[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)] @@ -34,21 +35,29 @@ const _: () = { where TupleStruct: 'pin; impl TupleStruct { + #[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) + __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) + __TupleStructProjectionRef( + _pin_project::__private::Pin::new_unchecked(_0), + _1, + ) } } } @@ -57,10 +66,10 @@ const _: () = { let _ = &this.0; let _ = &this.1; } - impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct where - _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin - { - } + impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct + where + _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin, + {} trait TupleStructMustNotImplDrop {} #[allow(clippy::drop_bounds, drop_bounds)] impl TupleStructMustNotImplDrop for T {} diff --git a/tests/expandtest.rs b/tests/expandtest.rs index 3f0d5c1..4feec1a 100644 --- a/tests/expandtest.rs +++ b/tests/expandtest.rs @@ -13,9 +13,9 @@ const PATH: &str = "tests/expand/**/*.rs"; fn expandtest() { let is_ci = env::var_os("CI").is_some(); let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into()); - if !has_command(&[cargo, "expand"]) || !has_command(&[cargo, "fmt"]) { + if !has_command(&[cargo, "expand"]) { if is_ci { - panic!("expandtest requires rustfmt and cargo-expand"); + panic!("expandtest requires cargo-expand"); } return; } diff --git a/tests/include/basic.rs b/tests/include/basic.rs index f862c63..57cbaeb 100644 --- a/tests/include/basic.rs +++ b/tests/include/basic.rs @@ -1,13 +1,16 @@ include!("basic-safe-part.rs"); +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinStruct { } +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct { } +#[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinEnum { diff --git a/tests/lint.rs b/tests/lint.rs index 6a75461..35f05d5 100644 --- a/tests/lint.rs +++ b/tests/lint.rs @@ -8,14 +8,16 @@ #![forbid(future_incompatible, rust_2018_compatibility, rust_2021_compatibility)] // lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below. // elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms -// unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. +// unsafe_op_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn. // non_exhaustive_omitted_patterns: unstable // unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features -// unused_crate_dependencies: unrelated +// unused_crate_dependencies, must_not_suspend: unrelated // unsafe_code: checked in forbid_unsafe module #![warn( box_pointers, deprecated_in_future, + fuzzy_provenance_casts, + lossy_provenance_casts, macro_use_extern_crate, meta_variable_misuse, missing_abi, @@ -32,11 +34,12 @@ unused_lifetimes, unused_qualifications, unused_results, + unused_tuple_struct_fields, variant_size_differences )] #![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)] #![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally. -#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] // TODO +#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums, clippy::single_char_lifetime_names)] // TODO pub mod basic { include!("include/basic.rs"); @@ -237,14 +240,17 @@ pub mod basic { Unit, } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinStruct { } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct { } + #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl ::pin_project::UnsafeUnpin for UnsafeUnpinEnum { @@ -756,6 +762,7 @@ pub mod explicit_outlives_requirements { } } +#[allow(missing_debug_implementations)] pub mod single_use_lifetimes { use pin_project::pin_project; @@ -765,7 +772,6 @@ pub mod single_use_lifetimes { #[allow(unused_lifetimes)] // for the type itself #[allow(single_use_lifetimes)] // for the type itself: https://github.com/rust-lang/rust/issues/55058 #[pin_project(project_replace)] - #[derive(Debug)] pub struct Hrtb<'pin___, T> where for<'pin> &'pin T: Unpin, @@ -788,7 +794,6 @@ pub mod single_use_lifetimes { #[allow(unused_lifetimes)] // for the type itself #[allow(single_use_lifetimes)] // for the type itself: https://github.com/rust-lang/rust/issues/55058 #[pin_project(project_replace)] - #[derive(Debug)] pub struct Hrtb<'pin___, T> where for<'pin> &'pin T: Unpin, @@ -917,12 +922,12 @@ pub mod clippy_mut_mut { } } +#[allow(missing_debug_implementations)] #[allow(unreachable_pub)] mod clippy_redundant_pub_crate { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct { #[pin] pub pinned: T, @@ -930,7 +935,6 @@ mod clippy_redundant_pub_crate { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct(#[pin] pub T, pub U); #[allow(dead_code)] @@ -939,7 +943,6 @@ mod clippy_redundant_pub_crate { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum { Struct { #[pin] @@ -953,11 +956,11 @@ mod clippy_redundant_pub_crate { pub mod inside_macro { use pin_project::pin_project; + #[allow(clippy::redundant_pub_crate)] #[rustfmt::skip] macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct { #[pin] pub pinned: T, @@ -965,7 +968,6 @@ mod clippy_redundant_pub_crate { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct(#[pin] pub T, pub U); #[allow(dead_code)] @@ -974,7 +976,6 @@ mod clippy_redundant_pub_crate { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum { Struct { #[pin] @@ -991,11 +992,11 @@ mod clippy_redundant_pub_crate { } } +#[allow(missing_debug_implementations)] pub mod clippy_type_repetition_in_bounds { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct where Self: Sized, @@ -1006,7 +1007,6 @@ pub mod clippy_type_repetition_in_bounds { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct(#[pin] T, U) where Self: Sized; @@ -1016,7 +1016,6 @@ pub mod clippy_type_repetition_in_bounds { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum where Self: Sized, @@ -1037,7 +1036,6 @@ pub mod clippy_type_repetition_in_bounds { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct where Self: Sized, @@ -1048,7 +1046,6 @@ pub mod clippy_type_repetition_in_bounds { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct TupleStruct(#[pin] T, U) where Self: Sized; @@ -1058,7 +1055,6 @@ pub mod clippy_type_repetition_in_bounds { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum where Self: Sized, @@ -1078,6 +1074,7 @@ pub mod clippy_type_repetition_in_bounds { } } +#[allow(missing_debug_implementations)] pub mod clippy_use_self { use pin_project::pin_project; @@ -1086,7 +1083,6 @@ pub mod clippy_use_self { } #[pin_project(project_replace)] - #[derive(Debug)] pub struct Generics> where Self: Trait, @@ -1103,7 +1099,6 @@ pub mod clippy_use_self { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Generics> where Self: Trait, @@ -1117,11 +1112,11 @@ pub mod clippy_use_self { } } +#[allow(missing_debug_implementations)] pub mod clippy_used_underscore_binding { use pin_project::pin_project; #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct { #[pin] pub _pinned: T, @@ -1133,7 +1128,6 @@ pub mod clippy_used_underscore_binding { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum { Struct { #[pin] @@ -1149,7 +1143,6 @@ pub mod clippy_used_underscore_binding { macro_rules! mac { () => { #[pin_project(project_replace)] - #[derive(Debug)] pub struct Struct { #[pin] pub _pinned: T, @@ -1161,7 +1154,6 @@ pub mod clippy_used_underscore_binding { project_ref = EnumProjRef, project_replace = EnumProjOwn, )] - #[derive(Debug)] pub enum Enum { Struct { #[pin] @@ -1176,11 +1168,11 @@ pub mod clippy_used_underscore_binding { } } +#[allow(missing_debug_implementations)] pub mod clippy_ref_option_ref { use pin_project::pin_project; #[pin_project] - #[derive(Debug)] pub struct Struct<'a> { #[pin] pub _pinned: Option<&'a ()>, @@ -1188,7 +1180,6 @@ pub mod clippy_ref_option_ref { } #[pin_project(project = EnumProj, project_ref = EnumProjRef)] - #[derive(Debug)] pub enum Enum<'a> { Struct { #[pin] diff --git a/tests/ui/not_unpin/conflict-unpin.stderr b/tests/ui/not_unpin/conflict-unpin.stderr index d644bf7..d79fbfb 100644 --- a/tests/ui/not_unpin/conflict-unpin.stderr +++ b/tests/ui/not_unpin/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | impl Unpin for Foo where T: Unpin {} - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>` --> tests/ui/not_unpin/conflict-unpin.rs:12:15 diff --git a/tests/ui/not_unpin/impl-unsafe-unpin.stderr b/tests/ui/not_unpin/impl-unsafe-unpin.stderr index a944e95..93f225e 100644 --- a/tests/ui/not_unpin/impl-unsafe-unpin.stderr +++ b/tests/ui/not_unpin/impl-unsafe-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | unsafe impl UnsafeUnpin for Foo where T: Unpin {} - | ---------------------------------------------------------- first implementation here + | ------------------------------------------- first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 5e012c4..7df5db2 100644 --- a/tests/ui/pin_project/conflict-unpin.stderr +++ b/tests/ui/pin_project/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 13 | impl Unpin for Foo where T: Unpin {} // Conditional Unpin impl - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/impl-unsafe-unpin.stderr b/tests/ui/pin_project/impl-unsafe-unpin.stderr index ba42303..9554b9b 100644 --- a/tests/ui/pin_project/impl-unsafe-unpin.stderr +++ b/tests/ui/pin_project/impl-unsafe-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | unsafe impl UnsafeUnpin for Foo where T: Unpin {} - | ---------------------------------------------------------- first implementation here + | ------------------------------------------- first implementation here | = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/packed_sneaky-1.rs b/tests/ui/pin_project/packed_sneaky-1.rs index 72d3d3e..83a4612 100644 --- a/tests/ui/pin_project/packed_sneaky-1.rs +++ b/tests/ui/pin_project/packed_sneaky-1.rs @@ -1,6 +1,6 @@ use std::pin::Pin; -use auxiliary_macro::hidden_repr; +use auxiliary_macro::{hidden_repr, hidden_repr2}; use pin_project::{pin_project, pinned_drop, UnsafeUnpin}; #[pin_project] //~ ERROR may not be used on #[repr(packed)] types @@ -10,6 +10,13 @@ struct A { f: u32, } +#[hidden_repr2] +#[pin_project] //~ ERROR may not be used on #[repr(packed)] types +struct B { + #[pin] + f: u32, +} + #[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types #[hidden_repr(packed)] struct C { diff --git a/tests/ui/pin_project/packed_sneaky-1.stderr b/tests/ui/pin_project/packed_sneaky-1.stderr index 32fe407..0746e1a 100644 --- a/tests/ui/pin_project/packed_sneaky-1.stderr +++ b/tests/ui/pin_project/packed_sneaky-1.stderr @@ -5,13 +5,21 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:14:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:13:1 | -14 | #[hidden_repr(packed)] +13 | #[hidden_repr2] + | ^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `hidden_repr2` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: #[pin_project] attribute may not be used on #[repr(packed)] types + --> tests/ui/pin_project/packed_sneaky-1.rs:21:15 + | +21 | #[hidden_repr(packed)] | ^^^^^^ error: #[pin_project] attribute may not be used on #[repr(packed)] types - --> tests/ui/pin_project/packed_sneaky-1.rs:23:15 + --> tests/ui/pin_project/packed_sneaky-1.rs:30:15 | -23 | #[hidden_repr(packed)] +30 | #[hidden_repr(packed)] | ^^^^^^ diff --git a/tests/ui/pin_project/packed_sneaky-4.rs b/tests/ui/pin_project/packed_sneaky-4.rs new file mode 100644 index 0000000..fb954ba --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.rs @@ -0,0 +1,15 @@ +// https://github.com/taiki-e/pin-project/issues/342 + +#![allow(unaligned_references)] + +use auxiliary_macro::hidden_repr2; +use pin_project::pin_project; + +#[pin_project] //~ ERROR reference to packed field is unaligned +#[hidden_repr2] +struct A { + #[pin] + f: u32, +} + +fn main() {} diff --git a/tests/ui/pin_project/packed_sneaky-4.stderr b/tests/ui/pin_project/packed_sneaky-4.stderr new file mode 100644 index 0000000..8072ce2 --- /dev/null +++ b/tests/ui/pin_project/packed_sneaky-4.stderr @@ -0,0 +1,16 @@ +error: reference to packed field is unaligned + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/pin_project/packed_sneaky-4.rs:8:1 + | +8 | #[pin_project] //~ ERROR reference to packed field is unaligned + | ^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82523 + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr index 86cc148..042b499 100644 --- a/tests/ui/pin_project/project_replace_unsized.stderr +++ b/tests/ui/pin_project/project_replace_unsized.stderr @@ -48,25 +48,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized.rs:5:5 - | -3 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -4 | struct Struct { - | - this type parameter needs to be `std::marker::Sized` -5 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized.rs:5:5 + | +3 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +4 | struct Struct { + | - this type parameter needs to be `std::marker::Sized` +5 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -4 - struct Struct { -4 + struct Struct { - | + | +4 - struct Struct { +4 + struct Struct { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized.rs:8:15 diff --git a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr index e398ca4..10fad08 100644 --- a/tests/ui/pin_project/project_replace_unsized_fn_params.stderr +++ b/tests/ui/pin_project/project_replace_unsized_fn_params.stderr @@ -45,25 +45,25 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized` | error[E0277]: the size for values of type `T` cannot be known at compilation time - --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 - | -5 | #[pin_project(project_replace)] //~ ERROR E0277 - | ------------------------------- required by a bound introduced by this call -6 | struct Struct { - | - this type parameter needs to be `std::marker::Sized` -7 | f: T, - | ^ doesn't have a size known at compile-time - | + --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5 + | +5 | #[pin_project(project_replace)] //~ ERROR E0277 + | ------------------------------- required by a bound introduced by this call +6 | struct Struct { + | - this type parameter needs to be `std::marker::Sized` +7 | f: T, + | ^ doesn't have a size known at compile-time + | note: required by a bound in `std::ptr::read` - --> $RUST/core/src/ptr/mod.rs - | - | pub const unsafe fn read(src: *const T) -> T { - | ^ required by this bound in `std::ptr::read` + --> $RUST/core/src/ptr/mod.rs + | + | pub const unsafe fn read(src: *const T) -> T { + | ^ required by this bound in `std::ptr::read` help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -6 - struct Struct { -6 + struct Struct { - | + | +6 - struct Struct { +6 + struct Struct { + | error[E0277]: the size for values of type `T` cannot be known at compilation time --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8 diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr index ddf700d..82c2aa5 100644 --- a/tests/ui/pin_project/unpin_sneaky.stderr +++ b/tests/ui/pin_project/unpin_sneaky.stderr @@ -3,9 +3,3 @@ error[E0412]: cannot find type `__S` in this scope | 9 | impl Unpin for __S {} //~ ERROR E0412,E0321 | ^^^ not found in this scope - -error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]` - --> tests/ui/pin_project/unpin_sneaky.rs:9:1 - | -9 | impl Unpin for __S {} //~ ERROR E0412,E0321 - | ^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr index b11bee5..e3ceebd 100644 --- a/tests/ui/pinned_drop/call-drop-inner.stderr +++ b/tests/ui/pinned_drop/call-drop-inner.stderr @@ -2,9 +2,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> tests/ui/pinned_drop/call-drop-inner.rs:13:9 | 13 | __drop_inner(__self); - | ^^^^^^^^^^^^ ------ supplied 1 argument - | | - | expected 0 arguments + | ^^^^^^^^^^^^ ------ argument of type `Pin<&mut Struct>` unexpected | note: function defined here --> tests/ui/pinned_drop/call-drop-inner.rs:10:1 @@ -12,3 +10,7 @@ note: function defined here 10 | #[pinned_drop] | ^^^^^^^^^^^^^^ = note: this error originates in the attribute macro `pinned_drop` (in Nightly builds, run with -Z macro-backtrace for more info) +help: remove the extra argument + | +13 | __drop_inner(); + | ~~~~~~~~~~~~~~ diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr index 0c55bc2..0587765 100644 --- a/tests/ui/pinned_drop/conditional-drop-impl.stderr +++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr @@ -7,10 +7,8 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented f note: the implementor must specify the same requirement --> tests/ui/pinned_drop/conditional-drop-impl.rs:7:1 | -7 | / struct DropImpl { -8 | | f: T, -9 | | } - | |_^ +7 | struct DropImpl { + | ^^^^^^^^^^^^^^^^^^ error[E0277]: `T` cannot be unpinned --> tests/ui/pinned_drop/conditional-drop-impl.rs:16:15 diff --git a/tests/ui/pinned_drop/self.stderr b/tests/ui/pinned_drop/self.stderr index 0f96dc9..a19d5a0 100644 --- a/tests/ui/pinned_drop/self.stderr +++ b/tests/ui/pinned_drop/self.stderr @@ -55,7 +55,7 @@ error[E0308]: mismatched types = note: expected unit type `()` found struct `Pin<&mut E>` -error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `E::V` --> tests/ui/pinned_drop/self.rs:53:27 | 53 | let _: Self = Self::V; //~ ERROR E0533 diff --git a/tests/ui/unsafe_unpin/conflict-unpin.stderr b/tests/ui/unsafe_unpin/conflict-unpin.stderr index 20d4e08..0e89b03 100644 --- a/tests/ui/unsafe_unpin/conflict-unpin.stderr +++ b/tests/ui/unsafe_unpin/conflict-unpin.stderr @@ -5,7 +5,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type | ^^^^^^^^^^^ conflicting implementation for `Foo<_, _>` ... 10 | impl Unpin for Foo where T: Unpin {} - | --------------------------------------------- first implementation here + | ------------------------------ first implementation here | = note: upstream crates may add a new impl of trait `_::_pin_project::UnsafeUnpin` for type `_::_pin_project::__private::Wrapper<'_, Foo<_, _>>` in future versions diff --git a/tests/ui/unstable-features/negative_impls.rs b/tests/ui/unstable-features/negative_impls.rs new file mode 100644 index 0000000..9605642 --- /dev/null +++ b/tests/ui/unstable-features/negative_impls.rs @@ -0,0 +1,23 @@ +#![feature(negative_impls)] +#![deny(suspicious_auto_trait_impls)] + +// https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.3A.20backlog.20bonanza/near/269471299 +// https://github.com/taiki-e/pin-project/issues/340 + +#[pin_project::pin_project] +struct Foo { + #[pin] + pinned: Pinned, + + unpinned: Unpinned, +} + +struct MyPhantomPinned {} +impl !Unpin for MyPhantomPinned {} +impl Unpin for Foo {} + +fn is_unpin() {} + +fn main() { + is_unpin::>() +} diff --git a/tests/ui/unstable-features/negative_impls.stderr b/tests/ui/unstable-features/negative_impls.stderr new file mode 100644 index 0000000..0d99e2b --- /dev/null +++ b/tests/ui/unstable-features/negative_impls.stderr @@ -0,0 +1,19 @@ +error: cross-crate traits with a default impl, like `Unpin`, should not be specialized + --> tests/ui/unstable-features/negative_impls.rs:17:1 + | +17 | impl Unpin for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/unstable-features/negative_impls.rs:2:9 + | +2 | #![deny(suspicious_auto_trait_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 + = note: `MyPhantomPinned` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> tests/ui/unstable-features/negative_impls.rs:8:1 + | +8 | struct Foo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3