aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-10-29 19:49:12 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-10-29 19:49:12 +0000
commitaeebe1a3e16408a040c3100ae74c5be0edbd7c6e (patch)
tree55ba197683b0a0093a2767fcb1f576490157f8a1
parentc017e76ff935d7c5111d24026e79fed4c2d2b22f (diff)
parent57fbfaa560008e6518b456f0a2af3de7bd30c708 (diff)
downloadpin-project-aeebe1a3e16408a040c3100ae74c5be0edbd7c6e.tar.gz
Upgrade rust/crates/pin-project to 1.0.1 am: 127364b149 am: 57fbfaa560
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pin-project/+/1475399 Change-Id: I9cd9cb20264b674aee653a1ad1d5f732eae15c1b
-rw-r--r--.cargo_vcs_info.json5
-rw-r--r--.github/workflows/ci.yml75
-rw-r--r--.gitignore2
-rw-r--r--Android.bp10
-rw-r--r--CHANGELOG.md125
-rw-r--r--CODE_OF_CONDUCT.md9
-rw-r--r--Cargo.toml15
-rw-r--r--Cargo.toml.orig11
-rw-r--r--LICENSE-APACHE25
-rw-r--r--METADATA8
-rw-r--r--README.md40
-rw-r--r--ci.sh26
-rw-r--r--ci/check-minimal-versions.sh27
-rwxr-xr-x[-rw-r--r--]ci/install-component.sh31
-rwxr-xr-x[-rw-r--r--]ci/install-rust.sh3
-rw-r--r--examples/README.md11
-rw-r--r--examples/enum-default-expanded.rs53
-rw-r--r--examples/not_unpin-expanded.rs82
-rw-r--r--examples/pinned_drop-expanded.rs75
-rw-r--r--examples/project_replace-expanded.rs94
-rw-r--r--examples/struct-default-expanded.rs97
-rw-r--r--examples/unsafe_unpin-expanded.rs76
-rw-r--r--patches/std.diff14
-rw-r--r--scripts/README.md3
-rwxr-xr-xscripts/check-minimal-versions.sh44
-rwxr-xr-xscripts/ci.sh37
-rwxr-xr-xscripts/expandtest.sh35
-rw-r--r--src/lib.rs97
-rw-r--r--tests/auxiliary/mod.rs12
-rw-r--r--tests/cfg.rs39
-rw-r--r--tests/compiletest.rs3
-rw-r--r--tests/drop_order.rs159
-rw-r--r--tests/include/basic-safe-part.rs29
-rw-r--r--tests/lint.rs737
-rw-r--r--tests/lint.txt15
-rw-r--r--tests/pin_project.rs415
-rw-r--r--tests/pinned_drop.rs200
-rw-r--r--tests/project.rs298
-rw-r--r--tests/project_if_attr.rs.in45
-rw-r--r--tests/project_ref.rs175
-rw-r--r--tests/project_replace.rs99
-rw-r--r--tests/proper_unpin.rs135
-rw-r--r--tests/repr_packed.rs8
-rw-r--r--tests/sized.rs13
-rw-r--r--tests/ui/cfg/cfg_attr-resolve.rs4
-rw-r--r--tests/ui/cfg/cfg_attr-resolve.stderr4
-rw-r--r--tests/ui/cfg/cfg_attr-type-mismatch.rs12
-rw-r--r--tests/ui/cfg/cfg_attr-type-mismatch.stderr16
-rw-r--r--tests/ui/cfg/cfg_attr-unpin.rs21
-rw-r--r--tests/ui/cfg/cfg_attr-unpin.stderr22
-rw-r--r--tests/ui/cfg/packed_sneaky-span-issue-1.rs8
-rw-r--r--tests/ui/cfg/packed_sneaky-span-issue-2.rs8
-rw-r--r--tests/ui/cfg/packed_sneaky.rs6
-rw-r--r--tests/ui/cfg/packed_sneaky.stderr6
-rw-r--r--tests/ui/cfg/proper_unpin.rs28
-rw-r--r--tests/ui/cfg/proper_unpin.stderr11
-rw-r--r--tests/ui/cfg/unsupported.rs2
-rw-r--r--tests/ui/not_unpin/assert-not-unpin.rs40
-rw-r--r--tests/ui/not_unpin/assert-not-unpin.stderr83
-rw-r--r--tests/ui/not_unpin/conflict-unpin.rs12
-rw-r--r--tests/ui/not_unpin/impl-unsafe-unpin.rs12
-rw-r--r--tests/ui/pin_project/add-attr-to-struct.rs6
-rw-r--r--tests/ui/pin_project/add-pinned-field.rs6
-rw-r--r--tests/ui/pin_project/add-pinned-field.stderr16
-rw-r--r--tests/ui/pin_project/conflict-drop.rs8
-rw-r--r--tests/ui/pin_project/conflict-unpin.rs12
-rw-r--r--tests/ui/pin_project/impl-unsafe-unpin.rs12
-rw-r--r--tests/ui/pin_project/import_unnamed.rs30
-rw-r--r--tests/ui/pin_project/import_unnamed.stderr29
-rw-r--r--tests/ui/pin_project/invalid.rs45
-rw-r--r--tests/ui/pin_project/invalid.stderr200
-rw-r--r--tests/ui/pin_project/overlapping_unpin_struct.rs10
-rw-r--r--tests/ui/pin_project/overlapping_unpin_struct.stderr10
-rw-r--r--tests/ui/pin_project/packed.rs6
-rw-r--r--tests/ui/pin_project/packed_sneaky-1.rs8
-rw-r--r--tests/ui/pin_project/packed_sneaky-1.stderr18
-rw-r--r--tests/ui/pin_project/packed_sneaky-2.rs4
-rw-r--r--tests/ui/pin_project/packed_sneaky-2.stderr2
-rw-r--r--tests/ui/pin_project/packed_sneaky-3.rs32
-rw-r--r--tests/ui/pin_project/packed_sneaky-3.stderr30
-rw-r--r--tests/ui/pin_project/private_in_public-enum.rs8
-rw-r--r--tests/ui/pin_project/private_in_public-enum.stderr12
-rw-r--r--tests/ui/pin_project/project_replace_unsized.rs2
-rw-r--r--tests/ui/pin_project/project_replace_unsized.stderr14
-rw-r--r--tests/ui/pin_project/project_replace_unsized_locals.rs2
-rw-r--r--tests/ui/pin_project/project_replace_unsized_locals.stderr12
-rw-r--r--tests/ui/pin_project/proper_unpin.rs38
-rw-r--r--tests/ui/pin_project/proper_unpin.stderr37
-rw-r--r--tests/ui/pin_project/remove-attr-from-field.rs14
-rw-r--r--tests/ui/pin_project/remove-attr-from-field.stderr16
-rw-r--r--tests/ui/pin_project/remove-attr-from-struct.rs16
-rw-r--r--tests/ui/pin_project/remove-attr-from-struct.stderr28
-rw-r--r--tests/ui/pin_project/safe_packed_borrows.rs14
-rw-r--r--tests/ui/pin_project/safe_packed_borrows.stderr14
-rw-r--r--tests/ui/pin_project/unpin_sneaky.rs6
-rw-r--r--tests/ui/pin_project/unpin_sneaky.stderr12
-rw-r--r--tests/ui/pin_project/visibility.rs61
-rw-r--r--tests/ui/pin_project/visibility.stderr70
-rw-r--r--tests/ui/pinned_drop/call-drop-inner.rs2
-rw-r--r--tests/ui/pinned_drop/conditional-drop-impl.rs4
-rw-r--r--tests/ui/pinned_drop/conditional-drop-impl.stderr12
-rw-r--r--tests/ui/pinned_drop/forget-pinned-drop-impl.rs2
-rw-r--r--tests/ui/pinned_drop/forget-pinned-drop-impl.stderr4
-rw-r--r--tests/ui/pinned_drop/invalid-self.rs6
-rw-r--r--tests/ui/pinned_drop/invalid-self.stderr4
-rw-r--r--tests/ui/pinned_drop/invalid.rs4
-rw-r--r--tests/ui/pinned_drop/invalid.stderr4
-rw-r--r--tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs7
-rw-r--r--tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr6
-rw-r--r--tests/ui/pinned_drop/self.rs10
-rw-r--r--tests/ui/pinned_drop/self.stderr12
-rw-r--r--tests/ui/pinned_drop/unsafe-call.rs8
-rw-r--r--tests/ui/pinned_drop/unsafe-call.stderr4
-rw-r--r--tests/ui/project/ambiguous-let.rs26
-rw-r--r--tests/ui/project/ambiguous-let.stderr5
-rw-r--r--tests/ui/project/deprecated.rs8
-rw-r--r--tests/ui/project/deprecated.stderr23
-rw-r--r--tests/ui/project/invalid.rs192
-rw-r--r--tests/ui/project/invalid.stderr155
-rw-r--r--tests/ui/project/type-mismatch.rs72
-rw-r--r--tests/ui/project/type-mismatch.stderr23
-rw-r--r--tests/ui/project/use-public.rs17
-rw-r--r--tests/ui/project/use-public.stderr7
-rw-r--r--tests/ui/project/use.rs19
-rw-r--r--tests/ui/project/use.stderr11
-rw-r--r--tests/ui/unsafe_unpin/conflict-unpin.rs12
-rw-r--r--tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs14
-rw-r--r--tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr11
-rw-r--r--tests/ui/unsafe_unpin/proper_unpin.rs41
-rw-r--r--tests/ui/unsafe_unpin/proper_unpin.stderr63
-rw-r--r--tests/ui/unstable-features/marker_trait_attr-feature-gate.rs2
-rw-r--r--tests/ui/unstable-features/marker_trait_attr.rs2
-rw-r--r--tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs2
-rw-r--r--tests/ui/unstable-features/overlapping_marker_traits.rs2
-rw-r--r--tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs63
-rw-r--r--tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs57
-rw-r--r--tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr35
-rw-r--r--tests/ui/unstable-features/trivial_bounds-bug.stderr4
-rw-r--r--tests/ui/unstable-features/trivial_bounds-feature-gate.rs3
-rw-r--r--tests/ui/unstable-features/trivial_bounds-feature-gate.stderr36
-rw-r--r--tests/ui/unstable-features/trivial_bounds.stderr4
-rw-r--r--tests/unsafe_unpin.rs50
142 files changed, 2602 insertions, 3113 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
new file mode 100644
index 0000000..da3735d
--- /dev/null
+++ b/.cargo_vcs_info.json
@@ -0,0 +1,5 @@
+{
+ "git": {
+ "sha1": "a69b3004032bfabf8cac8ac809d56ff32e66ed82"
+ }
+}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6cd7fae..8a7da1d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,7 +8,7 @@ on:
- staging
- trying
schedule:
- - cron: '00 01 * * *'
+ - cron: '0 1 * * *'
env:
RUSTFLAGS: -Dwarnings
@@ -26,25 +26,22 @@ jobs:
rust:
# This is the minimum supported Rust version of this crate.
# When updating this, the reminder to update the minimum supported Rust version in README.md.
- - 1.34.0
- - 1.36.0
- 1.37.0
- stable
- beta
include:
- - os: ubuntu
+ - os: ubuntu-latest
rust: nightly
# pin-project itself has no platform-dependent implementation.
# macOS is only used to check that pin-project can interoperate
# correctly with `#[cfg()]`.
- - os: macos
+ - os: macos-latest
rust: nightly
- runs-on: ${{ matrix.os || 'ubuntu' }}-latest
+ runs-on: ${{ matrix.os || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v2
- name: Install Rust
- run: |
- . ./ci/install-rust.sh ${{ matrix.rust }}
+ run: ci/install-rust.sh ${{ matrix.rust }}
- name: Install cargo-hack
if: matrix.rust == 'nightly'
run: |
@@ -53,12 +50,7 @@ jobs:
if: matrix.rust == 'nightly'
run: |
rustup target add thumbv7m-none-eabi
- - name: cargo test --tests
- if: matrix.rust == '1.34.0' || matrix.rust == '1.36.0'
- run: |
- cargo test --all --all-features --exclude expandtest --tests
- name: cargo test
- if: matrix.rust != '1.34.0' && matrix.rust != '1.36.0'
run: |
cargo test --all --all-features --exclude expandtest
- name: cargo check (no-std)
@@ -69,37 +61,42 @@ jobs:
- name: cargo check (minimal versions)
if: matrix.rust == 'nightly'
run: |
- . ./ci/check-minimal-versions.sh
+ bash scripts/check-minimal-versions.sh
expandtest:
name: expandtest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- run: |
- . ./ci/install-rust.sh
- - name: Install rustfmt
- run: |
- . ./ci/install-component.sh rustfmt
+ - name: Install Rust and Rustfmt
+ run: ci/install-component.sh rustfmt
- name: Install cargo-expand
run: |
cargo install cargo-expand
- name: cargo test (expandtest)
run: |
- cargo test --all-features --manifest-path tests/expand/Cargo.toml
+ bash scripts/expandtest.sh
- clippy:
- name: clippy
+ miri:
+ name: miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
+ - name: Install Rust and Miri
run: |
- . ./ci/install-rust.sh
- - name: Install clippy
+ ci/install-component.sh miri
+ cargo miri setup
+ - name: cargo miri test
run: |
- . ./ci/install-component.sh clippy
+ cargo miri test
+
+ clippy:
+ name: clippy
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install Rust and Clippy
+ run: ci/install-component.sh clippy
- name: cargo clippy
run: |
cargo clippy --all --all-features --all-targets
@@ -109,12 +106,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Install Rust
- run: |
- . ./ci/install-rust.sh
- - name: Install rustfmt
- run: |
- . ./ci/install-component.sh rustfmt
+ - name: Install Rust and Rustfmt
+ run: ci/install-component.sh rustfmt
- name: cargo fmt --check
run: |
cargo fmt --all -- --check
@@ -127,12 +120,20 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Rust
- run: |
- . ./ci/install-rust.sh
+ run: ci/install-rust.sh
- name: cargo doc
run: |
cargo doc --no-deps --all --all-features
+ shellcheck:
+ name: shellcheck
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: shellcheck
+ run: |
+ shellcheck ci/*.sh scripts/*.sh
+
# These jobs don't actually test anything, but they're used to tell bors the
# build completed, as there is no practical way to detect when a workflow is
# successful listening to webhooks only.
@@ -148,6 +149,8 @@ jobs:
- rustfmt
- rustdoc
- expandtest
+ - miri
+ - shellcheck
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
@@ -161,6 +164,8 @@ jobs:
- rustfmt
- rustdoc
- expandtest
+ - miri
+ - shellcheck
runs-on: ubuntu-latest
steps:
- name: Mark the job as a failure
diff --git a/.gitignore b/.gitignore
index 214d7a8..ad0f684 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,4 @@ Cargo.lock
# For platform and editor specific settings, it is recommended to add to
# a global .gitignore file.
-# Refs: https://help.github.com/en/articles/ignoring-files#create-a-global-gitignore
+# Refs: https://docs.github.com/en/free-pro-team@latest/github/using-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer
diff --git a/Android.bp b/Android.bp
index 748477a..f20d8c1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -6,14 +6,12 @@ rust_library {
crate_name: "pin_project",
srcs: ["src/lib.rs"],
edition: "2018",
- proc_macros: [
- "libpin_project_internal",
- ],
+ proc_macros: ["libpin_project_internal"],
}
// dependent_library ["feature_list"]
-// pin-project-internal-0.4.23
-// proc-macro2-1.0.18 "default,proc-macro"
+// pin-project-internal-1.0.1
+// proc-macro2-1.0.24 "default,proc-macro"
// quote-1.0.7 "default,proc-macro"
-// syn-1.0.34 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit-mut"
+// syn-1.0.48 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit,visit-mut"
// unicode-xid-0.2.1 "default"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ad7438..f68f7b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,108 @@ This project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
+## [1.0.1] - 2020-10-15
+
+* [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
+
+* [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
+
+ Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
+
+ ```diff
+ - #[pin_project]
+ + #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ - #[project]
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ - #[project]
+ match x.project() {
+ - Enum::Variant(_) => { /* ... */ }
+ + EnumProj::Variant(_) => { /* ... */ }
+ }
+ }
+ ```
+
+* [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
+
+* [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
+
+* [Raise the minimum supported Rust version of this crate from Rust 1.34 to Rust 1.37.](https://github.com/taiki-e/pin-project/pull/292)
+
+* Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, `clippy::implicit_return`, and `clippy::redundant_pub_crate` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277), [#284](https://github.com/taiki-e/pin-project/pull/284))
+
+* Diagnostic improvements.
+
+Changes since the 1.0.0-alpha.1 release:
+
+* [Fix drop order of pinned fields in project_replace](https://github.com/taiki-e/pin-project/pull/287)
+
+* Update minimal version of `syn` to 1.0.44
+
+## [1.0.0-alpha.1] - 2020-09-22
+
+* [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
+
+ Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
+
+ ```diff
+ - #[pin_project]
+ + #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ - #[project]
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ - #[project]
+ match x.project() {
+ - Enum::Variant(_) => { /* ... */ }
+ + EnumProj::Variant(_) => { /* ... */ }
+ }
+ }
+ ```
+
+* [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
+
+* [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
+
+* Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, and `clippy::implicit_return` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277))
+
+* Diagnostic improvements.
+
+See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project/issues/264).
+
+## [0.4.27] - 2020-10-11
+
+* Update minimal version of `syn` to 1.0.44
+
+## [0.4.26] - 2020-10-04
+
+* [Fix drop order of pinned fields in project_replace](https://github.com/taiki-e/pin-project/pull/287)
+
+## [0.4.25] - 2020-10-01
+
+* Suppress `drop_bounds` lint, which will be added to rustc in the future. See [#272](https://github.com/taiki-e/pin-project/issues/272) for more details.
+
+ (Note: 1.0.0-alpha.1 already contains this change.)
+
+## [0.4.24] - 2020-09-26
+
+* Fix compatibility of generated code with `forbid(future_incompatible)`
+
+ 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
-* [Fix compile error with `?Sized` type parameters.][262]
+* [Fix compile error with `?Sized` type parameters.][263]
-[262]: https://github.com/taiki-e/pin-project/pull/262
+[263]: https://github.com/taiki-e/pin-project/pull/263
## [0.4.22] - 2020-06-14
@@ -20,12 +117,9 @@ This project adheres to [Semantic Versioning](https://semver.org).
* [Deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes due to some unfixable limitations.][244]
- Consider naming the projected type by passing an argument with the same name as the method to the #[pin_project] attribute instead.
+ Consider naming the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead.
```rust
- use pin_project::pin_project;
- use std::pin::Pin;
-
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
@@ -107,9 +201,6 @@ This project adheres to [Semantic Versioning](https://semver.org).
By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:
```rust
- use pin_project::pin_project;
- use std::pin::Pin;
-
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
@@ -143,7 +234,6 @@ This project adheres to [Semantic Versioning](https://semver.org).
* [Added `!Unpin` option to `#[pin_project]` attribute for guarantee the type is `!Unpin`.][219]
```rust
- use pin_project::pin_project;
#[pin_project(!Unpin)]
struct Struct<T, U> {
field: T,
@@ -153,8 +243,6 @@ This project adheres to [Semantic Versioning](https://semver.org).
This is equivalent to use `#[pin]` attribute for `PhantomPinned` field.
```rust
- use pin_project::pin_project;
- use std::marker::PhantomPinned;
#[pin_project]
struct Struct<T, U> {
field: T,
@@ -163,7 +251,7 @@ This project adheres to [Semantic Versioning](https://semver.org).
}
```
- *[Note: This raises the minimum supported Rust version of this crate from rustc 1.33 to rustc 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)*
* [Fixed an issue where duplicate `#[project]` attributes were ignored.][218]
@@ -392,7 +480,7 @@ Changes since the 0.4.0-beta.1 release:
## [0.4.0-alpha.9] - 2019-09-05
-* [Added 'project_into' method to #[pin_project] types][69]. This can be useful when returning a pin projection from a method.
+* [Added 'project_into' method to `#[pin_project]` types][69]. This can be useful when returning a pin projection from a method.
```rust
fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
self.project_into().pinned
@@ -553,7 +641,14 @@ See also [tracking issue for 0.4 release][21].
Initial release
-[Unreleased]: https://github.com/taiki-e/pin-project/compare/v0.4.23...HEAD
+[Unreleased]: https://github.com/taiki-e/pin-project/compare/v1.0.1...HEAD
+[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.27]: https://github.com/taiki-e/pin-project/compare/v0.4.26...v0.4.27
+[0.4.26]: https://github.com/taiki-e/pin-project/compare/v0.4.25...v0.4.26
+[0.4.25]: https://github.com/taiki-e/pin-project/compare/v0.4.24...v0.4.25
+[0.4.24]: https://github.com/taiki-e/pin-project/compare/v0.4.23...v0.4.24
[0.4.23]: https://github.com/taiki-e/pin-project/compare/v0.4.22...v0.4.23
[0.4.22]: https://github.com/taiki-e/pin-project/compare/v0.4.21...v0.4.22
[0.4.21]: https://github.com/taiki-e/pin-project/compare/v0.4.20...v0.4.21
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..70c2090
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,9 @@
+# Code of Conduct
+
+This project adheres to the [Rust Code of Conduct].
+
+## Enforcement
+
+If you believe someone is violating the code of conduct, we ask that you report it by contacting taiki-e (te316e89@gmail.com).
+
+[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
diff --git a/Cargo.toml b/Cargo.toml
index 997d6fa..5d73386 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "pin-project"
-version = "0.4.23"
+version = "1.0.1"
authors = ["Taiki Endo <te316e89@gmail.com>"]
description = "A crate for safe and ergonomic pin-projection.\n"
homepage = "https://github.com/taiki-e/pin-project"
@@ -26,5 +26,16 @@ repository = "https://github.com/taiki-e/pin-project"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies.pin-project-internal]
-version = "=0.4.23"
+version = "=1.0.1"
default-features = false
+[dev-dependencies.pin-project-auxiliary-macro]
+version = "0"
+
+[dev-dependencies.rustversion]
+version = "1"
+
+[dev-dependencies.static_assertions]
+version = "1"
+
+[dev-dependencies.trybuild]
+version = "1"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 1f3ae36..ef428f0 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "pin-project"
-version = "0.4.23"
+version = "1.0.1"
authors = ["Taiki Endo <te316e89@gmail.com>"]
edition = "2018"
license = "Apache-2.0 OR MIT"
@@ -20,7 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[workspace]
members = [
"pin-project-internal",
- "tests/ui/auxiliary",
+ "tests/auxiliary/macro",
"tests/doc",
"tests/expand",
"tests/no-core",
@@ -29,5 +29,10 @@ members = [
]
[dependencies]
-pin-project-internal = { version = "=0.4.23", path = "pin-project-internal", default-features = false }
+pin-project-internal = { version = "=1.0.1", path = "pin-project-internal", default-features = false }
+[dev-dependencies]
+pin-project-auxiliary-macro = { version = "0", path = "tests/auxiliary/macro" }
+rustversion = "1"
+static_assertions = "1"
+trybuild = "1"
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
index d645695..f433b1a 100644
--- a/LICENSE-APACHE
+++ b/LICENSE-APACHE
@@ -175,28 +175,3 @@
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/METADATA b/METADATA
index 12bc110..d4ac624 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/pin-project/pin-project-0.4.23.crate"
+ value: "https://static.crates.io/crates/pin-project/pin-project-1.0.1.crate"
}
- version: "0.4.23"
+ version: "1.0.1"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 7
- day: 27
+ month: 10
+ day: 26
}
}
diff --git a/README.md b/README.md
index caee4d3..0d5f5d7 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@
[docs-url]: https://docs.rs/pin-project
[license-badge]: https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg
[license]: #license
-[rustc-badge]: https://img.shields.io/badge/rustc-1.34+-lightgray.svg
-[rustc-url]: https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html
+[rustc-badge]: https://img.shields.io/badge/rustc-1.37+-lightgray.svg
+[rustc-url]: https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html
A crate for safe and ergonomic [pin-projection].
@@ -22,10 +22,10 @@ Add this to your `Cargo.toml`:
```toml
[dependencies]
-pin-project = "0.4"
+pin-project = "1"
```
-The current pin-project requires Rust 1.34 or later.
+The current pin-project requires Rust 1.37 or later.
## Examples
@@ -54,10 +54,40 @@ impl<T, U> Struct<T, U> {
[*code like this will be generated*][struct-default-expanded]
+To use `#[pin_project]` on enums, you need to name the projection type
+returned from the method.
+
+```rust
+use pin_project::pin_project;
+use std::pin::Pin;
+
+#[pin_project(project = EnumProj)]
+enum Enum<T, U> {
+ Pinned(#[pin] T),
+ Unpinned(U),
+}
+
+impl<T, U> Enum<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ match self.project() {
+ EnumProj::Pinned(x) => {
+ let _: Pin<&mut T> = x;
+ }
+ EnumProj::Unpinned(y) => {
+ let _: &mut U = y;
+ }
+ }
+ }
+}
+```
+
+[*code like this will be generated*][enum-default-expanded]
+
See [documentation][docs-url] for more details, and
see [examples] directory for more examples and generated code.
-[`pin_project`]: https://docs.rs/pin-project/0.4/pin_project/attr.pin_project.html
+[`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/nightly/std/pin/index.html#projections-and-structural-pinning
[struct-default-expanded]: examples/struct-default-expanded.rs
diff --git a/ci.sh b/ci.sh
deleted file mode 100644
index 9c82699..0000000
--- a/ci.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-# A script to run a simplified version of the checks done by CI.
-#
-# Usage
-#
-# ```sh
-# . ./ci.sh
-# ```
-
-echo "Running 'cargo fmt'"
-cargo +nightly fmt --all
-
-echo "Running 'cargo clippy'"
-cargo +nightly clippy --all --all-features --all-targets
-
-echo "Running 'cargo test'"
-TRYBUILD=overwrite cargo +nightly test --all --all-features --exclude expandtest
-
-echo "Running 'cargo doc'"
-cargo +nightly doc --no-deps --all --all-features
-
-echo "Running 'expandtest'"
-# See also https://docs.rs/macrotest/1/macrotest/#updating-expandedrs
-# rm **/*.expanded.rs
-cargo +nightly test --manifest-path tests/expand/Cargo.toml
diff --git a/ci/check-minimal-versions.sh b/ci/check-minimal-versions.sh
deleted file mode 100644
index 6152c15..0000000
--- a/ci/check-minimal-versions.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-# Check all public crates with minimal version dependencies.
-#
-# Note that this script modifies Cargo.toml and Cargo.lock while this script is
-# running, and it is an error if there are any unstaged changes.
-#
-# Refs:
-# * minimal versions: https://github.com/rust-lang/cargo/issues/5657
-# * features 2.0: https://github.com/rust-lang/cargo/issues/8088
-
-set -euo pipefail
-
-# This script modifies Cargo.toml and Cargo.lock, so make sure there are no
-# unstaged changes.
-git diff --exit-code
-
-# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
-# from determining minimal versions based on dev-dependencies.
-cargo hack --remove-dev-deps --workspace
-
-# Update Cargo.lock to minimal version dependencies.
-cargo update -Zminimal-versions
-# Run check for all public members of the workspace.
-cargo hack check --workspace --all-features --ignore-private -Zfeatures=all
-
-# Restore original Cargo.toml and Cargo.lock.
-git checkout .
diff --git a/ci/install-component.sh b/ci/install-component.sh
index 9aaa5ce..dbba7b1 100644..100755
--- a/ci/install-component.sh
+++ b/ci/install-component.sh
@@ -1,22 +1,27 @@
#!/bin/bash
+# Install nightly Rust with a given component.
+#
+# If the component is unavailable on the latest nightly,
+# use the latest toolchain with the component available.
+#
+# When using stable Rust, this script is basically unnecessary as almost components available.
+#
+# Refs: https://github.com/rust-lang/rustup-components-history#the-web-part
+
set -euo pipefail
-component="${1}"
+package="${1:?}"
+target="${2:-x86_64-unknown-linux-gnu}"
-if ! rustup component add "${component}" 2>/dev/null; then
- # If the component is unavailable on the latest nightly,
- # use the latest toolchain with the component available.
- # Refs: https://github.com/rust-lang/rustup-components-history#the-web-part
- target=$(curl -sSf "https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/${component}")
- echo "'${component}' is unavailable on the default toolchain, use the toolchain 'nightly-${target}' instead"
+date=$(curl -sSf https://rust-lang.github.io/rustup-components-history/"${target}"/"${package}")
- . ci/install-rust.sh "nightly-${target}"
+# shellcheck disable=1090
+"$(cd "$(dirname "${0}")" && pwd)"/install-rust.sh nightly-"${date}"
- rustup component add "${component}"
-fi
+rustup component add "${package}"
-case "${component}" in
- rustfmt) "${component}" -V ;;
- *) cargo "${component}" -V ;;
+case "${package}" in
+ rustfmt) "${package}" -V ;;
+ *) cargo "${package}" -V ;;
esac
diff --git a/ci/install-rust.sh b/ci/install-rust.sh
index b6625b6..92c5877 100644..100755
--- a/ci/install-rust.sh
+++ b/ci/install-rust.sh
@@ -4,8 +4,7 @@ set -euo pipefail
toolchain="${1:-nightly}"
-rustup set profile minimal
-rustup update "${toolchain}" --no-self-update
+rustup toolchain install "${toolchain}" --no-self-update --profile minimal
rustup default "${toolchain}"
rustup -V
diff --git a/examples/README.md b/examples/README.md
index 94f49b5..3f0d87e 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -14,22 +14,25 @@
* [example](unsafe_unpin.rs)
* [generated code](unsafe_unpin-expanded.rs)
- * [`UnsafeUnpin` documentation](https://docs.rs/pin-project/0.4/pin_project/trait.UnsafeUnpin.html)
+ * [`UnsafeUnpin` documentation](https://docs.rs/pin-project/1/pin_project/trait.UnsafeUnpin.html)
### Manual implementation of `Drop` by `#[pinned_drop]`
* [example](pinned_drop.rs)
* [generated code](pinned_drop-expanded.rs)
- * [`#[pinned_drop]` documentation](https://docs.rs/pin-project/0.4/pin_project/attr.pinned_drop.html)
+ * [`#[pinned_drop]` documentation](https://docs.rs/pin-project/1/pin_project/attr.pinned_drop.html)
### `project_replace()` method
* [example](project_replace.rs)
* [generated code](project_replace-expanded.rs)
- * [`project_replace()` documentation](https://docs.rs/pin-project/0.4/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)
### Ensure `!Unpin` by `#[pin_project(!Unpin)]`
* [example](not_unpin.rs)
* [generated code](not_unpin-expanded.rs)
- * [`!Unpin` documentation](https://docs.rs/pin-project/0.4/pin_project/attr.pin_project.html#unpin)
+ * [`!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 want to see the exact version of the actual generated code.
diff --git a/examples/enum-default-expanded.rs b/examples/enum-default-expanded.rs
index cea3ae5..f234b51 100644
--- a/examples/enum-default-expanded.rs
+++ b/examples/enum-default-expanded.rs
@@ -14,20 +14,17 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::just_underscores_and_digits)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes, clippy::just_underscores_and_digits)]
use pin_project::pin_project;
+// #[pin_project(project = EnumProj)]
enum Enum<T, U> {
Pinned(/* #[pin] */ T),
Unpinned(U),
}
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
@@ -35,23 +32,13 @@ where
Pinned(::pin_project::__private::Pin<&'pin mut (T)>),
Unpinned(&'pin mut (U)),
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-enum __EnumProjectionRef<'pin, T, U>
-where
- Enum<T, U>: 'pin,
-{
- Pinned(::pin_project::__private::Pin<&'pin (T)>),
- Unpinned(&'pin (U)),
-}
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ // When `#[pin_project]` is used on enums, only named projection types and
+ // methods are generated because there is no way to access variants of
+ // projected types without naming it.
+ // (When `#[pin_project]` is used on structs, both methods are always generated.)
+
impl<T, U> Enum<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -65,18 +52,6 @@ const _: () = {
}
}
}
- fn project_ref<'pin>(
- self: ::pin_project::__private::Pin<&'pin Self>,
- ) -> __EnumProjectionRef<'pin, T, U> {
- unsafe {
- match self.get_ref() {
- Enum::Pinned(_0) => __EnumProjectionRef::Pinned(
- ::pin_project::__private::Pin::new_unchecked(_0),
- ),
- Enum::Unpinned(_0) => __EnumProjectionRef::Unpinned(_0),
- }
- }
- }
}
// Automatically create the appropriate conditional `Unpin` implementation.
@@ -94,15 +69,23 @@ const _: () = {
__Enum<'pin, T, U>: ::pin_project::__private::Unpin
{
}
- unsafe impl<T, U> ::pin_project::UnsafeUnpin for Enum<T, U> {}
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Enum<T, U> where
+ __Enum<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
// Ensure that enum does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait EnumMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
diff --git a/examples/not_unpin-expanded.rs b/examples/not_unpin-expanded.rs
index fdfe5a2..aa5209d 100644
--- a/examples/not_unpin-expanded.rs
+++ b/examples/not_unpin-expanded.rs
@@ -18,46 +18,34 @@
// }
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
+// #[pin_project(!Unpin)]
pub struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjection<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
- unpinned: &'pin mut (U),
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjectionRef<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin (T)>,
- unpinned: &'pin (U),
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ pub(crate) struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ pub(crate) struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
impl<T, U> Struct<T, U> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -83,6 +71,17 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
// Create `Unpin` impl that has trivial `Unpin` bounds.
//
// See https://github.com/taiki-e/pin-project/issues/102#issuecomment-540472282
@@ -98,29 +97,26 @@ const _: () = {
// impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
// impl, they'll get a "conflicting implementations of trait" error when
// coherence checks are run.
- unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ ::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>:
+ ::pin_project::__private::Unpin
+ {
+ }
// Ensure that struct does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
- // for details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<T, U>(val: &Struct<T, U>) {
- &val.pinned;
- &val.unpinned;
- }
};
fn main() {
diff --git a/examples/pinned_drop-expanded.rs b/examples/pinned_drop-expanded.rs
index 8f295e9..ad22c0b 100644
--- a/examples/pinned_drop-expanded.rs
+++ b/examples/pinned_drop-expanded.rs
@@ -21,47 +21,35 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;
+// #[pin_project(PinnedDrop)]
pub struct Struct<'a, T> {
was_dropped: &'a mut bool,
// #[pin]
field: T,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjection<'pin, 'a, T>
-where
- Struct<'a, T>: 'pin,
-{
- was_dropped: &'pin mut (&'a mut bool),
- field: ::pin_project::__private::Pin<&'pin mut (T)>,
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjectionRef<'pin, 'a, T>
-where
- Struct<'a, T>: 'pin,
-{
- was_dropped: &'pin (&'a mut bool),
- field: ::pin_project::__private::Pin<&'pin (T)>,
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ pub(crate) struct __StructProjection<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin mut (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin mut (T)>,
+ }
+ pub(crate) struct __StructProjectionRef<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin (T)>,
+ }
+
impl<'a, T> Struct<'a, T> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -87,6 +75,17 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<'a, T>(this: &Struct<'a, T>) {
+ let _ = &this.was_dropped;
+ let _ = &this.field;
+ }
+
impl<'a, T> ::pin_project::__private::Drop for Struct<'a, T> {
fn drop(&mut self) {
// Safety - we're in 'drop', so we know that 'self' will
@@ -114,17 +113,11 @@ const _: () = {
__Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
{
}
- unsafe impl<'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> {}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
- // for details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<'a, T>(val: &Struct<'a, T>) {
- &val.was_dropped;
- &val.field;
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, 'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where
+ __Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
+ {
}
};
diff --git a/examples/project_replace-expanded.rs b/examples/project_replace-expanded.rs
index 16f47b7..ec00d41 100644
--- a/examples/project_replace-expanded.rs
+++ b/examples/project_replace-expanded.rs
@@ -15,54 +15,38 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
+// #[pin_project(project_replace)]
struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-struct __StructProjection<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
- unpinned: &'pin mut (U),
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-struct __StructProjectionRef<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin (T)>,
- unpinned: &'pin (U),
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(unreachable_pub)]
-#[allow(single_use_lifetimes)]
-struct __StructProjectionOwned<T, U> {
- pinned: ::pin_project::__private::PhantomData<T>,
- unpinned: U,
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ struct __StructProjectionOwned<T, U> {
+ pinned: ::pin_project::__private::PhantomData<T>,
+ unpinned: U,
+ }
+
impl<T, U> Struct<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -122,6 +106,17 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
// Automatically create the appropriate conditional `Unpin` implementation.
//
// See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
@@ -137,29 +132,26 @@ const _: () = {
__Struct<'pin, T, U>: ::pin_project::__private::Unpin
{
}
- unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
// Ensure that struct does not implement `Drop`.
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
- // for details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<T, U>(val: &Struct<T, U>) {
- &val.pinned;
- &val.unpinned;
- }
};
fn main() {}
diff --git a/examples/struct-default-expanded.rs b/examples/struct-default-expanded.rs
index ff160ce..3d0e4ab 100644
--- a/examples/struct-default-expanded.rs
+++ b/examples/struct-default-expanded.rs
@@ -15,46 +15,34 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::pin_project;
+// #[pin_project]
struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-struct __StructProjection<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
- unpinned: &'pin mut (U),
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-struct __StructProjectionRef<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin (T)>,
- unpinned: &'pin (U),
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
impl<T, U> Struct<T, U> {
fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -80,6 +68,26 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // Taking a reference to a packed field is unsafe, and applying
+ // #[forbid(safe_packed_borrows)] makes sure that doing this without
+ // an 'unsafe' block (which we deliberately do not generate)
+ // is a hard error.
+ //
+ // If the struct ends up having #[repr(packed)] applied somehow,
+ // this will generate an (unfriendly) error message. Under all reasonable
+ // circumstances, we'll detect the #[repr(packed)] attribute, and generate
+ // a much nicer error above.
+ //
+ // See https://github.com/taiki-e/pin-project/pull/34 for more details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
// Automatically create the appropriate conditional `Unpin` implementation.
//
// Basically this is equivalent to the following code:
@@ -123,7 +131,11 @@ const _: () = {
// impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
// impl, they'll get a "conflicting implementations of trait" error when
// coherence checks are run.
- unsafe impl<T, U> ::pin_project::UnsafeUnpin for Struct<T, U> {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
// Ensure that struct does not implement `Drop`.
//
@@ -131,34 +143,15 @@ const _: () = {
// then apply to your type, causing a compile-time error due to
// the conflict with the second impl.
trait StructMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
// A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
// write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // Taking a reference to a packed field is unsafe, and applying
- // #[deny(safe_packed_borrows)] makes sure that doing this without
- // an 'unsafe' block (which we deliberately do not generate)
- // is a hard error.
- //
- // If the struct ends up having #[repr(packed)] applied somehow,
- // this will generate an (unfriendly) error message. Under all reasonable
- // circumstances, we'll detect the #[repr(packed)] attribute, and generate
- // a much nicer error above.
- //
- // See https://github.com/taiki-e/pin-project/pull/34 for more details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<T, U>(val: &Struct<T, U>) {
- &val.pinned;
- &val.unpinned;
- }
};
fn main() {}
diff --git a/examples/unsafe_unpin-expanded.rs b/examples/unsafe_unpin-expanded.rs
index e55b740..2ea1f37 100644
--- a/examples/unsafe_unpin-expanded.rs
+++ b/examples/unsafe_unpin-expanded.rs
@@ -17,46 +17,34 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::{pin_project, UnsafeUnpin};
+// #[pin_project(UnsafeUnpin)]
pub struct Struct<T, U> {
// #[pin]
pinned: T,
unpinned: U,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjection<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
- unpinned: &'pin mut (U),
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjectionRef<'pin, T, U>
-where
- Struct<T, U>: 'pin,
-{
- pinned: ::pin_project::__private::Pin<&'pin (T)>,
- unpinned: &'pin (U),
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ pub(crate) struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ pub(crate) struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
impl<T, U> Struct<T, U> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -82,6 +70,18 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
+ // Implement `Unpin` via `UnsafeUnpin`.
impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin
{
@@ -91,23 +91,15 @@ const _: () = {
//
// See ./struct-default-expanded.rs for details.
trait StructMustNotImplDrop {}
- #[allow(clippy::drop_bounds)]
+ #[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
- // for details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<T, U>(val: &Struct<T, U>) {
- &val.pinned;
- &val.unpinned;
- }
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
diff --git a/patches/std.diff b/patches/std.diff
new file mode 100644
index 0000000..562ddd1
--- /dev/null
+++ b/patches/std.diff
@@ -0,0 +1,14 @@
+diff --git a/src/lib.rs b/src/lib.rs
+index aaa561f..016a0c7 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -81,6 +81,9 @@
+ )]
+ #![allow(clippy::needless_doctest_main)]
+
++// ANDROID: Use std to allow building as a dylib.
++extern crate std;
++
+ #[doc(inline)]
+ pub use pin_project_internal::pin_project;
+
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 0000000..671a9b1
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,3 @@
+This directory contains scripts used by the developers of this project.
+
+Some scripts in this directory are also used in CI, but scripts intended to be used only in CI and scripts not intended to be used directly by the developers are basically in the `ci` directory.
diff --git a/scripts/check-minimal-versions.sh b/scripts/check-minimal-versions.sh
new file mode 100755
index 0000000..6c7fa7b
--- /dev/null
+++ b/scripts/check-minimal-versions.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Check all public crates with minimal version dependencies.
+#
+# Usage:
+# bash scripts/check-minimal-versions.sh
+#
+# Note:
+# - This script modifies Cargo.toml and Cargo.lock while running
+# - This script exits with 1 if there are any unstaged changes
+# - This script requires nightly Rust and cargo-hack
+#
+# Refs: https://github.com/rust-lang/cargo/issues/5657
+
+set -euo pipefail
+
+cd "$(cd "$(dirname "${0}")" && pwd)"/..
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+elif [[ "${CI:-false}" != "true" ]]; then
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! cargo hack -V &>/dev/null; then
+ echo "error: check-minimal-versions.sh requires nightly Rust and cargo-hack"
+ exit 1
+fi
+
+# This script modifies Cargo.toml and Cargo.lock, so make sure there are no
+# unstaged changes.
+git diff --exit-code
+# Restore original Cargo.toml and Cargo.lock on exit.
+trap 'git checkout .' EXIT
+
+# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
+# from determining minimal versions based on dev-dependencies.
+cargo hack --remove-dev-deps --workspace
+
+# Update Cargo.lock to minimal version dependencies.
+cargo ${toolchain:-} update -Zminimal-versions
+# Run check for all public members of the workspace.
+cargo ${toolchain:-} hack check --workspace --all-features --ignore-private -Zfeatures=all
diff --git a/scripts/ci.sh b/scripts/ci.sh
new file mode 100755
index 0000000..ec08568
--- /dev/null
+++ b/scripts/ci.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# A script to run a simplified version of the checks done by CI.
+#
+# Usage:
+# bash scripts/ci.sh
+#
+# Note: This script requires nightly Rust, rustfmt, clippy, and cargo-expand
+
+set -euo pipefail
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+else
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! rustfmt -V &>/dev/null || ! cargo clippy -V &>/dev/null || ! cargo expand -V &>/dev/null; then
+ echo "error: ci.sh requires nightly Rust, rustfmt, clippy, and cargo-expand"
+ exit 1
+fi
+
+echo "Running 'cargo ${toolchain} fmt --all'"
+cargo "${toolchain}" fmt --all
+
+echo "Running 'cargo ${toolchain} clippy --all --all-targets'"
+cargo "${toolchain}" clippy --all --all-features --all-targets -Zunstable-options
+
+echo "Running 'cargo ${toolchain} test --all --exclude expandtest'"
+TRYBUILD=overwrite cargo "${toolchain}" test --all --all-features --exclude expandtest
+
+echo "Running 'bash scripts/expandtest.sh ${toolchain}'"
+"$(cd "$(dirname "${0}")" && pwd)"/expandtest.sh "${toolchain}"
+
+echo "Running 'cargo ${toolchain} doc --no-deps --all'"
+cargo "${toolchain}" doc --no-deps --all --all-features
diff --git a/scripts/expandtest.sh b/scripts/expandtest.sh
new file mode 100755
index 0000000..844ace6
--- /dev/null
+++ b/scripts/expandtest.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# A script to run expandtest.
+#
+# Usage:
+# bash scripts/expandtest.sh
+#
+# Note: This script requires nightly Rust, rustfmt, and cargo-expand
+
+set -euo pipefail
+
+script_dir="$(cd "$(dirname "${0}")" && pwd)"
+
+if [[ "${1:-none}" == "+"* ]]; then
+ toolchain="${1}"
+elif [[ "${CI:-false}" != "true" ]]; then
+ cargo +nightly -V >/dev/null || exit 1
+ toolchain="+nightly"
+fi
+
+if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! rustfmt -V &>/dev/null || ! cargo expand -V &>/dev/null; then
+ echo "error: expandtest.sh requires nightly Rust, rustfmt, and cargo-expand"
+ exit 1
+fi
+
+if [[ "${CI:-false}" != "true" ]]; then
+ # First, check if the compile fails for another reason.
+ cargo ${toolchain} check --tests --manifest-path "${script_dir}"/../tests/expand/Cargo.toml
+
+ # Next, remove the `*.expanded.rs` files to allow updating those files.
+ # Refs: https://docs.rs/macrotest/1/macrotest/#updating-expandedrs
+ rm -rf "${script_dir}"/../tests/expand/tests/expand/*.expanded.rs
+fi
+
+cargo ${toolchain:-} test --manifest-path "${script_dir}"/../tests/expand/Cargo.toml
diff --git a/src/lib.rs b/src/lib.rs
index 61d90ea..016a0c7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -27,24 +27,58 @@
//!
//! [*code like this will be generated*][struct-default-expanded]
//!
+//! To use `#[pin_project]` on enums, you need to name the projection type
+//! returned from the method.
+//!
+//! ```rust
+//! use pin_project::pin_project;
+//! use std::pin::Pin;
+//!
+//! #[pin_project(project = EnumProj)]
+//! enum Enum<T, U> {
+//! Pinned(#[pin] T),
+//! Unpinned(U),
+//! }
+//!
+//! impl<T, U> Enum<T, U> {
+//! fn method(self: Pin<&mut Self>) {
+//! match self.project() {
+//! EnumProj::Pinned(x) => {
+//! let _: Pin<&mut T> = x;
+//! }
+//! EnumProj::Unpinned(y) => {
+//! let _: &mut U = y;
+//! }
+//! }
+//! }
+//! }
+//! ```
+//!
+//! [*code like this will be generated*][enum-default-expanded]
+//!
//! See [`#[pin_project]`][`pin_project`] attribute for more details, and
//! see [examples] directory for more examples and generated code.
//!
-//! [`pin_project`]: attr.pin_project.html
//! [examples]: https://github.com/taiki-e/pin-project/blob/master/examples/README.md
-//! [pin-projection]: https://doc.rust-lang.org/nightly/std/pin/index.html#projections-and-structural-pinning
+//! [enum-default-expanded]: https://github.com/taiki-e/pin-project/blob/master/examples/enum-default-expanded.rs
+//! [pin-projection]: core::pin#projections-and-structural-pinning
//! [struct-default-expanded]: https://github.com/taiki-e/pin-project/blob/master/examples/struct-default-expanded.rs
#![no_std]
-#![doc(html_root_url = "https://docs.rs/pin-project/0.4.23")]
+#![doc(html_root_url = "https://docs.rs/pin-project/1.0.1")]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms, single_use_lifetimes), allow(dead_code))
))]
-#![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
+#![warn(future_incompatible, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
+#![warn(missing_docs)]
#![warn(clippy::all, clippy::default_trait_access)]
-// mem::take and #[non_exhaustive] requires Rust 1.40
-#![allow(clippy::mem_replace_with_default, clippy::manual_non_exhaustive)]
+// mem::take and #[non_exhaustive] requires Rust 1.40, matches! requires Rust 1.42
+#![allow(
+ clippy::mem_replace_with_default,
+ clippy::manual_non_exhaustive,
+ clippy::match_like_matches_macro
+)]
#![allow(clippy::needless_doctest_main)]
// ANDROID: Use std to allow building as a dylib.
@@ -56,25 +90,14 @@ pub use pin_project_internal::pin_project;
#[doc(inline)]
pub use pin_project_internal::pinned_drop;
-#[allow(deprecated)]
-#[doc(inline)]
-pub use pin_project_internal::project;
-
-#[allow(deprecated)]
-#[doc(inline)]
-pub use pin_project_internal::project_ref;
-
-#[allow(deprecated)]
-#[doc(inline)]
-pub use pin_project_internal::project_replace;
-
/// A trait used for custom implementations of [`Unpin`].
-/// This trait is used in conjunction with the `UnsafeUnpin`
-/// argument to [`#[pin_project]`][`pin_project`]
+///
+/// This trait is used in conjunction with the `UnsafeUnpin` argument to
+/// the [`#[pin_project]`][macro@pin_project] attribute.
///
/// The Rust [`Unpin`] trait is safe to implement - by itself,
-/// implementing it cannot lead to undefined behavior. Undefined
-/// behavior can only occur when other unsafe code is used.
+/// implementing it cannot lead to [undefined behavior][undefined-behavior].
+/// Undefined behavior can only occur when other unsafe code is used.
///
/// It turns out that using pin projections, which requires unsafe code,
/// imposes additional requirements on an [`Unpin`] impl. Normally, all of this
@@ -112,19 +135,19 @@ pub use pin_project_internal::project_replace;
/// use pin_project::{pin_project, UnsafeUnpin};
///
/// #[pin_project(UnsafeUnpin)]
-/// struct Foo<K, V> {
+/// struct Struct<K, V> {
/// #[pin]
/// field_1: K,
/// field_2: V,
/// }
///
-/// unsafe impl<K, V> UnsafeUnpin for Foo<K, V> where K: Unpin + Clone {}
+/// unsafe impl<K, V> UnsafeUnpin for Struct<K, V> where K: Unpin + Clone {}
/// ```
///
/// [`PhantomPinned`]: core::marker::PhantomPinned
-/// [`pin_project`]: attr.pin_project.html
-/// [pin-projection]: https://doc.rust-lang.org/nightly/std/pin/index.html#projections-and-structural-pinning
/// [cargo-geiger]: https://github.com/rust-secure-code/cargo-geiger
+/// [pin-projection]: core::pin#projections-and-structural-pinning
+/// [undefined-behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
pub unsafe trait UnsafeUnpin {}
// Not public API.
@@ -144,18 +167,26 @@ pub mod __private {
#[doc(hidden)]
pub use pin_project_internal::__PinProjectInternalDerive;
+ // An internal trait used for custom implementations of [`Drop`].
+ //
+ // **Do not call or implement this trait directly.**
+ //
+ // # Why this trait is private and `#[pinned_drop]` attribute is needed?
+ //
// Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
// This is because destructors can be called multiple times in safe code and
- // [double dropping is unsound](https://github.com/rust-lang/rust/pull/62360).
+ // [double dropping is unsound][rust-lang/rust#62360].
//
// Ideally, it would be desirable to be able to forbid manual calls in
// the same way as [`Drop::drop`], but the library cannot do it. So, by using
- // macros and replacing them with private traits, we prevent users from
- // calling `PinnedDrop::drop`.
+ // macros and replacing them with private traits,
+ // this crate prevent users from calling `PinnedDrop::drop` in safe code.
//
- // Users can implement [`Drop`] safely using `#[pinned_drop]` and can drop a
- // type that implements `PinnedDrop` using the [`drop`] function safely.
- // **Do not call or implement this trait directly.**
+ // This allows implementing [`Drop`] safely using `#[pinned_drop]`.
+ // Also by using the [`drop`] function just like dropping a type that directly
+ // implements [`Drop`], can drop safely a type that implements `PinnedDrop`.
+ //
+ // [rust-lang/rust#62360]: https://github.com/rust-lang/rust/pull/62360
#[doc(hidden)]
pub trait PinnedDrop {
#[doc(hidden)]
@@ -223,7 +254,7 @@ pub mod __private {
//
// See https://github.com/taiki-e/pin-project/pull/53 for more details.
#[doc(hidden)]
- pub struct AlwaysUnpin<'a, T: ?Sized>(PhantomData<&'a ()>, PhantomData<T>);
+ pub struct AlwaysUnpin<'a, T>(PhantomData<&'a ()>, PhantomData<T>);
impl<T> Unpin for AlwaysUnpin<'_, T> {}
diff --git a/tests/auxiliary/mod.rs b/tests/auxiliary/mod.rs
new file mode 100644
index 0000000..1457099
--- /dev/null
+++ b/tests/auxiliary/mod.rs
@@ -0,0 +1,12 @@
+#![allow(dead_code, unused_macros)]
+
+macro_rules! assert_unpin {
+ ($ty:ty) => {
+ static_assertions::assert_impl_all!($ty: Unpin);
+ };
+}
+macro_rules! assert_not_unpin {
+ ($ty:ty) => {
+ static_assertions::assert_not_impl_all!($ty: Unpin);
+ };
+}
diff --git a/tests/cfg.rs b/tests/cfg.rs
index 4133517..9fde697 100644
--- a/tests/cfg.rs
+++ b/tests/cfg.rs
@@ -1,20 +1,20 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
-// Refs: https://doc.rust-lang.org/nightly/reference/attributes.html
+// Refs: https://doc.rust-lang.org/reference/attributes.html
+
+#[macro_use]
+mod auxiliary;
use pin_project::pin_project;
use std::{marker::PhantomPinned, pin::Pin};
-fn is_unpin<T: Unpin>() {}
-
#[cfg(target_os = "linux")]
struct Linux;
#[cfg(not(target_os = "linux"))]
struct Other;
// Use this type to check that `cfg(any())` is working properly.
-// If `cfg(any())` is not working properly, `is_unpin` will fail.
struct Any(PhantomPinned);
#[test]
@@ -34,7 +34,7 @@ fn cfg() {
any: Any,
}
- is_unpin::<SameName>();
+ assert_unpin!(SameName);
#[cfg(target_os = "linux")]
let _x = SameName { inner: Linux };
@@ -54,7 +54,7 @@ fn cfg() {
a: Any,
}
- is_unpin::<DifferentName>();
+ assert_unpin!(DifferentName);
#[cfg(target_os = "linux")]
let _x = DifferentName { l: Linux };
@@ -74,7 +74,7 @@ fn cfg() {
Any,
);
- is_unpin::<TupleStruct>();
+ assert_unpin!(TupleStruct);
#[cfg(target_os = "linux")]
let _x = TupleStruct(Linux);
@@ -83,7 +83,11 @@ fn cfg() {
// enums
- #[pin_project(project_replace)]
+ #[pin_project(
+ project = VariantProj,
+ project_ref = VariantProjRef,
+ project_replace = VariantProjOwn,
+ )]
enum Variant {
#[cfg(target_os = "linux")]
Inner(#[pin] Linux),
@@ -98,7 +102,7 @@ fn cfg() {
Any(#[pin] Any),
}
- is_unpin::<Variant>();
+ assert_unpin!(Variant);
#[cfg(target_os = "linux")]
let _x = Variant::Inner(Linux);
@@ -110,7 +114,11 @@ fn cfg() {
#[cfg(not(target_os = "linux"))]
let _x = Variant::Other(Other);
- #[pin_project(project_replace)]
+ #[pin_project(
+ project = FieldProj,
+ project_ref = FieldProjRef,
+ project_replace = FieldProjOwn,
+ )]
enum Field {
SameName {
#[cfg(target_os = "linux")]
@@ -147,7 +155,7 @@ fn cfg() {
),
}
- is_unpin::<Field>();
+ assert_unpin!(Field);
#[cfg(target_os = "linux")]
let _x = Field::SameName { inner: Linux };
@@ -180,7 +188,7 @@ fn cfg_attr() {
any: Any,
}
- is_unpin::<SameCfg>();
+ assert_unpin!(SameCfg);
#[cfg(target_os = "linux")]
let mut x = SameCfg { inner: Linux };
@@ -206,7 +214,7 @@ fn cfg_attr() {
any: Any,
}
- is_unpin::<DifferentCfg>();
+ assert_unpin!(DifferentCfg);
#[cfg(target_os = "linux")]
let mut x = DifferentCfg { inner: Linux };
@@ -225,6 +233,9 @@ fn cfg_attr() {
inner: T,
}
+ assert_unpin!(Foo<()>);
+ assert_not_unpin!(Foo<PhantomPinned>);
+
let mut x = Foo { inner: 0_u8 };
let x = Pin::new(&mut x).project();
let _: Pin<&mut u8> = x.inner;
@@ -237,6 +248,6 @@ fn cfg_attr_any_packed() {
#[cfg_attr(any(), repr(packed))]
struct Struct {
#[pin]
- field: u32,
+ f: u32,
}
}
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index e78b3dc..be01ba8 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -1,3 +1,4 @@
+#![cfg(not(miri))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
#[rustversion::attr(not(nightly), ignore)]
@@ -8,8 +9,6 @@ fn ui() {
t.compile_fail("tests/ui/not_unpin/*.rs");
t.compile_fail("tests/ui/pin_project/*.rs");
t.compile_fail("tests/ui/pinned_drop/*.rs");
- t.compile_fail("tests/ui/project/*.rs");
t.compile_fail("tests/ui/unsafe_unpin/*.rs");
t.compile_fail("tests/ui/unstable-features/*.rs");
- t.pass("tests/ui/unstable-features/run-pass/*.rs");
}
diff --git a/tests/drop_order.rs b/tests/drop_order.rs
new file mode 100644
index 0000000..1931b68
--- /dev/null
+++ b/tests/drop_order.rs
@@ -0,0 +1,159 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+// Refs: https://doc.rust-lang.org/reference/destructors.html
+
+use pin_project::pin_project;
+use std::{cell::Cell, pin::Pin, thread};
+
+struct D<'a>(&'a Cell<usize>, usize);
+
+impl Drop for D<'_> {
+ fn drop(&mut self) {
+ if !thread::panicking() {
+ let old = self.0.replace(self.1);
+ assert_eq!(old, self.1 - 1);
+ }
+ }
+}
+
+#[pin_project(project_replace)]
+struct StructPinned<'a> {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+}
+
+#[pin_project(project_replace)]
+struct StructUnpinned<'a> {
+ f1: D<'a>,
+ f2: D<'a>,
+}
+
+#[pin_project(project_replace)]
+struct TuplePinned<'a>(#[pin] D<'a>, #[pin] D<'a>);
+
+#[pin_project(project_replace)]
+struct TupleUnpinned<'a>(D<'a>, D<'a>);
+
+#[pin_project(project_replace = EnumProj)]
+enum Enum<'a> {
+ StructPinned {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+ },
+ StructUnpinned {
+ f1: D<'a>,
+ f2: D<'a>,
+ },
+ TuplePinned(#[pin] D<'a>, #[pin] D<'a>),
+ TupleUnpinned(D<'a>, D<'a>),
+}
+
+#[test]
+fn struct_pinned() {
+ {
+ let c = Cell::new(0);
+ let _x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn struct_unpinned() {
+ {
+ let c = Cell::new(0);
+ let _x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn tuple_pinned() {
+ {
+ let c = Cell::new(0);
+ let _x = TuplePinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = TuplePinned(D(&c, 1), D(&c, 2));
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(TuplePinned(D(&c, 3), D(&c, 4)));
+ }
+}
+
+#[test]
+fn tuple_unpinned() {
+ {
+ let c = Cell::new(0);
+ let _x = TupleUnpinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = TupleUnpinned(D(&c, 1), D(&c, 2));
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(TupleUnpinned(D(&c, 3), D(&c, 4)));
+ }
+}
+
+#[test]
+fn enum_struct() {
+ {
+ let c = Cell::new(0);
+ let _x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(Enum::StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+
+ {
+ let c = Cell::new(0);
+ let _x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(Enum::StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn enum_tuple() {
+ {
+ let c = Cell::new(0);
+ let _x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(Enum::TuplePinned(D(&c, 3), D(&c, 4)));
+ }
+
+ {
+ let c = Cell::new(0);
+ let _x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut _x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
+ let _y = Pin::new(&mut _x);
+ let _z = _y.project_replace(Enum::TupleUnpinned(D(&c, 3), D(&c, 4)));
+ }
+}
diff --git a/tests/include/basic-safe-part.rs b/tests/include/basic-safe-part.rs
index fefc924..c8d24bd 100644
--- a/tests/include/basic-safe-part.rs
+++ b/tests/include/basic-safe-part.rs
@@ -12,7 +12,10 @@ pub struct DefaultStruct<T, U> {
#[derive(Debug)]
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
-#[::pin_project::pin_project]
+#[::pin_project::pin_project(
+ project = DefaultEnumProj,
+ project_ref = DefaultEnumProjRef,
+)]
#[derive(Debug)]
pub enum DefaultEnum<T, U> {
Struct {
@@ -46,7 +49,11 @@ impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
-#[::pin_project::pin_project(PinnedDrop)]
+#[::pin_project::pin_project(
+ PinnedDrop,
+ project = PinnedDropEnumProj,
+ project_ref = PinnedDropEnumProjRef,
+)]
#[derive(Debug)]
pub enum PinnedDropEnum<T, U> {
Struct {
@@ -75,7 +82,11 @@ pub struct ReplaceStruct<T, U> {
#[derive(Debug)]
pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
-#[::pin_project::pin_project(project_replace)]
+#[::pin_project::pin_project(
+ project = ReplaceEnumProj,
+ project_ref = ReplaceEnumProjRef,
+ project_replace = ReplaceEnumProjOwn,
+)]
#[derive(Debug)]
pub enum ReplaceEnum<T, U> {
Struct {
@@ -99,7 +110,11 @@ pub struct UnsafeUnpinStruct<T, U> {
#[derive(Debug)]
pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
-#[::pin_project::pin_project(UnsafeUnpin)]
+#[::pin_project::pin_project(
+ UnsafeUnpin,
+ project = UnsafeUnpinEnumProj,
+ project_ref = UnsafeUnpinEnumProjRef,
+)]
#[derive(Debug)]
pub enum UnsafeUnpinEnum<T, U> {
Struct {
@@ -123,7 +138,11 @@ pub struct NotUnpinStruct<T, U> {
#[derive(Debug)]
pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
-#[::pin_project::pin_project(!Unpin)]
+#[::pin_project::pin_project(
+ !Unpin,
+ project = NotUnpinEnumProj,
+ project_ref = NotUnpinEnumProjRef,
+)]
#[derive(Debug)]
pub enum NotUnpinEnum<T, U> {
Struct {
diff --git a/tests/lint.rs b/tests/lint.rs
index e152930..86cb121 100644
--- a/tests/lint.rs
+++ b/tests/lint.rs
@@ -1,31 +1,25 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![warn(future_incompatible, nonstandard_style, rust_2018_compatibility, unused)]
-#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
+#![warn(nonstandard_style, rust_2018_idioms, rustdoc, unused)]
+// Note: This does not guarantee compatibility with forbidding these lints in the future.
+// If rustc adds a new lint, we may not be able to keep this.
+#![forbid(future_incompatible, rust_2018_compatibility)]
#![allow(unknown_lints)] // for old compilers
#![warn(
- absolute_paths_not_starting_with_crate,
- anonymous_parameters,
box_pointers,
deprecated_in_future,
elided_lifetimes_in_paths,
explicit_outlives_requirements,
- indirect_structural_match,
- keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_copy_implementations,
missing_crate_level_docs,
missing_debug_implementations,
missing_docs,
- missing_doc_code_examples,
non_ascii_idents,
- private_doc_tests,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unaligned_references,
unreachable_pub,
- unstable_features,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
@@ -33,14 +27,196 @@
unused_results,
variant_size_differences
)]
-// unused_crate_dependencies: unrelated
-// unsafe_code: checked in forbid_unsafe module
+// absolute_paths_not_starting_with_crate, anonymous_parameters, keyword_idents, pointer_structural_match: forbidden as a part of future_incompatible
+// missing_doc_code_examples, private_doc_tests, invalid_html_tags: warned as a part of rustdoc
// unsafe_block_in_unsafe_fn: unstable
+// unsafe_code: checked in forbid_unsafe module
+// unstable_features: deprecated: https://doc.rust-lang.org/beta/rustc/lints/listing/allowed-by-default.html#unstable-features
+// unused_crate_dependencies: unrelated
+#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
+#![warn(clippy::restriction)]
+#![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
// Check interoperability with rustc and clippy lints.
pub mod basic {
include!("include/basic.rs");
+
+ pub mod inside_macro {
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[::pin_project::pin_project]
+ #[derive(Debug)]
+ pub struct DefaultStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project]
+ #[derive(Debug)]
+ pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = DefaultEnumProj,
+ project_ref = DefaultEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(
+ PinnedDrop,
+ project = PinnedDropEnumProj,
+ project_ref = PinnedDropEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum PinnedDropEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = ReplaceEnumProj,
+ project_ref = ReplaceEnumProjRef,
+ project_replace = ReplaceEnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum ReplaceEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ UnsafeUnpin,
+ project = UnsafeUnpinEnumProj,
+ project_ref = UnsafeUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum UnsafeUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ !Unpin,
+ project = NotUnpinEnumProj,
+ project_ref = NotUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum NotUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U>
+ {
+ }
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U>
+ {
+ }
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U>
+ {
+ }
+ };
+ }
+
+ mac!();
+ }
}
pub mod forbid_unsafe {
@@ -49,27 +225,294 @@ pub mod forbid_unsafe {
include!("include/basic-safe-part.rs");
}
-pub mod clippy {
+pub mod box_pointers {
+ use pin_project::pin_project;
+
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct {
+ #[pin]
+ pub p: Box<isize>,
+ pub u: Box<isize>,
+ }
+
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct(#[pin] pub Box<isize>, pub Box<isize>);
+
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum {
+ Struct {
+ #[pin]
+ p: Box<isize>,
+ u: Box<isize>,
+ },
+ Tuple(#[pin] Box<isize>, Box<isize>),
+ Unit,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct {
+ #[pin]
+ pub p: Box<isize>,
+ pub u: Box<isize>,
+ }
+
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct(#[pin] pub Box<isize>, pub Box<isize>);
+
+ #[allow(box_pointers)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum {
+ Struct {
+ #[pin]
+ p: Box<isize>,
+ u: Box<isize>,
+ },
+ Tuple(#[pin] Box<isize>, Box<isize>),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod explicit_outlives_requirements {
use pin_project::pin_project;
- #[rustversion::attr(before(1.37), allow(single_use_lifetimes))] // https://github.com/rust-lang/rust/issues/53738
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
#[pin_project(project_replace)]
#[derive(Debug)]
- pub struct MutMutStruct<'a, T, U> {
+ pub struct Struct<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
#[pin]
pub pinned: &'a mut T,
pub unpinned: &'a mut U,
}
- #[rustversion::attr(before(1.37), allow(single_use_lifetimes))] // https://github.com/rust-lang/rust/issues/53738
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<'a, T, U>(#[pin] pub &'a mut T, pub &'a mut U)
+ where
+ T: ?Sized,
+ U: ?Sized;
+
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Tuple(#[pin] &'a mut T, &'a mut U),
+ Unit,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
+
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<'a, T, U>(#[pin] pub &'a mut T, pub &'a mut U)
+ where
+ T: ?Sized,
+ U: ?Sized;
+
+ #[allow(explicit_outlives_requirements)] // for the type itself: https://github.com/rust-lang/rust/issues/60993
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Tuple(#[pin] &'a mut T, &'a mut U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod single_use_lifetimes {
+ use pin_project::pin_project;
+
+ #[allow(unused_lifetimes)]
+ pub trait Trait<'a> {}
+
+ #[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,
+ T: for<'pin> Trait<'pin>,
+ for<'pin, 'pin_, 'pin__> &'pin &'pin_ &'pin__ T: Unpin,
+ {
+ #[pin]
+ f: &'pin___ mut T,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[allow(unused_lifetimes)]
+ pub trait Trait<'a> {}
+
+ #[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,
+ T: for<'pin> Trait<'pin>,
+ for<'pin, 'pin_, 'pin__> &'pin &'pin_ &'pin__ T: Unpin,
+ {
+ #[pin]
+ f: &'pin___ mut T,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod variant_size_differences {
+ use pin_project::pin_project;
+
+ #[allow(missing_debug_implementations, missing_copy_implementations)] // https://github.com/rust-lang/rust/pull/74060
+ #[allow(variant_size_differences)] // for the type itself
+ #[allow(clippy::large_enum_variant)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum {
+ V1(u8),
+ V2([u8; 1024]),
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[allow(missing_debug_implementations, missing_copy_implementations)] // https://github.com/rust-lang/rust/pull/74060
+ #[allow(variant_size_differences)] // for the type itself
+ #[allow(clippy::large_enum_variant)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum {
+ V1(u8),
+ V2([u8; 1024]),
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod clippy_mut_mut {
+ use pin_project::pin_project;
+
#[pin_project(project_replace)]
#[derive(Debug)]
- pub struct MutMutTupleStruct<'a, T, U>(#[pin] &'a mut T, &'a mut U);
+ pub struct Struct<'a, T, U> {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
- #[rustversion::attr(before(1.37), allow(single_use_lifetimes))] // https://github.com/rust-lang/rust/issues/53738
#[pin_project(project_replace)]
#[derive(Debug)]
- pub enum MutMutEnum<'a, T, U> {
+ pub struct TupleStruct<'a, T, U>(#[pin] &'a mut T, &'a mut U);
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U> {
Struct {
#[pin]
pinned: &'a mut T,
@@ -79,9 +522,126 @@ pub mod clippy {
Unit,
}
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<'a, T, U> {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
+
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<'a, T, U>(#[pin] &'a mut T, &'a mut U);
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U> {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Tuple(#[pin] &'a mut T, &'a mut U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+#[allow(unreachable_pub)]
+mod clippy_redundant_pub_crate {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[allow(dead_code)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[allow(dead_code)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod clippy_type_repetition_in_bounds {
+ use pin_project::pin_project;
+
#[pin_project(project_replace)]
#[derive(Debug)]
- pub struct TypeRepetitionInBoundsStruct<T, U>
+ pub struct Struct<T, U>
where
Self: Sized,
{
@@ -92,13 +652,17 @@ pub mod clippy {
#[pin_project(project_replace)]
#[derive(Debug)]
- pub struct TypeRepetitionInBoundsTupleStruct<T, U>(#[pin] T, U)
+ pub struct TupleStruct<T, U>(#[pin] T, U)
where
Self: Sized;
- #[pin_project(project_replace)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
#[derive(Debug)]
- pub enum TypeRepetitionInBoundsEnum<T, U>
+ pub enum Enum<T, U>
where
Self: Sized,
{
@@ -111,38 +675,149 @@ pub mod clippy {
Unit,
}
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<T, U>
+ where
+ Self: Sized,
+ {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct TupleStruct<T, U>(#[pin] T, U)
+ where
+ Self: Sized;
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<T, U>
+ where
+ Self: Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod clippy_used_underscore_binding {
+ use pin_project::pin_project;
+
#[pin_project(project_replace)]
#[derive(Debug)]
- pub struct UsedUnderscoreBindingStruct<T, U> {
+ pub struct Struct<T, U> {
#[pin]
pub _pinned: T,
pub _unpinned: U,
}
- #[pin_project(project_replace)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
#[derive(Debug)]
- pub enum UsedUnderscoreBindingEnum<T, U> {
+ pub enum Enum<T, U> {
Struct {
#[pin]
_pinned: T,
_unpinned: U,
},
}
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub _pinned: T,
+ pub _unpinned: U,
+ }
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ _pinned: T,
+ _unpinned: U,
+ },
+ }
+ };
+ }
+
+ mac!();
+ }
}
+#[cfg(not(miri))]
#[allow(box_pointers)]
+#[allow(clippy::restriction)]
#[rustversion::attr(not(nightly), ignore)]
#[test]
fn check_lint_list() {
- use std::{env, process::Command, str};
+ use std::{env, fs, path::PathBuf, process::Command, str};
- (|| -> Result<(), Box<dyn std::error::Error>> {
- let current = include_str!("lint.txt");
+ type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
+
+ fn assert_eq(expected_path: &str, actual: &str) -> Result<()> {
+ let manifest_dir = env::var_os("CARGO_MANIFEST_DIR")
+ .map(PathBuf::from)
+ .expect("CARGO_MANIFEST_DIR not set");
+ let expected_path = manifest_dir.join(expected_path);
+ let expected = fs::read_to_string(&expected_path)?;
+ if expected != actual {
+ if env::var_os("CI").map_or(false, |v| v == "true") {
+ panic!(
+ "assertion failed:\n\nEXPECTED:\n{0}\n{1}\n{0}\n\nACTUAL:\n{0}\n{2}\n{0}\n",
+ "-".repeat(60),
+ expected,
+ actual,
+ );
+ } else {
+ fs::write(&expected_path, actual)?;
+ }
+ }
+ Ok(())
+ }
+
+ (|| -> Result<()> {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
let output = Command::new(rustc).args(&["-W", "help"]).output()?;
let new = str::from_utf8(&output.stdout)?;
- assert_eq!(current, new);
- Ok(())
+ assert_eq("tests/lint.txt", new)
})()
.unwrap_or_else(|e| panic!("{}", e));
}
diff --git a/tests/lint.txt b/tests/lint.txt
index 4205786..e4c9f98 100644
--- a/tests/lint.txt
+++ b/tests/lint.txt
@@ -16,7 +16,7 @@ Lint checks provided by rustc:
deprecated-in-future allow detects use of items that will be deprecated in a future version
elided-lifetimes-in-paths allow hidden lifetime parameters in types are deprecated
explicit-outlives-requirements allow outlives requirements can be inferred
- indirect-structural-match allow pattern with const indirectly referencing non-structural-match type
+ invalid-html-tags allow detects invalid HTML tags in doc comments
keyword-idents allow detects edition keywords being used as an identifier
macro-use-extern-crate allow the `#[macro_use]` attribute is now deprecated in favor of using macros via the module system
meta-variable-misuse allow possible meta-variable misuse at macro definition
@@ -26,6 +26,7 @@ Lint checks provided by rustc:
missing-docs allow detects missing documentation for public members
missing-doc-code-examples allow detects publicly-exported items without code samples in their documentation
non-ascii-idents allow detects non-ASCII identifiers
+ pointer-structural-match allow pointers are not structural-match
private-doc-tests allow detects code samples in docs of private items not documented by rustdoc
single-use-lifetimes allow detects lifetime parameters that are only used once
trivial-casts allow detects trivial casts which could be removed
@@ -46,26 +47,31 @@ Lint checks provided by rustc:
asm-sub-register warn using only a subset of a register for inline asm inputs
bare-trait-objects warn suggest using `dyn Trait` for trait objects
bindings-with-variant-name warn detects pattern bindings with the same name as one of the matched variants
+ broken-intra-doc-links warn failures in resolving intra-doc link targets
cenum-impl-drop-cast warn a C-like enum implementing Drop is cast
clashing-extern-declarations warn detects when an extern fn has been declared with the same name but different types
coherence-leak-check warn distinct impls distinguished only by the leak-check code
confusable-idents warn detects visually confusable pairs between identifiers
+ const-evaluatable-unchecked warn detects a generic constant is used in a type without a emitting a warning
+ const-item-mutation warn detects attempts to mutate a `const` item
dead-code warn detect unused, unexported items
deprecated warn detects use of deprecated items
+ drop-bounds warn bounds of the form `T: Drop` are useless
ellipsis-inclusive-range-patterns warn `...` range patterns are deprecated
exported-private-dependencies warn public interface leaks type from a private dependency
illegal-floating-point-literal-pattern warn floating-point literals cannot be used in patterns
improper-ctypes warn proper use of libc types in foreign modules
improper-ctypes-definitions warn proper use of libc types in foreign item definitions
incomplete-features warn incomplete features that may function improperly in some or all cases
+ indirect-structural-match warn constant used in pattern contains value of non-structural-match type in a field or a variant
inline-no-sanitize warn detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`
- intra-doc-link-resolution-failure warn failures in resolving intra-doc link targets
invalid-codeblock-attributes warn codeblock attribute looks a lot like a known one
invalid-value warn an invalid value is being created (such as a NULL reference)
irrefutable-let-patterns warn detects irrefutable patterns in if-let and while-let statements
late-bound-lifetime-arguments warn detects generic lifetime arguments in path segments with late bound lifetime parameters
mixed-script-confusables warn detects Unicode scripts whose mixed script confusables codepoints are solely used
mutable-borrow-reservation-conflict warn reservation of a two-phased borrow conflicts with other shared borrows
+ nontrivial-structural-match warn constant used in pattern of non-structural-match type and the constant's initializer expression contains values of non-structural-match types
non-camel-case-types warn types, variants, traits and type parameters should have camel case names
non-shorthand-field-patterns warn using `Struct { x: x }` instead of `Struct { x }` in a pattern
non-snake-case warn variables, methods, functions, lifetime parameters and modules should have snake case names
@@ -115,7 +121,6 @@ Lint checks provided by rustc:
incomplete-include deny trailing content in included file
invalid-type-param-default deny type parameter default erroneously allowed in invalid location
macro-expanded-macro-exports-accessed-by-absolute-paths deny macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
- missing-fragment-specifier deny detects missing fragment specifiers in unused `macro_rules!` patterns
mutable-transmutes deny mutating transmuted &mut T from &T may cause undefined behavior
no-mangle-const-items deny const items will not have their symbols exported
order-dependent-trait-objects deny trait-object types were treated as different depending on marker-trait order
@@ -132,11 +137,11 @@ Lint groups provided by rustc:
name sub-lints
---- ---------
warnings all lints that are set to issue warnings
- future-incompatible keyword-idents, anonymous-parameters, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, safe-packed-borrows, patterns-in-fns-without-body, missing-fragment-specifier, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, soft-unstable, cenum-impl-drop-cast, array-into-iter
+ future-incompatible keyword-idents, anonymous-parameters, illegal-floating-point-literal-pattern, private-in-public, pub-use-of-private-extern-crate, invalid-type-param-default, safe-packed-borrows, patterns-in-fns-without-body, late-bound-lifetime-arguments, order-dependent-trait-objects, coherence-leak-check, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate, unstable-name-collisions, where-clauses-object-safety, proc-macro-derive-resolution-fallback, macro-expanded-macro-exports-accessed-by-absolute-paths, ill-formed-attribute-input, conflicting-repr-hints, ambiguous-associated-items, mutable-borrow-reservation-conflict, indirect-structural-match, pointer-structural-match, nontrivial-structural-match, soft-unstable, cenum-impl-drop-cast, const-evaluatable-unchecked, array-into-iter
nonstandard-style non-camel-case-types, non-snake-case, non-upper-case-globals
rust-2018-compatibility keyword-idents, anonymous-parameters, tyvar-behind-raw-pointer, absolute-paths-not-starting-with-crate
rust-2018-idioms bare-trait-objects, unused-extern-crates, ellipsis-inclusive-range-patterns, elided-lifetimes-in-paths, explicit-outlives-requirements
- rustdoc intra-doc-link-resolution-failure, invalid-codeblock-attributes, missing-doc-code-examples, private-doc-tests
+ rustdoc broken-intra-doc-links, private-intra-doc-links, invalid-codeblock-attributes, missing-doc-code-examples, private-doc-tests, invalid-html-tags
unused unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unreachable-patterns, overlapping-patterns, unused-must-use, unused-unsafe, path-statements, unused-attributes, unused-macros, unused-allocation, unused-doc-comments, unused-extern-crates, unused-features, unused-labels, unused-parens, unused-braces, redundant-semicolons
diff --git a/tests/pin_project.rs b/tests/pin_project.rs
index 766887f..d9c37e5 100644
--- a/tests/pin_project.rs
+++ b/tests/pin_project.rs
@@ -1,9 +1,13 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
+#[macro_use]
+mod auxiliary;
+
use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
use std::{
marker::{PhantomData, PhantomPinned},
+ panic,
pin::Pin,
};
@@ -16,41 +20,39 @@ fn projection() {
)]
struct Struct<T, U> {
#[pin]
- field1: T,
- field2: U,
+ f1: T,
+ f2: U,
}
- let mut s = Struct { field1: 1, field2: 2 };
+ let mut s = Struct { f1: 1, f2: 2 };
let mut s_orig = Pin::new(&mut s);
let s = s_orig.as_mut().project();
- let x: Pin<&mut i32> = s.field1;
+ let x: Pin<&mut i32> = s.f1;
assert_eq!(*x, 1);
-
- let y: &mut i32 = s.field2;
+ let y: &mut i32 = s.f2;
assert_eq!(*y, 2);
- assert_eq!(s_orig.as_ref().field1, 1);
- assert_eq!(s_orig.as_ref().field2, 2);
+ assert_eq!(s_orig.as_ref().f1, 1);
+ assert_eq!(s_orig.as_ref().f2, 2);
- let mut s = Struct { field1: 1, field2: 2 };
+ let mut s = Struct { f1: 1, f2: 2 };
- let StructProj { field1, field2 } = Pin::new(&mut s).project();
- let _: Pin<&mut i32> = field1;
- let _: &mut i32 = field2;
+ let StructProj { f1, f2 } = Pin::new(&mut s).project();
+ let _: Pin<&mut i32> = f1;
+ let _: &mut i32 = f2;
- let StructProjRef { field1, field2 } = Pin::new(&s).project_ref();
- let _: Pin<&i32> = field1;
- let _: &i32 = field2;
+ let StructProjRef { f1, f2 } = Pin::new(&s).project_ref();
+ let _: Pin<&i32> = f1;
+ let _: &i32 = f2;
let mut s = Pin::new(&mut s);
- let StructProjOwn { field1, field2 } =
- s.as_mut().project_replace(Struct { field1: 3, field2: 4 });
- let _: PhantomData<i32> = field1;
- let _: i32 = field2;
- assert_eq!(field2, 2);
- assert_eq!(s.field1, 3);
- assert_eq!(s.field2, 4);
+ let StructProjOwn { f1, f2 } = s.as_mut().project_replace(Struct { f1: 3, f2: 4 });
+ let _: PhantomData<i32> = f1;
+ let _: i32 = f2;
+ assert_eq!(f2, 2);
+ assert_eq!(s.f1, 3);
+ assert_eq!(s.f2, 4);
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
@@ -60,92 +62,88 @@ fn projection() {
let x: Pin<&mut i32> = s.0;
assert_eq!(*x, 1);
-
let y: &mut i32 = s.1;
assert_eq!(*y, 2);
- #[pin_project(project_replace, project = EnumProj)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
#[derive(Eq, PartialEq, Debug)]
enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
+ Tuple(#[pin] A, B),
+ Struct {
#[pin]
- field1: C,
- field2: D,
+ f1: C,
+ f2: D,
},
- None,
+ Unit,
}
- let mut e = Enum::Variant1(1, 2);
+ let mut e = Enum::Tuple(1, 2);
let mut e_orig = Pin::new(&mut e);
let e = e_orig.as_mut().project();
match e {
- EnumProj::Variant1(x, y) => {
+ EnumProj::Tuple(x, y) => {
let x: Pin<&mut i32> = x;
assert_eq!(*x, 1);
-
let y: &mut i32 = y;
assert_eq!(*y, 2);
}
- EnumProj::Variant2 { field1, field2 } => {
- let _x: Pin<&mut i32> = field1;
- let _y: &mut i32 = field2;
+ EnumProj::Struct { f1, f2 } => {
+ let _: Pin<&mut i32> = f1;
+ let _: &mut i32 = f2;
}
- EnumProj::None => {}
+ EnumProj::Unit => {}
}
- assert_eq!(Pin::into_ref(e_orig).get_ref(), &Enum::Variant1(1, 2));
+ assert_eq!(Pin::into_ref(e_orig).get_ref(), &Enum::Tuple(1, 2));
- let mut e = Enum::Variant2 { field1: 3, field2: 4 };
+ let mut e = Enum::Struct { f1: 3, f2: 4 };
let mut e = Pin::new(&mut e).project();
match &mut e {
- EnumProj::Variant1(x, y) => {
- let _x: &mut Pin<&mut i32> = x;
- let _y: &mut &mut i32 = y;
+ EnumProj::Tuple(x, y) => {
+ let _: &mut Pin<&mut i32> = x;
+ let _: &mut &mut i32 = y;
}
- EnumProj::Variant2 { field1, field2 } => {
- let x: &mut Pin<&mut i32> = field1;
+ EnumProj::Struct { f1, f2 } => {
+ let x: &mut Pin<&mut i32> = f1;
assert_eq!(**x, 3);
-
- let y: &mut &mut i32 = field2;
+ let y: &mut &mut i32 = f2;
assert_eq!(**y, 4);
}
- EnumProj::None => {}
+ EnumProj::Unit => {}
}
- if let EnumProj::Variant2 { field1, field2 } = e {
- let x: Pin<&mut i32> = field1;
+ if let EnumProj::Struct { f1, f2 } = e {
+ let x: Pin<&mut i32> = f1;
assert_eq!(*x, 3);
-
- let y: &mut i32 = field2;
+ let y: &mut i32 = f2;
assert_eq!(*y, 4);
}
}
#[test]
fn enum_project_set() {
- #[pin_project(project_replace, project = EnumProj)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
#[derive(Eq, PartialEq, Debug)]
enum Enum {
- Variant1(#[pin] u8),
- Variant2(bool),
+ V1(#[pin] u8),
+ V2(bool),
}
- let mut e = Enum::Variant1(25);
+ let mut e = Enum::V1(25);
let mut e_orig = Pin::new(&mut e);
let e_proj = e_orig.as_mut().project();
match e_proj {
- EnumProj::Variant1(val) => {
- let new_e = Enum::Variant2(val.as_ref().get_ref() == &25);
+ EnumProj::V1(val) => {
+ let new_e = Enum::V2(val.as_ref().get_ref() == &25);
e_orig.set(new_e);
}
_ => unreachable!(),
}
- assert_eq!(e, Enum::Variant2(true));
+ assert_eq!(e, Enum::V2(true));
}
#[test]
@@ -155,7 +153,7 @@ fn where_clause() {
where
T: Copy,
{
- field: T,
+ f: T,
}
#[pin_project]
@@ -163,12 +161,12 @@ fn where_clause() {
where
T: Copy;
- #[pin_project]
- enum EnumWhere<T>
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum<T>
where
T: Copy,
{
- Variant(T),
+ V(T),
}
}
@@ -180,8 +178,8 @@ fn where_clause_and_associated_type_field() {
I: Iterator,
{
#[pin]
- field1: I,
- field2: I::Item,
+ f1: I,
+ f2: I::Item,
}
#[pin_project(project_replace)]
@@ -190,8 +188,8 @@ fn where_clause_and_associated_type_field() {
I: Iterator<Item = J>,
{
#[pin]
- field1: I,
- field2: J,
+ f1: I,
+ f2: J,
}
#[pin_project(project_replace)]
@@ -199,7 +197,7 @@ fn where_clause_and_associated_type_field() {
where
T: 'static,
{
- field: T,
+ f: T,
}
trait Static: 'static {}
@@ -211,13 +209,13 @@ fn where_clause_and_associated_type_field() {
where
I: Iterator;
- #[pin_project(project_replace)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<I>
where
I: Iterator,
{
- Variant1(#[pin] I),
- Variant2(I::Item),
+ V1(#[pin] I),
+ V2(I::Item),
}
}
@@ -226,7 +224,7 @@ fn derive_copy() {
#[pin_project(project_replace)]
#[derive(Clone, Copy)]
struct Struct<T> {
- val: T,
+ f: T,
}
fn is_copy<T: Copy>() {}
@@ -240,21 +238,21 @@ fn move_out() {
#[pin_project(project_replace)]
struct Struct {
- val: NotCopy,
+ f: NotCopy,
}
- let x = Struct { val: NotCopy };
- let _val: NotCopy = x.val;
+ let x = Struct { f: NotCopy };
+ let _val: NotCopy = x.f;
- #[pin_project(project_replace)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum {
- Variant(NotCopy),
+ V(NotCopy),
}
- let x = Enum::Variant(NotCopy);
+ let x = Enum::V(NotCopy);
#[allow(clippy::infallible_destructuring_match)]
let _val: NotCopy = match x {
- Enum::Variant(val) => val,
+ Enum::V(val) => val,
};
}
@@ -262,39 +260,39 @@ fn move_out() {
fn trait_bounds_on_type_generics() {
#[pin_project(project_replace)]
pub struct Struct1<'a, T: ?Sized> {
- field: &'a mut T,
+ f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct2<'a, T: ::core::fmt::Debug> {
- field: &'a mut T,
+ f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct3<'a, T: core::fmt::Debug> {
- field: &'a mut T,
+ f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct4<'a, T: core::fmt::Debug + core::fmt::Display> {
- field: &'a mut T,
+ f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct5<'a, T: core::fmt::Debug + ?Sized> {
- field: &'a mut T,
+ f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct6<'a, T: core::fmt::Debug = [u8; 16]> {
- field: &'a mut T,
+ f: &'a mut T,
}
- let _: Struct6<'_> = Struct6 { field: &mut [0u8; 16] };
+ let _: Struct6<'_> = Struct6 { f: &mut [0u8; 16] };
#[pin_project(project_replace)]
pub struct Struct7<T: 'static> {
- field: T,
+ f: T,
}
trait Static: 'static {}
@@ -303,16 +301,16 @@ fn trait_bounds_on_type_generics() {
#[pin_project(project_replace)]
pub struct Struct8<'a, 'b: 'a> {
- field1: &'a u8,
- field2: &'b u8,
+ f1: &'a u8,
+ f2: &'b u8,
}
#[pin_project(project_replace)]
pub struct TupleStruct<'a, T: ?Sized>(&'a mut T);
- #[pin_project(project_replace)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<'a, T: ?Sized> {
- Variant(&'a mut T),
+ V(&'a mut T),
}
}
@@ -321,27 +319,52 @@ fn overlapping_lifetime_names() {
#[pin_project(project_replace)]
pub struct Struct1<'pin, T> {
#[pin]
- field: &'pin mut T,
+ f: &'pin mut T,
}
#[pin_project(project_replace)]
pub struct Struct2<'pin, 'pin_, 'pin__> {
#[pin]
- field: &'pin &'pin_ &'pin__ (),
+ f: &'pin &'pin_ &'pin__ (),
}
- pub trait A<'a> {}
+ pub trait Trait<'a> {}
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#[pin_project(project_replace)]
pub struct HRTB<'pin___, T>
where
for<'pin> &'pin T: Unpin,
- T: for<'pin> A<'pin>,
+ T: for<'pin> Trait<'pin>,
for<'pin, 'pin_, 'pin__> &'pin &'pin_ &'pin__ T: Unpin,
{
#[pin]
- field: &'pin___ mut T,
+ f: &'pin___ mut T,
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct PinnedDropStruct<'pin> {
+ #[pin]
+ f: &'pin (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for PinnedDropStruct<'_> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(UnsafeUnpin)]
+ pub struct UnsafeUnpinStruct<'pin> {
+ #[pin]
+ f: &'pin (),
+ }
+
+ unsafe impl UnsafeUnpin for UnsafeUnpinStruct<'_> {}
+
+ #[pin_project(!Unpin)]
+ pub struct NotUnpinStruct<'pin> {
+ #[pin]
+ f: &'pin (),
}
}
@@ -350,7 +373,7 @@ fn combine() {
#[pin_project(PinnedDrop, UnsafeUnpin)]
pub struct PinnedDropWithUnsafeUnpin<T> {
#[pin]
- field: T,
+ f: T,
}
#[pinned_drop]
@@ -363,7 +386,7 @@ fn combine() {
#[pin_project(PinnedDrop, !Unpin)]
pub struct PinnedDropWithNotUnpin<T> {
#[pin]
- field: T,
+ f: T,
}
#[pinned_drop]
@@ -374,7 +397,7 @@ fn combine() {
#[pin_project(UnsafeUnpin, project_replace)]
pub struct UnsafeUnpinWithReplace<T> {
#[pin]
- field: T,
+ f: T,
}
unsafe impl<T: Unpin> UnsafeUnpin for UnsafeUnpinWithReplace<T> {}
@@ -382,7 +405,7 @@ fn combine() {
#[pin_project(!Unpin, project_replace)]
pub struct NotUnpinWithReplace<T> {
#[pin]
- field: T,
+ f: T,
}
}
@@ -397,6 +420,7 @@ fn private_type_in_public_type() {
struct PrivateStruct<T>(T);
}
+#[allow(clippy::needless_lifetimes)]
#[test]
fn lifetime_project() {
#[pin_project(project_replace)]
@@ -413,9 +437,9 @@ fn lifetime_project() {
unpinned: U,
}
- #[pin_project(project_replace, project = EnumProj, project_ref = EnumProjRef)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<T, U> {
- Variant {
+ V {
#[pin]
pinned: T,
unpinned: U,
@@ -429,6 +453,12 @@ fn lifetime_project() {
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
self.project().pinned
}
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
+ self.project().pinned
+ }
}
impl<'b, T, U> Struct2<'b, T, U> {
@@ -438,75 +468,33 @@ fn lifetime_project() {
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut &'b mut T> {
self.project().pinned
}
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&&'b mut T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut &'b mut T> {
+ self.project().pinned
+ }
}
impl<T, U> Enum<T, U> {
fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
match self.project_ref() {
- EnumProjRef::Variant { pinned, .. } => pinned,
+ EnumProjRef::V { pinned, .. } => pinned,
}
}
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
match self.project() {
- EnumProj::Variant { pinned, .. } => pinned,
+ EnumProj::V { pinned, .. } => pinned,
}
}
- }
-}
-
-#[rustversion::since(1.36)] // https://github.com/rust-lang/rust/pull/61207
-#[test]
-fn lifetime_project_elided() {
- #[pin_project(project_replace)]
- struct Struct1<T, U> {
- #[pin]
- pinned: T,
- unpinned: U,
- }
-
- #[pin_project(project_replace)]
- struct Struct2<'a, T, U> {
- #[pin]
- pinned: &'a mut T,
- unpinned: U,
- }
-
- #[pin_project(project_replace, project = EnumProj, project_ref = EnumProjRef)]
- enum Enum<T, U> {
- Variant {
- #[pin]
- pinned: T,
- unpinned: U,
- },
- }
-
- impl<T, U> Struct1<T, U> {
- fn get_pin_ref(self: Pin<&Self>) -> Pin<&T> {
- self.project_ref().pinned
- }
- fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
- self.project().pinned
- }
- }
-
- impl<'b, T, U> Struct2<'b, T, U> {
- fn get_pin_ref(self: Pin<&Self>) -> Pin<&&'b mut T> {
- self.project_ref().pinned
- }
- fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut &'b mut T> {
- self.project().pinned
- }
- }
-
- impl<T, U> Enum<T, U> {
- fn get_pin_ref(self: Pin<&Self>) -> Pin<&T> {
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
match self.project_ref() {
- EnumProjRef::Variant { pinned, .. } => pinned,
+ EnumProjRef::V { pinned, .. } => pinned,
}
}
- fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
match self.project() {
- EnumProj::Variant { pinned, .. } => pinned,
+ EnumProj::V { pinned, .. } => pinned,
}
}
}
@@ -516,19 +504,19 @@ mod visibility {
use pin_project::pin_project;
#[pin_project(project_replace)]
- pub(crate) struct A {
- pub b: u8,
+ pub(crate) struct S {
+ pub f: u8,
}
}
#[test]
fn visibility() {
- let mut x = visibility::A { b: 0 };
+ let mut x = visibility::S { f: 0 };
let x = Pin::new(&mut x);
let y = x.as_ref().project_ref();
- let _: &u8 = y.b;
+ let _: &u8 = y.f;
let y = x.project();
- let _: &mut u8 = y.b;
+ let _: &mut u8 = y.f;
}
#[test]
@@ -536,45 +524,66 @@ fn trivial_bounds() {
#[pin_project(project_replace)]
pub struct NoGenerics {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
+
+ assert_not_unpin!(NoGenerics);
}
#[test]
fn dst() {
#[pin_project]
struct Struct1<T: ?Sized> {
- x: T,
+ f: T,
}
- let mut x = Struct1 { x: 0_u8 };
+ let mut x = Struct1 { f: 0_u8 };
let x: Pin<&mut Struct1<dyn core::fmt::Debug>> = Pin::new(&mut x as _);
- let _y: &mut (dyn core::fmt::Debug) = x.project().x;
+ let _: &mut (dyn core::fmt::Debug) = x.project().f;
#[pin_project]
struct Struct2<T: ?Sized> {
#[pin]
- x: T,
+ f: T,
}
- let mut x = Struct2 { x: 0_u8 };
+ let mut x = Struct2 { f: 0_u8 };
let x: Pin<&mut Struct2<dyn core::fmt::Debug + Unpin>> = Pin::new(&mut x as _);
- let _y: Pin<&mut (dyn core::fmt::Debug + Unpin)> = x.project().x;
+ let _: Pin<&mut (dyn core::fmt::Debug + Unpin)> = x.project().f;
+
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[pin_project]
+ struct Struct3<T>
+ where
+ T: ?Sized,
+ {
+ f: T,
+ }
+
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[pin_project]
+ struct Struct4<T>
+ where
+ T: ?Sized,
+ {
+ #[pin]
+ f: T,
+ }
#[pin_project(UnsafeUnpin)]
struct Struct5<T: ?Sized> {
- x: T,
+ f: T,
}
#[pin_project(UnsafeUnpin)]
struct Struct6<T: ?Sized> {
#[pin]
- x: T,
+ f: T,
}
#[pin_project(PinnedDrop)]
struct Struct7<T: ?Sized> {
- x: T,
+ f: T,
}
#[pinned_drop]
@@ -585,7 +594,7 @@ fn dst() {
#[pin_project(PinnedDrop)]
struct Struct8<T: ?Sized> {
#[pin]
- x: T,
+ f: T,
}
#[pinned_drop]
@@ -595,13 +604,19 @@ fn dst() {
#[pin_project(!Unpin)]
struct Struct9<T: ?Sized> {
- x: T,
+ f: T,
}
#[pin_project(!Unpin)]
struct Struct10<T: ?Sized> {
#[pin]
- x: T,
+ f: T,
+ }
+
+ #[pin_project]
+ struct Struct11<'a, T: ?Sized, U: ?Sized> {
+ f1: &'a mut T,
+ f2: U,
}
#[pin_project]
@@ -610,6 +625,18 @@ fn dst() {
#[pin_project]
struct TupleStruct2<T: ?Sized>(#[pin] T);
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[pin_project]
+ struct TupleStruct3<T>(T)
+ where
+ T: ?Sized;
+
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[pin_project]
+ struct TupleStruct4<T>(#[pin] T)
+ where
+ T: ?Sized;
+
#[pin_project(UnsafeUnpin)]
struct TupleStruct5<T: ?Sized>(T);
@@ -637,37 +664,9 @@ fn dst() {
#[pin_project(!Unpin)]
struct TupleStruct10<T: ?Sized>(#[pin] T);
-}
-#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
-#[test]
-fn unsized_in_where_clause() {
#[pin_project]
- struct Struct3<T>
- where
- T: ?Sized,
- {
- x: T,
- }
-
- #[pin_project]
- struct Struct4<T>
- where
- T: ?Sized,
- {
- #[pin]
- x: T,
- }
-
- #[pin_project]
- struct TupleStruct3<T>(T)
- where
- T: ?Sized;
-
- #[pin_project]
- struct TupleStruct4<T>(#[pin] T)
- where
- T: ?Sized;
+ struct TupleStruct11<'a, T: ?Sized, U: ?Sized>(&'a mut T, U);
}
#[test]
@@ -775,7 +774,7 @@ fn parse_self() {
type Assoc = Self;
}
- #[pin_project(project_replace)]
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum {
Struct {
_f1: Box<Self>,
@@ -809,19 +808,19 @@ fn parse_self() {
#[test]
fn no_infer_outlives() {
- trait Bar<X> {
+ trait Trait<X> {
type Y;
}
- struct Example<A>(A);
+ struct Struct1<A>(A);
- impl<X, T> Bar<X> for Example<T> {
+ impl<X, T> Trait<X> for Struct1<T> {
type Y = Option<T>;
}
#[pin_project(project_replace)]
- struct Foo<A, B> {
- _x: <Example<A> as Bar<B>>::Y,
+ struct Struct2<A, B> {
+ _f: <Struct1<A> as Trait<B>>::Y,
}
}
@@ -830,8 +829,6 @@ fn no_infer_outlives() {
#[allow(clippy::many_single_char_names)]
#[test]
fn project_replace_panic() {
- use std::panic;
-
#[pin_project(project_replace)]
struct S<T, U> {
#[pin]
diff --git a/tests/pinned_drop.rs b/tests/pinned_drop.rs
index e257758..e369ecb 100644
--- a/tests/pinned_drop.rs
+++ b/tests/pinned_drop.rs
@@ -25,62 +25,9 @@ fn safe_project() {
}
#[test]
-fn self_argument_in_macro() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
-
- #[pin_project(PinnedDrop)]
- struct Struct {
- x: (),
- }
-
- #[pinned_drop]
- impl PinnedDrop for Struct {
- fn drop(self: Pin<&mut Self>) {
- let _: Vec<_> = vec![self.x];
- }
- }
-}
-
-#[test]
-fn self_in_macro_containing_fn() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
-
- macro_rules! mac {
- ($($tt:tt)*) => {
- $($tt)*
- };
- }
-
- #[pin_project(PinnedDrop)]
- pub struct Struct {
- _x: (),
- }
-
- #[pinned_drop]
- impl PinnedDrop for Struct {
- fn drop(self: Pin<&mut Self>) {
- let _ = mac!({
- impl Struct {
- pub fn _f(self) -> Self {
- self
- }
- }
- });
- }
- }
-}
-
-#[test]
fn self_call() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
-
#[pin_project(PinnedDrop)]
- pub struct Struct<T> {
- _x: T,
- }
+ pub struct S<T>(T);
trait Trait {
fn self_ref(&self) {}
@@ -90,10 +37,10 @@ fn self_call() {
fn assoc_fn(_this: Pin<&mut Self>) {}
}
- impl<T> Trait for Struct<T> {}
+ impl<T> Trait for S<T> {}
#[pinned_drop]
- impl<T> PinnedDrop for Struct<T> {
+ impl<T> PinnedDrop for S<T> {
fn drop(mut self: Pin<&mut Self>) {
self.self_ref();
self.as_ref().self_pin_ref();
@@ -106,13 +53,10 @@ fn self_call() {
}
#[test]
-fn self_struct() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
-
+fn self_ty() {
#[pin_project(PinnedDrop)]
pub struct Struct {
- pub x: (),
+ pub f: (),
}
#[pinned_drop]
@@ -121,14 +65,14 @@ fn self_struct() {
#[allow(clippy::match_single_binding)]
fn drop(mut self: Pin<&mut Self>) {
// expr
- let _: Self = Self { x: () };
+ let _: Self = Self { f: () };
// pat
match *self {
- Self { x: _ } => {}
+ Self { f: _ } => {}
}
- if let Self { x: _ } = *self {}
- let Self { x: _ } = *self;
+ if let Self { f: _ } = *self {}
+ let Self { f: _ } = *self;
}
}
@@ -150,56 +94,74 @@ fn self_struct() {
let Self(_) = *self;
}
}
-}
-
-#[rustversion::since(1.37)] // type_alias_enum_variants requires Rust 1.37
-#[test]
-fn self_enum() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
- #[pin_project(PinnedDrop)]
+ #[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
pub enum Enum {
- Struct { x: () },
+ Struct { f: () },
Tuple(()),
+ Unit,
}
#[pinned_drop]
impl PinnedDrop for Enum {
fn drop(mut self: Pin<&mut Self>) {
// expr
- let _: Self = Self::Struct { x: () };
+ let _: Self = Self::Struct { f: () };
let _: Self = Self::Tuple(());
+ let _: Self = Self::Unit;
// pat
match *self {
- Self::Struct { x: _ } => {}
+ Self::Struct { f: _ } => {}
Self::Tuple(_) => {}
+ Self::Unit => {}
}
- if let Self::Struct { x: _ } = *self {}
+ if let Self::Struct { f: _ } = *self {}
if let Self::Tuple(_) = *self {}
+ if let Self::Unit = *self {}
}
}
}
-// See also `ui/pinned_drop/self.rs`.
-#[rustversion::since(1.40)] // https://github.com/rust-lang/rust/pull/64690
#[test]
-fn self_in_macro_def() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
+fn self_inside_macro_containing_fn() {
+ macro_rules! mac {
+ ($($tt:tt)*) => {
+ $($tt)*
+ };
+ }
#[pin_project(PinnedDrop)]
- pub struct Struct {
- _x: (),
+ pub struct S(());
+
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ let _ = mac!({
+ impl S {
+ pub fn _f(self) -> Self {
+ self
+ }
+ }
+ });
+ }
}
+}
+
+// See also `ui/pinned_drop/self.rs`.
+#[rustversion::since(1.40)] // https://github.com/rust-lang/rust/pull/64690
+#[test]
+fn self_inside_macro_def() {
+ #[pin_project(PinnedDrop)]
+ pub struct S(());
#[pinned_drop]
- impl PinnedDrop for Struct {
+ impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
macro_rules! mac {
() => {{
let _ = self;
+ let _ = Self(());
}};
}
mac!();
@@ -208,10 +170,22 @@ fn self_in_macro_def() {
}
#[test]
-fn self_inside_macro() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
+fn self_arg_inside_macro_call() {
+ #[pin_project(PinnedDrop)]
+ struct Struct {
+ f: (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Struct {
+ fn drop(self: Pin<&mut Self>) {
+ let _: Vec<_> = vec![self.f];
+ }
+ }
+}
+#[test]
+fn self_ty_inside_macro_call() {
macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
@@ -223,24 +197,24 @@ fn self_inside_macro() {
where
mac!(Self): Send,
{
- _x: T,
+ _f: T,
}
impl<T: Send> Struct<T> {
- const ASSOCIATED1: &'static str = "1";
- fn associated1() {}
+ const ASSOC1: &'static str = "1";
+ fn assoc1() {}
}
trait Trait {
- type Associated2;
- const ASSOCIATED2: &'static str;
- fn associated2();
+ type Assoc2;
+ const ASSOC2: &'static str;
+ fn assoc2();
}
impl<T: Send> Trait for Struct<T> {
- type Associated2 = ();
- const ASSOCIATED2: &'static str = "2";
- fn associated2() {}
+ type Assoc2 = ();
+ const ASSOC2: &'static str = "2";
+ fn assoc2() {}
}
#[pinned_drop]
@@ -252,38 +226,34 @@ fn self_inside_macro() {
#[allow(clippy::no_effect)]
fn drop(self: Pin<&mut Self>) {
// inherent items
- mac!(Self::ASSOCIATED1;);
- mac!(<Self>::ASSOCIATED1;);
- mac!(Self::associated1(););
- mac!(<Self>::associated1(););
+ mac!(Self::ASSOC1;);
+ mac!(<Self>::ASSOC1;);
+ mac!(Self::assoc1(););
+ mac!(<Self>::assoc1(););
// trait items
- mac!(let _: <Self as Trait>::Associated2;);
- mac!(Self::ASSOCIATED2;);
- mac!(<Self>::ASSOCIATED2;);
- mac!(<Self as Trait>::ASSOCIATED2;);
- mac!(Self::associated2(););
- mac!(<Self>::associated2(););
- mac!(<Self as Trait>::associated2(););
+ mac!(let _: <Self as Trait>::Assoc2;);
+ mac!(Self::ASSOC2;);
+ mac!(<Self>::ASSOC2;);
+ mac!(<Self as Trait>::ASSOC2;);
+ mac!(Self::assoc2(););
+ mac!(<Self>::assoc2(););
+ mac!(<Self as Trait>::assoc2(););
}
}
}
#[test]
fn inside_macro() {
- use pin_project::{pin_project, pinned_drop};
- use std::pin::Pin;
-
#[pin_project(PinnedDrop)]
- struct Struct(());
+ struct S(());
macro_rules! mac {
($expr:expr) => {
#[pinned_drop]
- impl PinnedDrop for Struct {
- #[allow(clippy::no_effect)]
+ impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
- $expr;
+ let _ = $expr;
}
}
};
diff --git a/tests/project.rs b/tests/project.rs
deleted file mode 100644
index 78a9261..0000000
--- a/tests/project.rs
+++ /dev/null
@@ -1,298 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
-#![allow(deprecated)]
-
-// Ceurrently, `#[attr] if true {}` doesn't even *parse* on MSRV,
-// which means that it will error even behind a `#[rustversion::since(..)]`
-//
-// This trick makes sure that we don't even attempt to parse
-// the `#[project] if let _` test on MSRV.
-#[rustversion::since(1.43)]
-include!("project_if_attr.rs.in");
-
-use pin_project::{pin_project, project, project_ref, project_replace};
-use std::pin::Pin;
-
-#[project] // Nightly does not need a dummy attribute to the function.
-#[test]
-fn project_stmt_expr() {
- #[pin_project]
- struct Struct<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- let mut s = Struct { field1: 1, field2: 2 };
-
- #[project]
- let Struct { field1, field2 } = Pin::new(&mut s).project();
-
- let x: Pin<&mut i32> = field1;
- assert_eq!(*x, 1);
-
- let y: &mut i32 = field2;
- assert_eq!(*y, 2);
-
- #[pin_project]
- struct TupleStruct<T, U>(#[pin] T, U);
-
- let mut s = TupleStruct(1, 2);
-
- #[project]
- let TupleStruct(x, y) = Pin::new(&mut s).project();
-
- let x: Pin<&mut i32> = x;
- assert_eq!(*x, 1);
-
- let y: &mut i32 = y;
- assert_eq!(*y, 2);
-
- #[pin_project]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut e = Enum::Variant1(1, 2);
-
- let mut e = Pin::new(&mut e).project();
-
- #[project]
- match &mut e {
- Enum::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- Enum::None => {}
- }
-
- #[project]
- let val = match &mut e {
- Enum::Variant1(_, _) => true,
- Enum::Variant2 { .. } => false,
- Enum::None => false,
- };
- assert_eq!(val, true);
-}
-
-#[test]
-fn project_impl() {
- #[pin_project]
- struct HasGenerics<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- #[project]
- impl<T, U> HasGenerics<T, U> {
- fn a(self) {
- let Self { field1, field2 } = self;
-
- let _x: Pin<&mut T> = field1;
- let _y: &mut U = field2;
- }
- }
-
- #[pin_project]
- struct NoneGenerics {
- #[pin]
- field1: i32,
- field2: u32,
- }
-
- #[project]
- impl NoneGenerics {}
-
- #[pin_project]
- struct HasLifetimes<'a, T, U> {
- #[pin]
- field1: &'a mut T,
- field2: U,
- }
-
- #[project]
- impl<T, U> HasLifetimes<'_, T, U> {}
-
- #[pin_project]
- struct HasOverlappingLifetimes<'pin, T, U> {
- #[pin]
- field1: &'pin mut T,
- field2: U,
- }
-
- #[allow(single_use_lifetimes)]
- #[project]
- impl<'pin, T, U> HasOverlappingLifetimes<'pin, T, U> {}
-
- #[pin_project]
- struct HasOverlappingLifetimes2<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- #[allow(single_use_lifetimes)]
- #[allow(clippy::needless_lifetimes)]
- #[project]
- impl<T, U> HasOverlappingLifetimes2<T, U> {
- fn foo<'pin>(&'pin self) {}
- }
-}
-
-#[pin_project]
-struct A {
- #[pin]
- field: u8,
-}
-
-mod project_use_1 {
- use crate::A;
- use pin_project::project;
- use std::pin::Pin;
-
- #[project]
- use crate::A;
-
- #[project]
- #[test]
- fn project_use() {
- let mut x = A { field: 0 };
- #[project]
- let A { field } = Pin::new(&mut x).project();
- let _: Pin<&mut u8> = field;
- }
-}
-
-mod project_use_2 {
- #[project]
- use crate::A;
- use pin_project::project;
-
- #[project]
- impl A {
- fn project_use(self) {}
- }
-}
-
-#[allow(clippy::unnecessary_operation, clippy::unit_arg)]
-#[test]
-#[project]
-fn non_stmt_expr_match() {
- #[pin_project]
- enum Enum<A> {
- Variant(#[pin] A),
- }
-
- let mut x = Enum::Variant(1);
- let x = Pin::new(&mut x).project();
-
- Some(
- #[project]
- match x {
- Enum::Variant(_x) => {}
- },
- );
-}
-
-// https://github.com/taiki-e/pin-project/issues/206
-#[allow(clippy::unnecessary_operation, clippy::unit_arg)]
-#[test]
-#[project]
-fn issue_206() {
- #[pin_project]
- enum Enum<A> {
- Variant(#[pin] A),
- }
-
- let mut x = Enum::Variant(1);
- let x = Pin::new(&mut x).project();
-
- Some({
- #[project]
- match &x {
- Enum::Variant(_) => {}
- }
- });
-
- #[allow(clippy::never_loop)]
- loop {
- let _ = {
- #[project]
- match &x {
- Enum::Variant(_) => {}
- }
- };
- break;
- }
-}
-
-#[project]
-#[test]
-fn combine() {
- #[pin_project(project_replace)]
- enum Enum<A> {
- V1(#[pin] A),
- V2,
- }
-
- let mut x = Enum::V1(1);
- #[project]
- match Pin::new(&mut x).project() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_ref]
- match Pin::new(&x).project_ref() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_replace]
- match Pin::new(&mut x).project_replace(Enum::V2) {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
-}
-
-// FIXME: This should be denied, but allowed for compatibility at this time.
-#[project]
-#[project_ref]
-#[project_replace]
-#[test]
-fn combine_compat() {
- #[pin_project(project_replace)]
- enum Enum<A> {
- V1(#[pin] A),
- V2,
- }
-
- let mut x = Enum::V1(1);
- #[project]
- match Pin::new(&mut x).project() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_ref]
- match Pin::new(&x).project_ref() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_replace]
- match Pin::new(&mut x).project_replace(Enum::V2) {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
-}
diff --git a/tests/project_if_attr.rs.in b/tests/project_if_attr.rs.in
deleted file mode 100644
index 7bc236d..0000000
--- a/tests/project_if_attr.rs.in
+++ /dev/null
@@ -1,45 +0,0 @@
-#[test]
-#[project]
-fn project_if_let() {
- #[pin_project]
- enum Foo<A, B> {
- Variant1(#[pin] A),
- Variant2(u8),
- Variant3 {
- #[pin]
- field: B,
- },
- }
-
- let mut x: Foo<bool, f32> = Foo::Variant1(true);
- let x = Pin::new(&mut x).project();
-
- #[project]
- if let Foo::Variant1(a) = x {
- let a: Pin<&mut bool> = a;
- assert_eq!(*a, true);
- } else if let Foo::Variant2(_) = x {
- unreachable!();
- } else if let Foo::Variant3 { .. } = x {
- unreachable!();
- }
-}
-
-#[allow(clippy::unnecessary_operation, clippy::unit_arg)]
-#[test]
-#[project]
-fn non_stmt_expr_if_let() {
- #[pin_project]
- enum Enum<A> {
- Variant(#[pin] A),
- }
-
- let mut x = Enum::Variant(1);
- let x = Pin::new(&mut x).project();
-
- #[allow(irrefutable_let_patterns)]
- Some(
- #[project]
- if let Enum::Variant(_x) = x {},
- );
-}
diff --git a/tests/project_ref.rs b/tests/project_ref.rs
deleted file mode 100644
index 0e8ebd9..0000000
--- a/tests/project_ref.rs
+++ /dev/null
@@ -1,175 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
-#![allow(deprecated)]
-
-use pin_project::{pin_project, project_ref};
-use std::pin::Pin;
-
-#[project_ref] // Nightly does not need a dummy attribute to the function.
-#[test]
-fn project_stmt_expr() {
- #[pin_project]
- struct Struct<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- let s = Struct { field1: 1, field2: 2 };
-
- #[project_ref]
- let Struct { field1, field2 } = Pin::new(&s).project_ref();
-
- let x: Pin<&i32> = field1;
- assert_eq!(*x, 1);
-
- let y: &i32 = field2;
- assert_eq!(*y, 2);
-
- // tuple struct
-
- #[pin_project]
- struct TupleStruct<T, U>(#[pin] T, U);
-
- let s = TupleStruct(1, 2);
-
- #[project_ref]
- let TupleStruct(x, y) = Pin::new(&s).project_ref();
-
- let x: Pin<&i32> = x;
- assert_eq!(*x, 1);
-
- let y: &i32 = y;
- assert_eq!(*y, 2);
-
- #[pin_project]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let e = Enum::Variant1(1, 2);
-
- let e = Pin::new(&e).project_ref();
-
- #[project_ref]
- match &e {
- Enum::Variant1(x, y) => {
- let x: &Pin<&i32> = x;
- assert_eq!(**x, 1);
-
- let y: &&i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &Pin<&i32> = field1;
- let _y: &&i32 = field2;
- }
- Enum::None => {}
- }
-
- #[project_ref]
- let val = match &e {
- Enum::Variant1(_, _) => true,
- Enum::Variant2 { .. } => false,
- Enum::None => false,
- };
- assert_eq!(val, true);
-}
-
-#[test]
-fn project_impl() {
- #[pin_project]
- struct HasGenerics<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- #[project_ref]
- impl<T, U> HasGenerics<T, U> {
- fn a(self) {
- let Self { field1, field2 } = self;
-
- let _x: Pin<&T> = field1;
- let _y: &U = field2;
- }
- }
-
- #[pin_project]
- struct NoneGenerics {
- #[pin]
- field1: i32,
- field2: u32,
- }
-
- #[project_ref]
- impl NoneGenerics {}
-
- #[pin_project]
- struct HasLifetimes<'a, T, U> {
- #[pin]
- field1: &'a mut T,
- field2: U,
- }
-
- #[project_ref]
- impl<T, U> HasLifetimes<'_, T, U> {}
-
- #[pin_project]
- struct HasOverlappingLifetimes<'pin, T, U> {
- #[pin]
- field1: &'pin mut T,
- field2: U,
- }
-
- #[allow(single_use_lifetimes)]
- #[project_ref]
- impl<'pin, T, U> HasOverlappingLifetimes<'pin, T, U> {}
-
- #[pin_project]
- struct HasOverlappingLifetimes2<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- #[allow(single_use_lifetimes)]
- #[allow(clippy::needless_lifetimes)]
- #[project_ref]
- impl<T, U> HasOverlappingLifetimes2<T, U> {
- fn foo<'pin>(&'pin self) {}
- }
-}
-
-#[project_ref]
-#[test]
-fn combine() {
- #[pin_project(project_replace)]
- enum Enum<A> {
- V1(#[pin] A),
- V2,
- }
-
- let mut x = Enum::V1(1);
- #[project]
- match Pin::new(&mut x).project() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_ref]
- match Pin::new(&x).project_ref() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_replace]
- match Pin::new(&mut x).project_replace(Enum::V2) {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
-}
diff --git a/tests/project_replace.rs b/tests/project_replace.rs
deleted file mode 100644
index a97e3af..0000000
--- a/tests/project_replace.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
-#![allow(deprecated)]
-
-use pin_project::{pin_project, project_replace};
-use std::{marker::PhantomData, pin::Pin};
-
-#[project_replace] // Nightly does not need a dummy attribute to the function.
-#[test]
-fn project_replace_stmt_expr() {
- #[pin_project(project_replace)]
- struct Struct<T, U> {
- #[pin]
- field1: T,
- field2: U,
- }
-
- let mut s = Struct { field1: 1, field2: 2 };
-
- #[project_replace]
- let Struct { field1, field2 } =
- Pin::new(&mut s).project_replace(Struct { field1: 42, field2: 43 });
-
- let _x: PhantomData<i32> = field1;
-
- let y: i32 = field2;
- assert_eq!(y, 2);
-
- // tuple struct
-
- #[pin_project(project_replace)]
- struct TupleStruct<T, U>(#[pin] T, U);
-
- let mut s = TupleStruct(1, 2);
-
- #[project_replace]
- let TupleStruct(x, y) = Pin::new(&mut s).project_replace(TupleStruct(42, 43));
-
- let _x: PhantomData<i32> = x;
- let y: i32 = y;
- assert_eq!(y, 2);
-
- #[pin_project(project_replace)]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut e = Enum::Variant1(1, 2);
-
- let e = Pin::new(&mut e).project_replace(Enum::None);
-
- #[project_replace]
- match e {
- Enum::Variant1(x, y) => {
- let _x: PhantomData<i32> = x;
- let y: i32 = y;
- assert_eq!(y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: PhantomData<i32> = field1;
- let _y: i32 = field2;
- panic!()
- }
- Enum::None => panic!(),
- }
-}
-
-#[project_replace]
-#[test]
-fn combine() {
- #[pin_project(project_replace)]
- enum Enum<A> {
- V1(#[pin] A),
- V2,
- }
-
- let mut x = Enum::V1(1);
- #[project]
- match Pin::new(&mut x).project() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_ref]
- match Pin::new(&x).project_ref() {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
- #[project_replace]
- match Pin::new(&mut x).project_replace(Enum::V2) {
- Enum::V1(_) => {}
- Enum::V2 => unreachable!(),
- }
-}
diff --git a/tests/proper_unpin.rs b/tests/proper_unpin.rs
new file mode 100644
index 0000000..ce2a6c8
--- /dev/null
+++ b/tests/proper_unpin.rs
@@ -0,0 +1,135 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+pub mod default {
+ use pin_project::pin_project;
+ use std::marker::PhantomPinned;
+
+ struct Inner<T> {
+ f: T,
+ }
+
+ assert_unpin!(Inner<()>);
+ assert_not_unpin!(Inner<PhantomPinned>);
+
+ #[pin_project]
+ struct Foo<T, U> {
+ #[pin]
+ f1: Inner<T>,
+ f2: U,
+ }
+
+ assert_unpin!(Foo<(), ()>);
+ assert_unpin!(Foo<(), PhantomPinned>);
+ assert_not_unpin!(Foo<PhantomPinned, ()>);
+ assert_not_unpin!(Foo<PhantomPinned, PhantomPinned>);
+
+ #[pin_project]
+ struct TrivialBounds {
+ #[pin]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(TrivialBounds);
+
+ #[pin_project]
+ struct Bar<'a, T, U> {
+ #[pin]
+ f1: &'a mut Inner<T>,
+ f2: U,
+ }
+
+ assert_unpin!(Bar<'_, PhantomPinned, PhantomPinned>);
+}
+
+pub mod cfg {
+ use pin_project::pin_project;
+ use std::marker::PhantomPinned;
+
+ #[pin_project]
+ struct Foo<T> {
+ #[cfg(any())]
+ #[pin]
+ f: T,
+ #[cfg(not(any()))]
+ f: T,
+ }
+
+ assert_unpin!(Foo<PhantomPinned>);
+
+ #[pin_project]
+ struct Bar<T> {
+ #[cfg(any())]
+ f: T,
+ #[cfg(not(any()))]
+ #[pin]
+ f: T,
+ }
+
+ assert_unpin!(Bar<()>);
+ assert_not_unpin!(Bar<PhantomPinned>);
+}
+
+pub mod cfg_attr {
+ use pin_project::pin_project;
+ use std::marker::PhantomPinned;
+
+ #[cfg_attr(any(), pin_project)]
+ struct Foo<T> {
+ f: T,
+ }
+
+ assert_unpin!(Foo<()>);
+ assert_not_unpin!(Foo<PhantomPinned>);
+
+ #[cfg_attr(not(any()), pin_project)]
+ struct Bar<T> {
+ #[cfg_attr(not(any()), pin)]
+ f: T,
+ }
+
+ assert_unpin!(Bar<()>);
+ assert_not_unpin!(Bar<PhantomPinned>);
+}
+
+// pin_project(!Unpin)
+pub mod not_unpin {
+ use pin_project::pin_project;
+ use std::marker::PhantomPinned;
+
+ struct Inner<T> {
+ f: T,
+ }
+
+ #[pin_project(!Unpin)]
+ struct Foo<T, U> {
+ #[pin]
+ inner: Inner<T>,
+ other: U,
+ }
+
+ assert_not_unpin!(Foo<(), ()>);
+ assert_not_unpin!(Foo<(), PhantomPinned>);
+ assert_not_unpin!(Foo<PhantomPinned, ()>);
+ assert_not_unpin!(Foo<PhantomPinned, PhantomPinned>);
+
+ #[pin_project(!Unpin)]
+ struct TrivialBounds {
+ #[pin]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(TrivialBounds);
+
+ #[pin_project(!Unpin)]
+ struct Bar<'a, T, U> {
+ #[pin]
+ inner: &'a mut Inner<T>,
+ other: U,
+ }
+
+ assert_not_unpin!(Bar<'_, (), ()>);
+}
diff --git a/tests/repr_packed.rs b/tests/repr_packed.rs
index 73fc45c..a0d8bdc 100644
--- a/tests/repr_packed.rs
+++ b/tests/repr_packed.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![deny(safe_packed_borrows)]
+#![forbid(safe_packed_borrows)]
use std::cell::Cell;
@@ -22,11 +22,11 @@ fn weird_repr_packed() {
}
#[repr(packed)]
- struct Foo {
+ struct Struct {
field: u8,
}
- impl Drop for Foo {
+ impl Drop for Struct {
fn drop(&mut self) {
FIELD_ADDR.with(|f| {
f.set(&self.field as *const u8 as usize);
@@ -41,7 +41,7 @@ fn weird_repr_packed() {
// Calling drop(foo) causes 'foo' to be moved
// into the 'drop' function, resulting in a different
// address.
- let x = Foo { field: 27 };
+ let x = Struct { field: 27 };
let field_addr = &x.field as *const u8 as usize;
field_addr
};
diff --git a/tests/sized.rs b/tests/sized.rs
deleted file mode 100644
index 9fd7e2b..0000000
--- a/tests/sized.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#![warn(rust_2018_idioms, single_use_lifetimes)]
-#![allow(dead_code)]
-
-use pin_project::pin_project;
-
-#[pin_project]
-struct Foo<'a, I: ?Sized, Item>
-where
- I: Iterator,
-{
- iter: &'a mut I,
- item: Option<Item>,
-}
diff --git a/tests/ui/cfg/cfg_attr-resolve.rs b/tests/ui/cfg/cfg_attr-resolve.rs
index e16f3e8..c7a246a 100644
--- a/tests/ui/cfg/cfg_attr-resolve.rs
+++ b/tests/ui/cfg/cfg_attr-resolve.rs
@@ -2,10 +2,10 @@ use std::pin::Pin;
#[cfg_attr(any(), pin_project::pin_project)]
struct Foo<T> {
- inner: T,
+ f: T,
}
fn main() {
- let mut x = Foo { inner: 0_u8 };
+ let mut x = Foo { f: 0_u8 };
let _x = Pin::new(&mut x).project(); //~ ERROR E0599
}
diff --git a/tests/ui/cfg/cfg_attr-resolve.stderr b/tests/ui/cfg/cfg_attr-resolve.stderr
index 45af3ae..ee1fa03 100644
--- a/tests/ui/cfg/cfg_attr-resolve.stderr
+++ b/tests/ui/cfg/cfg_attr-resolve.stderr
@@ -1,5 +1,5 @@
-error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut Foo<u8>>` in the current scope
+error[E0599]: no method named `project` found for struct `Pin<&mut Foo<u8>>` in the current scope
--> $DIR/cfg_attr-resolve.rs:10:31
|
10 | let _x = Pin::new(&mut x).project(); //~ ERROR E0599
- | ^^^^^^^ method not found in `std::pin::Pin<&mut Foo<u8>>`
+ | ^^^^^^^ method not found in `Pin<&mut Foo<u8>>`
diff --git a/tests/ui/cfg/cfg_attr-type-mismatch.rs b/tests/ui/cfg/cfg_attr-type-mismatch.rs
index 2807c87..b075af9 100644
--- a/tests/ui/cfg/cfg_attr-type-mismatch.rs
+++ b/tests/ui/cfg/cfg_attr-type-mismatch.rs
@@ -4,21 +4,21 @@ use std::pin::Pin;
#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
#[cfg_attr(any(), pin)]
- inner: T,
+ f: T,
}
#[cfg_attr(not(any()), pin_project)]
struct Bar<T> {
#[cfg_attr(not(any()), pin)]
- inner: T,
+ f: T,
}
fn main() {
- let mut x = Foo { inner: 0_u8 };
+ let mut x = Foo { f: 0_u8 };
let x = Pin::new(&mut x).project();
- let _: Pin<&mut u8> = x.inner; //~ ERROR E0308
+ let _: Pin<&mut u8> = x.f; //~ ERROR E0308
- let mut x = Bar { inner: 0_u8 };
+ let mut x = Bar { f: 0_u8 };
let x = Pin::new(&mut x).project();
- let _: &mut u8 = x.inner; //~ ERROR E0308
+ let _: &mut u8 = x.f; //~ ERROR E0308
}
diff --git a/tests/ui/cfg/cfg_attr-type-mismatch.stderr b/tests/ui/cfg/cfg_attr-type-mismatch.stderr
index 2868299..89172a2 100644
--- a/tests/ui/cfg/cfg_attr-type-mismatch.stderr
+++ b/tests/ui/cfg/cfg_attr-type-mismatch.stderr
@@ -1,23 +1,23 @@
error[E0308]: mismatched types
--> $DIR/cfg_attr-type-mismatch.rs:19:27
|
-19 | let _: Pin<&mut u8> = x.inner; //~ ERROR E0308
- | ------------ ^^^^^^^ expected struct `std::pin::Pin`, found `&mut u8`
+19 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308
+ | ------------ ^^^ expected struct `Pin`, found `&mut u8`
| |
| expected due to this
|
- = note: expected struct `std::pin::Pin<&mut u8>`
+ = note: expected struct `Pin<&mut u8>`
found mutable reference `&mut u8`
error[E0308]: mismatched types
--> $DIR/cfg_attr-type-mismatch.rs:23:22
|
-23 | let _: &mut u8 = x.inner; //~ ERROR E0308
- | ------- ^^^^^^^
+23 | let _: &mut u8 = x.f; //~ ERROR E0308
+ | ------- ^^^
| | |
- | | expected `&mut u8`, found struct `std::pin::Pin`
- | | help: consider mutably borrowing here: `&mut x.inner`
+ | | expected `&mut u8`, found struct `Pin`
+ | | help: consider mutably borrowing here: `&mut x.f`
| expected due to this
|
= note: expected mutable reference `&mut u8`
- found struct `std::pin::Pin<&mut u8>`
+ found struct `Pin<&mut u8>`
diff --git a/tests/ui/cfg/cfg_attr-unpin.rs b/tests/ui/cfg/cfg_attr-unpin.rs
deleted file mode 100644
index 7b88205..0000000
--- a/tests/ui/cfg/cfg_attr-unpin.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use pin_project::pin_project;
-use std::marker::PhantomPinned;
-
-#[cfg_attr(any(), pin_project)]
-struct Foo<T> {
- inner: T,
-}
-
-#[cfg_attr(not(any()), pin_project)]
-struct Bar<T> {
- #[cfg_attr(not(any()), pin)]
- inner: T,
-}
-
-fn is_unpin<T: Unpin>() {}
-
-fn main() {
- is_unpin::<Foo<PhantomPinned>>(); // ERROR E0277
- is_unpin::<Bar<()>>(); // Ok
- is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
-}
diff --git a/tests/ui/cfg/cfg_attr-unpin.stderr b/tests/ui/cfg/cfg_attr-unpin.stderr
deleted file mode 100644
index 45789ff..0000000
--- a/tests/ui/cfg/cfg_attr-unpin.stderr
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/cfg_attr-unpin.rs:18:5
- |
-15 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-18 | is_unpin::<Foo<PhantomPinned>>(); // ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Foo<std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `Foo<std::marker::PhantomPinned>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/cfg_attr-unpin.rs:20:5
- |
-15 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-20 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `_::__Bar<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/tests/ui/cfg/packed_sneaky-span-issue-1.rs b/tests/ui/cfg/packed_sneaky-span-issue-1.rs
index 3776dac..8455d07 100644
--- a/tests/ui/cfg/packed_sneaky-span-issue-1.rs
+++ b/tests/ui/cfg/packed_sneaky-span-issue-1.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::hidden_repr;
+use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
//~ ERROR may not be used on #[repr(packed)] types
@@ -6,13 +6,13 @@ use pin_project::pin_project;
// Refs: https://github.com/rust-lang/rust/issues/43081
#[pin_project]
#[hidden_repr(packed)]
-struct Foo {
+struct S {
#[cfg(not(any()))]
#[pin]
- field: u32,
+ f: u32,
#[cfg(any())]
#[pin]
- field: u8,
+ f: u8,
}
fn main() {}
diff --git a/tests/ui/cfg/packed_sneaky-span-issue-2.rs b/tests/ui/cfg/packed_sneaky-span-issue-2.rs
index aa65d33..01706ee 100644
--- a/tests/ui/cfg/packed_sneaky-span-issue-2.rs
+++ b/tests/ui/cfg/packed_sneaky-span-issue-2.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::hidden_repr;
+use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
//~ ERROR may not be used on #[repr(packed)] types
@@ -6,13 +6,13 @@ use pin_project::pin_project;
// Refs: https://github.com/rust-lang/rust/issues/43081
#[pin_project]
#[hidden_repr(packed)]
-struct Foo {
+struct S {
#[cfg(any())]
#[pin]
- field: u32,
+ f: u32,
#[cfg(not(any()))]
#[pin]
- field: u8,
+ f: u8,
}
fn main() {}
diff --git a/tests/ui/cfg/packed_sneaky.rs b/tests/ui/cfg/packed_sneaky.rs
index 3305ed3..0b01dc9 100644
--- a/tests/ui/cfg/packed_sneaky.rs
+++ b/tests/ui/cfg/packed_sneaky.rs
@@ -1,12 +1,12 @@
-use auxiliary_macros::hidden_repr_cfg_not_any;
+use auxiliary_macro::hidden_repr_cfg_not_any;
use pin_project::pin_project;
// `#[hidden_repr_cfg_not_any(packed)]` generates `#[cfg_attr(not(any()), repr(packed))]`.
#[pin_project]
#[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
-struct Foo {
+struct S {
#[pin]
- field: u32,
+ f: u32,
}
fn main() {}
diff --git a/tests/ui/cfg/packed_sneaky.stderr b/tests/ui/cfg/packed_sneaky.stderr
index 5910cf4..b0d4d93 100644
--- a/tests/ui/cfg/packed_sneaky.stderr
+++ b/tests/ui/cfg/packed_sneaky.stderr
@@ -1,7 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/packed_sneaky.rs:6:1
+ --> $DIR/packed_sneaky.rs:6:27
|
6 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ | ^^^^^^
diff --git a/tests/ui/cfg/proper_unpin.rs b/tests/ui/cfg/proper_unpin.rs
deleted file mode 100644
index b7bb04d..0000000
--- a/tests/ui/cfg/proper_unpin.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use pin_project::pin_project;
-use std::marker::PhantomPinned;
-
-#[pin_project]
-struct Foo<T> {
- #[cfg(any())]
- #[pin]
- inner: T,
- #[cfg(not(any()))]
- inner: T,
-}
-
-#[pin_project]
-struct Bar<T> {
- #[cfg(any())]
- inner: T,
- #[cfg(not(any()))]
- #[pin]
- inner: T,
-}
-
-fn is_unpin<T: Unpin>() {}
-
-fn main() {
- is_unpin::<Foo<PhantomPinned>>(); // Ok
- is_unpin::<Bar<()>>(); // Ok
- is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
-}
diff --git a/tests/ui/cfg/proper_unpin.stderr b/tests/ui/cfg/proper_unpin.stderr
deleted file mode 100644
index f1fff34..0000000
--- a/tests/ui/cfg/proper_unpin.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:27:5
- |
-22 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-27 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Bar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `_::__Bar<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>`
diff --git a/tests/ui/cfg/unsupported.rs b/tests/ui/cfg/unsupported.rs
index 5205307..c450f6f 100644
--- a/tests/ui/cfg/unsupported.rs
+++ b/tests/ui/cfg/unsupported.rs
@@ -4,7 +4,7 @@ use pin_project::pin_project;
// span is lost.
// Refs: https://github.com/rust-lang/rust/issues/43081
#[pin_project]
-struct Struct {
+struct S {
#[cfg(any())]
#[pin]
f: u8,
diff --git a/tests/ui/not_unpin/assert-not-unpin.rs b/tests/ui/not_unpin/assert-not-unpin.rs
deleted file mode 100644
index b8f8238..0000000
--- a/tests/ui/not_unpin/assert-not-unpin.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-use pin_project::pin_project;
-use std::marker::PhantomPinned;
-
-struct Inner<T> {
- val: T,
-}
-
-#[pin_project(!Unpin)]
-struct Foo<T, U> {
- #[pin]
- inner: Inner<T>,
- other: U,
-}
-
-#[pin_project(!Unpin)]
-struct TrivialBounds {
- #[pin]
- field1: PhantomPinned,
-}
-
-#[pin_project(!Unpin)]
-struct Bar<'a, T, U> {
- #[pin]
- inner: &'a mut Inner<T>,
- other: U,
-}
-
-fn is_unpin<T: Unpin>() {}
-
-fn main() {
- is_unpin::<Foo<(), ()>>(); //~ ERROR E0277
- is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
- is_unpin::<Foo<(), PhantomPinned>>(); //~ ERROR E0277
- is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
-
- is_unpin::<TrivialBounds>(); //~ ERROR E0277
-
- is_unpin::<Bar<'_, (), ()>>(); //~ ERROR E0277
- is_unpin::<Bar<'_, PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
-}
diff --git a/tests/ui/not_unpin/assert-not-unpin.stderr b/tests/ui/not_unpin/assert-not-unpin.stderr
deleted file mode 100644
index 5e323fc..0000000
--- a/tests/ui/not_unpin/assert-not-unpin.stderr
+++ /dev/null
@@ -1,83 +0,0 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:31:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-31 | is_unpin::<Foo<(), ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<(), ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:32:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-32 | is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:33:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-33 | is_unpin::<Foo<(), PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<(), std::marker::PhantomPinned>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:34:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-34 | is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:36:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-36 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:38:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-38 | is_unpin::<Bar<'_, (), ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<'_, (), ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/assert-not-unpin.rs:39:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-39 | is_unpin::<Bar<'_, PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `pin_project::__private::Wrapper<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`
diff --git a/tests/ui/not_unpin/conflict-unpin.rs b/tests/ui/not_unpin/conflict-unpin.rs
index f259f6c..8985f37 100644
--- a/tests/ui/not_unpin/conflict-unpin.rs
+++ b/tests/ui/not_unpin/conflict-unpin.rs
@@ -3,8 +3,8 @@ use pin_project::pin_project;
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
@@ -12,8 +12,8 @@ impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T, U> Unpin for Bar<T, U> {}
@@ -21,8 +21,8 @@ impl<T, U> Unpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
diff --git a/tests/ui/not_unpin/impl-unsafe-unpin.rs b/tests/ui/not_unpin/impl-unsafe-unpin.rs
index 625dc29..2c078c7 100644
--- a/tests/ui/not_unpin/impl-unsafe-unpin.rs
+++ b/tests/ui/not_unpin/impl-unsafe-unpin.rs
@@ -3,8 +3,8 @@ use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
@@ -12,8 +12,8 @@ unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
@@ -21,8 +21,8 @@ unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
diff --git a/tests/ui/pin_project/add-attr-to-struct.rs b/tests/ui/pin_project/add-attr-to-struct.rs
index f5364fc..55f1561 100644
--- a/tests/ui/pin_project/add-attr-to-struct.rs
+++ b/tests/ui/pin_project/add-attr-to-struct.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::add_pin_attr;
+use auxiliary_macro::add_pin_attr;
use pin_project::pin_project;
use std::marker::PhantomPinned;
@@ -6,14 +6,14 @@ use std::marker::PhantomPinned;
#[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute
struct Foo {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
#[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
#[pin_project]
struct Bar {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
fn main() {}
diff --git a/tests/ui/pin_project/add-pinned-field.rs b/tests/ui/pin_project/add-pinned-field.rs
index 76394cf..c415f9c 100644
--- a/tests/ui/pin_project/add-pinned-field.rs
+++ b/tests/ui/pin_project/add-pinned-field.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::add_pinned_field;
+use auxiliary_macro::add_pinned_field;
use pin_project::pin_project;
fn is_unpin<T: Unpin>() {}
@@ -7,14 +7,14 @@ fn is_unpin<T: Unpin>() {}
#[add_pinned_field]
struct Foo {
#[pin]
- field: u32,
+ f: u32,
}
#[add_pinned_field]
#[pin_project]
struct Bar {
#[pin]
- field: u32,
+ f: u32,
}
fn main() {
diff --git a/tests/ui/pin_project/add-pinned-field.stderr b/tests/ui/pin_project/add-pinned-field.stderr
index d6a1dcd..a140694 100644
--- a/tests/ui/pin_project/add-pinned-field.stderr
+++ b/tests/ui/pin_project/add-pinned-field.stderr
@@ -1,23 +1,23 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/add-pinned-field.rs:21:5
|
4 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
21 | is_unpin::<Foo>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `_::__Foo<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^ within `__Foo<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because it appears within the type `_::__Foo<'_>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo`
+ = note: required because it appears within the type `__Foo<'_>`
+ = note: required because of the requirements on the impl of `Unpin` for `Foo`
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/add-pinned-field.rs:22:5
|
4 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
22 | is_unpin::<Bar>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^ within `_::__Bar<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^ within `__Bar<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because it appears within the type `_::__Bar<'_>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar`
+ = note: required because it appears within the type `__Bar<'_>`
+ = note: required because of the requirements on the impl of `Unpin` for `Bar`
diff --git a/tests/ui/pin_project/conflict-drop.rs b/tests/ui/pin_project/conflict-drop.rs
index c965184..908f5c0 100644
--- a/tests/ui/pin_project/conflict-drop.rs
+++ b/tests/ui/pin_project/conflict-drop.rs
@@ -4,8 +4,8 @@ use std::pin::Pin;
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T, U> Drop for Foo<T, U> {
@@ -15,8 +15,8 @@ impl<T, U> Drop for Foo<T, U> {
#[pin_project(PinnedDrop)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
#[pinned_drop]
diff --git a/tests/ui/pin_project/conflict-unpin.rs b/tests/ui/pin_project/conflict-unpin.rs
index 0c48d27..f58c45e 100644
--- a/tests/ui/pin_project/conflict-unpin.rs
+++ b/tests/ui/pin_project/conflict-unpin.rs
@@ -5,8 +5,8 @@ use pin_project::pin_project;
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
// conflicting implementations
@@ -17,8 +17,8 @@ impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
#[pin_project] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
// conflicting implementations
@@ -27,8 +27,8 @@ impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
#[pin_project] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
// conflicting implementations
diff --git a/tests/ui/pin_project/impl-unsafe-unpin.rs b/tests/ui/pin_project/impl-unsafe-unpin.rs
index 94af322..562c9b6 100644
--- a/tests/ui/pin_project/impl-unsafe-unpin.rs
+++ b/tests/ui/pin_project/impl-unsafe-unpin.rs
@@ -3,8 +3,8 @@ use pin_project::{pin_project, UnsafeUnpin};
#[pin_project] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
@@ -12,8 +12,8 @@ unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
#[pin_project] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
@@ -21,8 +21,8 @@ unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
#[pin_project] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
diff --git a/tests/ui/pin_project/import_unnamed.rs b/tests/ui/pin_project/import_unnamed.rs
new file mode 100644
index 0000000..7926e61
--- /dev/null
+++ b/tests/ui/pin_project/import_unnamed.rs
@@ -0,0 +1,30 @@
+/// Only named projected types can be imported.
+/// See visibility.rs for named projected types.
+
+mod pub_ {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ pub struct Default(());
+
+ #[pin_project(project_replace)]
+ pub struct Replace(());
+}
+#[allow(unused_imports)]
+pub mod use_ {
+ #[rustfmt::skip]
+ use crate::pub_::__DefaultProjection; //~ ERROR E0432
+ #[rustfmt::skip]
+ use crate::pub_::__DefaultProjectionRef; //~ ERROR E0432
+ #[rustfmt::skip]
+ use crate::pub_::__ReplaceProjection; //~ ERROR E0432
+ #[rustfmt::skip]
+ use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0432
+ #[rustfmt::skip]
+ use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0432
+
+ // Confirm that the visibility of the original type is not changed.
+ pub use crate::pub_::{Default, Replace};
+}
+
+fn main() {}
diff --git a/tests/ui/pin_project/import_unnamed.stderr b/tests/ui/pin_project/import_unnamed.stderr
new file mode 100644
index 0000000..f54e4c4
--- /dev/null
+++ b/tests/ui/pin_project/import_unnamed.stderr
@@ -0,0 +1,29 @@
+error[E0432]: unresolved import `crate::pub_::__DefaultProjection`
+ --> $DIR/import_unnamed.rs:16:9
+ |
+16 | use crate::pub_::__DefaultProjection; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjection` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__DefaultProjectionRef`
+ --> $DIR/import_unnamed.rs:18:9
+ |
+18 | use crate::pub_::__DefaultProjectionRef; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjectionRef` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjection`
+ --> $DIR/import_unnamed.rs:20:9
+ |
+20 | use crate::pub_::__ReplaceProjection; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjection` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionOwned`
+ --> $DIR/import_unnamed.rs:22:9
+ |
+22 | use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionOwned` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionRef`
+ --> $DIR/import_unnamed.rs:24:9
+ |
+24 | use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionRef` in `pub_`
diff --git a/tests/ui/pin_project/invalid.rs b/tests/ui/pin_project/invalid.rs
index 9c51bec..d39a1fd 100644
--- a/tests/ui/pin_project/invalid.rs
+++ b/tests/ui/pin_project/invalid.rs
@@ -4,7 +4,7 @@ mod pin_argument {
#[pin_project]
struct Struct {
#[pin()] //~ ERROR unexpected token
- field: (),
+ f: (),
}
#[pin_project]
@@ -19,7 +19,7 @@ mod pin_argument {
enum EnumStruct {
V {
#[pin(foo)] //~ ERROR unexpected token
- field: (),
+ f: (),
},
}
}
@@ -31,7 +31,7 @@ mod pin_attribute {
struct DuplicateStruct {
#[pin]
#[pin] //~ ERROR duplicate #[pin] attribute
- field: (),
+ f: (),
}
#[pin_project]
@@ -57,7 +57,7 @@ mod pin_attribute {
V {
#[pin]
#[pin] //~ ERROR duplicate #[pin] attribute
- field: (),
+ f: (),
},
}
}
@@ -69,7 +69,7 @@ mod pin_item {
#[pin] //~ ERROR may only be used on fields of structs or variants
struct Struct {
#[pin]
- field: (),
+ f: (),
}
#[pin_project]
@@ -88,6 +88,9 @@ mod pin_item {
mod pin_project_argument {
use pin_project::pin_project;
+ #[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
+ struct RemovedReplace(#[pin] ());
+
#[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
struct Unexpected1(#[pin] ());
@@ -106,9 +109,6 @@ mod pin_project_argument {
#[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
struct DuplicatePinnedDrop(#[pin] ());
- #[pin_project(Replace, Replace)] //~ ERROR duplicate `Replace` argument
- struct DuplicateReplace(#[pin] ());
-
#[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
struct DuplicateUnsafeUnpin(#[pin] ());
@@ -142,24 +142,12 @@ mod pin_project_argument {
#[pin_project(project_replace = A)] // Ok
struct ProjectReplaceWithoutReplace(#[pin] ());
- #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
- struct PinnedDropWithReplace1(#[pin] ());
-
- #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
- struct PinnedDropWithReplace2(#[pin] ());
-
#[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
struct PinnedDropWithProjectReplace1(#[pin] ());
#[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
struct PinnedDropWithProjectReplace2(#[pin] ());
- #[pin_project(project_replace, Replace)] // Ok
- struct ProjectReplaceWithReplace1(#[pin] ());
-
- #[pin_project(project_replace = B, Replace)] // Ok
- struct ProjectReplaceWithReplace2(#[pin] ());
-
#[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
struct UnsafeUnpinWithNotUnpin1(#[pin] ());
@@ -198,11 +186,25 @@ mod pin_project_argument {
#[pin_project(project_replace = !)] //~ ERROR expected identifier
struct ProjectReplace3(#[pin] ());
+
+ #[pin_project(project_replace)] //~ ERROR `project_replace` argument requires a value when used on enums
+ enum ProjectReplaceEnum {
+ V(#[pin] ()),
+ }
}
mod pin_project_conflict_naming {
use pin_project::pin_project;
+ #[pin_project(project = OrigAndProj)] //~ ERROR name `OrigAndProj` is the same as the original type name
+ struct OrigAndProj(#[pin] ());
+
+ #[pin_project(project_ref = OrigAndProjRef)] //~ ERROR name `OrigAndProjRef` is the same as the original type name
+ struct OrigAndProjRef(#[pin] ());
+
+ #[pin_project(project_replace = OrigAndProjOwn)] //~ ERROR name `OrigAndProjOwn` is the same as the original type name
+ struct OrigAndProjOwn(#[pin] ());
+
#[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
struct ProjAndProjRef(#[pin] ());
@@ -253,6 +255,9 @@ mod pin_project_item {
//~^ ERROR may only be used on structs or enums
f: (),
}
+
+ #[pin_project]
+ impl Impl {} //~ ERROR may only be used on structs or enums
}
// #[repr(packed)] is always detected first, even on unsupported structs.
diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr
index 3c6af57..35552bf 100644
--- a/tests/ui/pin_project/invalid.stderr
+++ b/tests/ui/pin_project/invalid.stderr
@@ -64,42 +64,42 @@ error: #[pin] attribute may only be used on fields of structs or variants
82 | #[pin] //~ ERROR may only be used on fields of structs or variants
| ^^^^^^
+error: `Replace` argument was removed, use `project_replace` argument instead
+ --> $DIR/invalid.rs:91:19
+ |
+91 | #[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
+ | ^^^^^^^
+
error: expected identifier
- --> $DIR/invalid.rs:91:31
+ --> $DIR/invalid.rs:94:31
|
-91 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
+94 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
| ^
error: unexpected argument: Foo
- --> $DIR/invalid.rs:94:19
+ --> $DIR/invalid.rs:97:19
|
-94 | #[pin_project(Foo)] //~ ERROR unexpected argument
+97 | #[pin_project(Foo)] //~ ERROR unexpected argument
| ^^^
error: expected identifier
- --> $DIR/invalid.rs:97:19
- |
-97 | #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
- | ^
+ --> $DIR/invalid.rs:100:19
+ |
+100 | #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
+ | ^
error: expected `,`
- --> $DIR/invalid.rs:103:30
+ --> $DIR/invalid.rs:106:30
|
-103 | #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
+106 | #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
| ^^^^^^^^^^
error: duplicate `PinnedDrop` argument
- --> $DIR/invalid.rs:106:31
+ --> $DIR/invalid.rs:109:31
|
-106 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+109 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
-error: duplicate `Replace` argument
- --> $DIR/invalid.rs:109:28
- |
-109 | #[pin_project(Replace, Replace)] //~ ERROR duplicate `Replace` argument
- | ^^^^^^^
-
error: duplicate `UnsafeUnpin` argument
--> $DIR/invalid.rs:112:32
|
@@ -160,187 +160,205 @@ error: duplicate `project_replace` argument
139 | #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
| ^^^^^^^^^^^^^^^
-error: arguments `PinnedDrop` and `Replace` are mutually exclusive
- --> $DIR/invalid.rs:145:19
- |
-145 | #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
- | ^^^^^^^^^^
-
-error: arguments `PinnedDrop` and `Replace` are mutually exclusive
- --> $DIR/invalid.rs:148:41
- |
-148 | #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
- | ^^^^^^^^^^
-
error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:151:19
+ --> $DIR/invalid.rs:145:19
|
-151 | #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+145 | #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
| ^^^^^^^^^^
error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:154:49
+ --> $DIR/invalid.rs:148:49
|
-154 | #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+148 | #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
| ^^^^^^^^^^
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
- --> $DIR/invalid.rs:163:19
+ --> $DIR/invalid.rs:151:19
|
-163 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+151 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
- --> $DIR/invalid.rs:166:39
+ --> $DIR/invalid.rs:154:39
|
-166 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+154 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
| ^^^^^^^^^^^
error: expected `!Unpin`, found `!`
- --> $DIR/invalid.rs:169:19
+ --> $DIR/invalid.rs:157:19
|
-169 | #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
+157 | #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
| ^
error: unexpected argument: Unpin
- --> $DIR/invalid.rs:172:19
+ --> $DIR/invalid.rs:160:19
|
-172 | #[pin_project(Unpin)] //~ ERROR unexpected argument
+160 | #[pin_project(Unpin)] //~ ERROR unexpected argument
| ^^^^^
error: expected `project = <identifier>`, found `project`
- --> $DIR/invalid.rs:175:19
+ --> $DIR/invalid.rs:163:19
|
-175 | #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
+163 | #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
| ^^^^^^^
error: expected `project = <identifier>`, found `project =`
- --> $DIR/invalid.rs:178:19
+ --> $DIR/invalid.rs:166:19
|
-178 | #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
+166 | #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
| ^^^^^^^^^
error: expected identifier
- --> $DIR/invalid.rs:181:29
+ --> $DIR/invalid.rs:169:29
|
-181 | #[pin_project(project = !)] //~ ERROR expected identifier
+169 | #[pin_project(project = !)] //~ ERROR expected identifier
| ^
error: expected `project_ref = <identifier>`, found `project_ref`
- --> $DIR/invalid.rs:184:19
+ --> $DIR/invalid.rs:172:19
|
-184 | #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
+172 | #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
| ^^^^^^^^^^^
error: expected `project_ref = <identifier>`, found `project_ref =`
- --> $DIR/invalid.rs:187:19
+ --> $DIR/invalid.rs:175:19
|
-187 | #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
+175 | #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
| ^^^^^^^^^^^^^
error: expected identifier
- --> $DIR/invalid.rs:190:33
+ --> $DIR/invalid.rs:178:33
|
-190 | #[pin_project(project_ref = !)] //~ ERROR expected identifier
+178 | #[pin_project(project_ref = !)] //~ ERROR expected identifier
| ^
error: expected `project_replace = <identifier>`, found `project_replace =`
- --> $DIR/invalid.rs:196:19
+ --> $DIR/invalid.rs:184:19
|
-196 | #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
+184 | #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
| ^^^^^^^^^^^^^^^^^
error: expected identifier
- --> $DIR/invalid.rs:199:37
+ --> $DIR/invalid.rs:187:37
|
-199 | #[pin_project(project_replace = !)] //~ ERROR expected identifier
+187 | #[pin_project(project_replace = !)] //~ ERROR expected identifier
| ^
+error: `project_replace` argument requires a value when used on enums
+ --> $DIR/invalid.rs:190:19
+ |
+190 | #[pin_project(project_replace)] //~ ERROR `project_replace` argument requires a value when used on enums
+ | ^^^^^^^^^^^^^^^
+
+error: name `OrigAndProj` is the same as the original type name
+ --> $DIR/invalid.rs:199:29
+ |
+199 | #[pin_project(project = OrigAndProj)] //~ ERROR name `OrigAndProj` is the same as the original type name
+ | ^^^^^^^^^^^
+
+error: name `OrigAndProjRef` is the same as the original type name
+ --> $DIR/invalid.rs:202:33
+ |
+202 | #[pin_project(project_ref = OrigAndProjRef)] //~ ERROR name `OrigAndProjRef` is the same as the original type name
+ | ^^^^^^^^^^^^^^
+
+error: name `OrigAndProjOwn` is the same as the original type name
+ --> $DIR/invalid.rs:205:37
+ |
+205 | #[pin_project(project_replace = OrigAndProjOwn)] //~ ERROR name `OrigAndProjOwn` is the same as the original type name
+ | ^^^^^^^^^^^^^^
+
error: name `A` is already specified by `project` argument
- --> $DIR/invalid.rs:206:46
+ --> $DIR/invalid.rs:208:46
|
-206 | #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
+208 | #[pin_project(project = A, project_ref = A)] //~ ERROR name `A` is already specified by `project` argument
| ^
error: name `A` is already specified by `project` argument
- --> $DIR/invalid.rs:209:50
+ --> $DIR/invalid.rs:211:50
|
-209 | #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
+211 | #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
| ^
error: name `A` is already specified by `project_ref` argument
- --> $DIR/invalid.rs:212:54
+ --> $DIR/invalid.rs:214:54
|
-212 | #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
+214 | #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
| ^
error: duplicate #[pin_project] attribute
- --> $DIR/invalid.rs:220:5
+ --> $DIR/invalid.rs:222:5
|
-220 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
+222 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
| ^^^^^^^^^^^^^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:228:19
+ --> $DIR/invalid.rs:230:19
|
-228 | struct Struct {} //~ ERROR may not be used on structs with zero fields
+230 | struct Struct {} //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:231:23
+ --> $DIR/invalid.rs:233:23
|
-231 | struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
+233 | struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
| ^^
error: #[pin_project] attribute may not be used on structs with zero fields
- --> $DIR/invalid.rs:234:12
+ --> $DIR/invalid.rs:236:12
|
-234 | struct UnitStruct; //~ ERROR may not be used on structs with zero fields
+236 | struct UnitStruct; //~ ERROR may not be used on structs with zero fields
| ^^^^^^^^^^
error: #[pin_project] attribute may not be used on enums without variants
- --> $DIR/invalid.rs:237:20
+ --> $DIR/invalid.rs:239:20
|
-237 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
+239 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
| ^^
error: #[pin_project] attribute may not be used on enums with discriminants
- --> $DIR/invalid.rs:241:13
+ --> $DIR/invalid.rs:243:13
|
-241 | V = 2, //~ ERROR may not be used on enums with discriminants
+243 | V = 2, //~ ERROR may not be used on enums with discriminants
| ^
error: #[pin_project] attribute may not be used on enums with zero fields
- --> $DIR/invalid.rs:246:9
+ --> $DIR/invalid.rs:248:9
|
-246 | / Unit, //~ ERROR may not be used on enums with zero fields
-247 | | Tuple(),
-248 | | Struct {},
+248 | / Unit, //~ ERROR may not be used on enums with zero fields
+249 | | Tuple(),
+250 | | Struct {},
| |__________________^
error: #[pin_project] attribute may only be used on structs or enums
- --> $DIR/invalid.rs:252:5
+ --> $DIR/invalid.rs:254:5
|
-252 | / union Union {
-253 | | //~^ ERROR may only be used on structs or enums
-254 | | f: (),
-255 | | }
+254 | / union Union {
+255 | | //~^ ERROR may only be used on structs or enums
+256 | | f: (),
+257 | | }
| |_____^
+error: #[pin_project] attribute may only be used on structs or enums
+ --> $DIR/invalid.rs:260:5
+ |
+260 | impl Impl {} //~ ERROR may only be used on structs or enums
+ | ^^^^^^^^^^^^
+
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:263:12
+ --> $DIR/invalid.rs:268:12
|
-263 | #[repr(packed)]
+268 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:267:12
+ --> $DIR/invalid.rs:272:12
|
-267 | #[repr(packed)]
+272 | #[repr(packed)]
| ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/invalid.rs:271:12
+ --> $DIR/invalid.rs:276:12
|
-271 | #[repr(packed)]
+276 | #[repr(packed)]
| ^^^^^^
diff --git a/tests/ui/pin_project/overlapping_unpin_struct.rs b/tests/ui/pin_project/overlapping_unpin_struct.rs
index 00fef3c..8db0855 100644
--- a/tests/ui/pin_project/overlapping_unpin_struct.rs
+++ b/tests/ui/pin_project/overlapping_unpin_struct.rs
@@ -2,17 +2,17 @@ use pin_project::pin_project;
use std::marker::PhantomPinned;
#[pin_project]
-struct Foo<T> {
+struct S<T> {
#[pin]
- inner: T,
+ f: T,
}
-struct __Foo {}
+struct __S {}
-impl Unpin for __Foo {}
+impl Unpin for __S {}
fn is_unpin<T: Unpin>() {}
fn main() {
- is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
+ is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
}
diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr
index 96a9f51..296b063 100644
--- a/tests/ui/pin_project/overlapping_unpin_struct.stderr
+++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -1,11 +1,11 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/overlapping_unpin_struct.rs:17:5
|
14 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
-17 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+17 | is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__S<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned>`
+ = note: required because it appears within the type `_::__S<'_, PhantomPinned>`
+ = note: required because of the requirements on the impl of `Unpin` for `S<PhantomPinned>`
diff --git a/tests/ui/pin_project/packed.rs b/tests/ui/pin_project/packed.rs
index 86f3ecf..f756605 100644
--- a/tests/ui/pin_project/packed.rs
+++ b/tests/ui/pin_project/packed.rs
@@ -4,7 +4,7 @@ use pin_project::pin_project;
#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
struct A {
#[pin]
- field: u8,
+ f: u8,
}
// Test putting 'repr' before the 'pin_project' attribute
@@ -12,14 +12,14 @@ struct A {
#[pin_project]
struct B {
#[pin]
- field: u8,
+ f: u8,
}
#[pin_project]
#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
struct C {
#[pin]
- field: u32,
+ f: u32,
}
fn main() {}
diff --git a/tests/ui/pin_project/packed_sneaky-1.rs b/tests/ui/pin_project/packed_sneaky-1.rs
index dcf5464..38f6fe0 100644
--- a/tests/ui/pin_project/packed_sneaky-1.rs
+++ b/tests/ui/pin_project/packed_sneaky-1.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::hidden_repr;
+use auxiliary_macro::hidden_repr;
use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
use std::pin::Pin;
@@ -6,14 +6,14 @@ use std::pin::Pin;
#[hidden_repr(packed)]
struct A {
#[pin]
- field: u32,
+ f: u32,
}
#[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types
#[hidden_repr(packed)]
struct C {
#[pin]
- field: u32,
+ f: u32,
}
unsafe impl UnsafeUnpin for C {}
@@ -22,7 +22,7 @@ unsafe impl UnsafeUnpin for C {}
#[hidden_repr(packed)]
struct D {
#[pin]
- field: u32,
+ f: u32,
}
#[pinned_drop]
diff --git a/tests/ui/pin_project/packed_sneaky-1.stderr b/tests/ui/pin_project/packed_sneaky-1.stderr
index 06a4f62..510200e 100644
--- a/tests/ui/pin_project/packed_sneaky-1.stderr
+++ b/tests/ui/pin_project/packed_sneaky-1.stderr
@@ -1,23 +1,17 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/packed_sneaky-1.rs:6:1
+ --> $DIR/packed_sneaky-1.rs:6:15
|
6 | #[hidden_repr(packed)]
- | ^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ | ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/packed_sneaky-1.rs:13:1
+ --> $DIR/packed_sneaky-1.rs:13:15
|
13 | #[hidden_repr(packed)]
- | ^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ | ^^^^^^
error: #[pin_project] attribute may not be used on #[repr(packed)] types
- --> $DIR/packed_sneaky-1.rs:22:1
+ --> $DIR/packed_sneaky-1.rs:22:15
|
22 | #[hidden_repr(packed)]
- | ^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ | ^^^^^^
diff --git a/tests/ui/pin_project/packed_sneaky-2.rs b/tests/ui/pin_project/packed_sneaky-2.rs
index d162706..b098358 100644
--- a/tests/ui/pin_project/packed_sneaky-2.rs
+++ b/tests/ui/pin_project/packed_sneaky-2.rs
@@ -1,11 +1,11 @@
-use auxiliary_macros::hidden_repr_macro;
+use auxiliary_macro::hidden_repr_macro;
use pin_project::pin_project;
hidden_repr_macro! { //~ ERROR may not be used on #[repr(packed)] types
#[pin_project]
struct B {
#[pin]
- field: u32,
+ f: u32,
}
}
diff --git a/tests/ui/pin_project/packed_sneaky-2.stderr b/tests/ui/pin_project/packed_sneaky-2.stderr
index d653a4d..51987a2 100644
--- a/tests/ui/pin_project/packed_sneaky-2.stderr
+++ b/tests/ui/pin_project/packed_sneaky-2.stderr
@@ -5,7 +5,7 @@ error: #[pin_project] attribute may not be used on #[repr(packed)] types
5 | | #[pin_project]
6 | | struct B {
7 | | #[pin]
-8 | | field: u32,
+8 | | f: u32,
9 | | }
10 | | }
| |_^
diff --git a/tests/ui/pin_project/packed_sneaky-3.rs b/tests/ui/pin_project/packed_sneaky-3.rs
new file mode 100644
index 0000000..d3f00f3
--- /dev/null
+++ b/tests/ui/pin_project/packed_sneaky-3.rs
@@ -0,0 +1,32 @@
+use auxiliary_macro::{hidden_repr_macro, HiddenRepr};
+use pin_project::pin_project;
+
+hidden_repr_macro! {} //~ ERROR expected item after attributes
+#[pin_project]
+struct S1 {
+ #[pin]
+ f: u32,
+}
+
+macro_rules! hidden_repr_macro2 {
+ () => {
+ #[repr(packed)] //~ ERROR expected item after attributes
+ };
+}
+
+hidden_repr_macro2! {}
+#[pin_project]
+struct S2 {
+ #[pin]
+ f: u32,
+}
+
+#[derive(HiddenRepr)] //~ ERROR expected item after attributes
+struct S3 {}
+#[pin_project]
+struct S4 {
+ #[pin]
+ f: u32,
+}
+
+fn main() {}
diff --git a/tests/ui/pin_project/packed_sneaky-3.stderr b/tests/ui/pin_project/packed_sneaky-3.stderr
new file mode 100644
index 0000000..b711d05
--- /dev/null
+++ b/tests/ui/pin_project/packed_sneaky-3.stderr
@@ -0,0 +1,30 @@
+error: expected item after attributes
+ --> $DIR/packed_sneaky-3.rs:4:1
+ |
+4 | hidden_repr_macro! {} //~ ERROR expected item after attributes
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+error: expected item after attributes
+ --> $DIR/packed_sneaky-3.rs:13:9
+ |
+13 | #[repr(packed)] //~ ERROR expected item after attributes
+ | ^^^^^^^^^^^^^^^
+...
+17 | hidden_repr_macro2! {}
+ | ---------------------- in this macro invocation
+ |
+ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected item after attributes
+ --> $DIR/packed_sneaky-3.rs:24:10
+ |
+24 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
+ | ^^^^^^^^^^
+ |
+ = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: proc-macro derive produced unparseable tokens
+ --> $DIR/packed_sneaky-3.rs:24:10
+ |
+24 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
+ | ^^^^^^^^^^
diff --git a/tests/ui/pin_project/private_in_public-enum.rs b/tests/ui/pin_project/private_in_public-enum.rs
index cbffa20..15a82a9 100644
--- a/tests/ui/pin_project/private_in_public-enum.rs
+++ b/tests/ui/pin_project/private_in_public-enum.rs
@@ -3,20 +3,20 @@
#![allow(private_in_public)]
pub enum PublicEnum {
- Variant(PrivateEnum), //~ ERROR E0446
+ V(PrivateEnum), //~ ERROR E0446
}
enum PrivateEnum {
- Variant(u8),
+ V(u8),
}
mod foo {
pub(crate) enum CrateEnum {
- Variant(PrivateEnum), //~ ERROR E0446
+ V(PrivateEnum), //~ ERROR E0446
}
enum PrivateEnum {
- Variant(u8),
+ V(u8),
}
}
diff --git a/tests/ui/pin_project/private_in_public-enum.stderr b/tests/ui/pin_project/private_in_public-enum.stderr
index 6f2988f..a14756b 100644
--- a/tests/ui/pin_project/private_in_public-enum.stderr
+++ b/tests/ui/pin_project/private_in_public-enum.stderr
@@ -1,17 +1,17 @@
error[E0446]: private type `PrivateEnum` in public interface
- --> $DIR/private_in_public-enum.rs:6:13
+ --> $DIR/private_in_public-enum.rs:6:7
|
-6 | Variant(PrivateEnum), //~ ERROR E0446
- | ^^^^^^^^^^^ can't leak private type
+6 | V(PrivateEnum), //~ ERROR E0446
+ | ^^^^^^^^^^^ can't leak private type
...
9 | enum PrivateEnum {
| - `PrivateEnum` declared as private
error[E0446]: private type `foo::PrivateEnum` in public interface
- --> $DIR/private_in_public-enum.rs:15:17
+ --> $DIR/private_in_public-enum.rs:15:11
|
-15 | Variant(PrivateEnum), //~ ERROR E0446
- | ^^^^^^^^^^^ can't leak private type
+15 | V(PrivateEnum), //~ ERROR E0446
+ | ^^^^^^^^^^^ can't leak private type
...
18 | enum PrivateEnum {
| - `foo::PrivateEnum` declared as private
diff --git a/tests/ui/pin_project/project_replace_unsized.rs b/tests/ui/pin_project/project_replace_unsized.rs
index 706a0c1..20dde12 100644
--- a/tests/ui/pin_project/project_replace_unsized.rs
+++ b/tests/ui/pin_project/project_replace_unsized.rs
@@ -2,7 +2,7 @@ use pin_project::pin_project;
#[pin_project(project_replace)] //~ ERROR E0277
struct Struct<T: ?Sized> {
- x: T,
+ f: T,
}
#[pin_project(project_replace)] //~ ERROR E0277
diff --git a/tests/ui/pin_project/project_replace_unsized.stderr b/tests/ui/pin_project/project_replace_unsized.stderr
index 0395c4e..b6ecb1b 100644
--- a/tests/ui/pin_project/project_replace_unsized.stderr
+++ b/tests/ui/pin_project/project_replace_unsized.stderr
@@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
3 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
4 | struct Struct<T: ?Sized> {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: required because it appears within the type `Struct<T>`
= help: unsized locals are gated as an unstable feature
@@ -17,8 +17,8 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/project_replace_unsized.rs:5:5
|
4 | struct Struct<T: ?Sized> {
- | - this type parameter needs to be `std::marker::Sized`
-5 | x: T,
+ | - this type parameter needs to be `Sized`
+5 | f: T,
| ^ doesn't have a size known at compile-time
error[E0277]: the size for values of type `T` cannot be known at compilation time
@@ -27,7 +27,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
3 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
4 | struct Struct<T: ?Sized> {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: required because it appears within the type `__StructProjectionOwned<T>`
= note: structs must have a statically known size to be initialized
@@ -39,7 +39,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
8 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9 | struct TupleStruct<T: ?Sized>(T);
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: required because it appears within the type `TupleStruct<T>`
= help: unsized locals are gated as an unstable feature
@@ -54,7 +54,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
8 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
9 | struct TupleStruct<T: ?Sized>(T);
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -62,7 +62,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/project_replace_unsized.rs:9:8
|
9 | struct TupleStruct<T: ?Sized>(T);
- | ^^^^^^^^^^^ - this type parameter needs to be `std::marker::Sized`
+ | ^^^^^^^^^^^ - this type parameter needs to be `Sized`
| |
| doesn't have a size known at compile-time
|
diff --git a/tests/ui/pin_project/project_replace_unsized_locals.rs b/tests/ui/pin_project/project_replace_unsized_locals.rs
index 2546041..7e28e2c 100644
--- a/tests/ui/pin_project/project_replace_unsized_locals.rs
+++ b/tests/ui/pin_project/project_replace_unsized_locals.rs
@@ -4,7 +4,7 @@ use pin_project::pin_project;
#[pin_project(project_replace)] //~ ERROR E0277
struct Struct<T: ?Sized> {
- x: T,
+ f: T,
}
#[pin_project(project_replace)] //~ ERROR E0277
diff --git a/tests/ui/pin_project/project_replace_unsized_locals.stderr b/tests/ui/pin_project/project_replace_unsized_locals.stderr
index 1266c4d..ad965e5 100644
--- a/tests/ui/pin_project/project_replace_unsized_locals.stderr
+++ b/tests/ui/pin_project/project_replace_unsized_locals.stderr
@@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
6 | struct Struct<T: ?Sized> {
| ^^^^^^^-^^^^^^^^^
| | |
- | | this type parameter needs to be `std::marker::Sized`
+ | | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
= note: required because it appears within the type `__StructProjectionOwned<T>`
@@ -14,8 +14,8 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
--> $DIR/project_replace_unsized_locals.rs:7:5
|
6 | struct Struct<T: ?Sized> {
- | - this type parameter needs to be `std::marker::Sized`
-7 | x: T,
+ | - this type parameter needs to be `Sized`
+7 | f: T,
| ^ doesn't have a size known at compile-time
error[E0277]: the size for values of type `T` cannot be known at compilation time
@@ -24,7 +24,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
5 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6 | struct Struct<T: ?Sized> {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: required because it appears within the type `__StructProjectionOwned<T>`
= note: structs must have a statically known size to be initialized
@@ -36,7 +36,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
11 | struct TupleStruct<T: ?Sized>(T);
| ^^^^^^^^^^^^-^^^^^^^^^
| | |
- | | this type parameter needs to be `std::marker::Sized`
+ | | this type parameter needs to be `Sized`
| doesn't have a size known at compile-time
|
= note: required because it appears within the type `__TupleStructProjectionOwned<T>`
@@ -48,6 +48,6 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
10 | #[pin_project(project_replace)] //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
11 | struct TupleStruct<T: ?Sized>(T);
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/proper_unpin.rs b/tests/ui/pin_project/proper_unpin.rs
deleted file mode 100644
index e61789b..0000000
--- a/tests/ui/pin_project/proper_unpin.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use pin_project::pin_project;
-use std::marker::PhantomPinned;
-
-struct Inner<T> {
- val: T,
-}
-
-#[pin_project]
-struct Foo<T, U> {
- #[pin]
- inner: Inner<T>,
- other: U,
-}
-
-#[pin_project]
-struct TrivialBounds {
- #[pin]
- field1: PhantomPinned,
-}
-
-#[pin_project]
-struct Bar<'a, T, U> {
- #[pin]
- inner: &'a mut Inner<T>,
- other: U,
-}
-
-fn is_unpin<T: Unpin>() {}
-
-fn main() {
- is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
- is_unpin::<Foo<(), PhantomPinned>>(); // Ok
- is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
-
- is_unpin::<TrivialBounds>(); //~ ERROR E0277
-
- is_unpin::<Bar<'_, PhantomPinned, PhantomPinned>>(); // Ok
-}
diff --git a/tests/ui/pin_project/proper_unpin.stderr b/tests/ui/pin_project/proper_unpin.stderr
deleted file mode 100644
index 7562597..0000000
--- a/tests/ui/pin_project/proper_unpin.stderr
+++ /dev/null
@@ -1,37 +0,0 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:31:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-31 | is_unpin::<Foo<PhantomPinned, ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned, ()>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
- = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned, ()>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:33:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-33 | is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `Inner<std::marker::PhantomPinned>`
- = note: required because it appears within the type `_::__Foo<'_, std::marker::PhantomPinned, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:35:5
- |
-28 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-35 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__TrivialBounds<'_>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because it appears within the type `_::__TrivialBounds<'_>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
diff --git a/tests/ui/pin_project/remove-attr-from-field.rs b/tests/ui/pin_project/remove-attr-from-field.rs
index 1ecd56f..bec8302 100644
--- a/tests/ui/pin_project/remove-attr-from-field.rs
+++ b/tests/ui/pin_project/remove-attr-from-field.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::remove_attr;
+use auxiliary_macro::remove_attr;
use pin_project::pin_project;
use std::{marker::PhantomPinned, pin::Pin};
@@ -8,25 +8,25 @@ fn is_unpin<T: Unpin>() {}
#[remove_attr(field_all)]
struct A {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
#[remove_attr(field_all)]
#[pin_project]
struct B {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
fn main() {
is_unpin::<A>();
is_unpin::<B>();
- let mut x = A { field: PhantomPinned };
+ let mut x = A { f: PhantomPinned };
let x = Pin::new(&mut x).project();
- let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+ let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
- let mut x = B { field: PhantomPinned };
+ let mut x = B { f: PhantomPinned };
let x = Pin::new(&mut x).project();
- let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
+ let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
}
diff --git a/tests/ui/pin_project/remove-attr-from-field.stderr b/tests/ui/pin_project/remove-attr-from-field.stderr
index 15195e7..5d8caac 100644
--- a/tests/ui/pin_project/remove-attr-from-field.stderr
+++ b/tests/ui/pin_project/remove-attr-from-field.stderr
@@ -1,21 +1,21 @@
error[E0308]: mismatched types
--> $DIR/remove-attr-from-field.rs:27:38
|
-27 | let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
- | ----------------------- ^^^^^^^ expected struct `std::pin::Pin`, found `&mut std::marker::PhantomPinned`
+27 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+ | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned`
| |
| expected due to this
|
- = note: expected struct `std::pin::Pin<&mut std::marker::PhantomPinned>`
- found mutable reference `&mut std::marker::PhantomPinned`
+ = note: expected struct `Pin<&mut PhantomPinned>`
+ found mutable reference `&mut PhantomPinned`
error[E0308]: mismatched types
--> $DIR/remove-attr-from-field.rs:31:38
|
-31 | let _: Pin<&mut PhantomPinned> = x.field; //~ ERROR E0308
- | ----------------------- ^^^^^^^ expected struct `std::pin::Pin`, found `&mut std::marker::PhantomPinned`
+31 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+ | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned`
| |
| expected due to this
|
- = note: expected struct `std::pin::Pin<&mut std::marker::PhantomPinned>`
- found mutable reference `&mut std::marker::PhantomPinned`
+ = note: expected struct `Pin<&mut PhantomPinned>`
+ found mutable reference `&mut PhantomPinned`
diff --git a/tests/ui/pin_project/remove-attr-from-struct.rs b/tests/ui/pin_project/remove-attr-from-struct.rs
index 0c7af63..0086cf9 100644
--- a/tests/ui/pin_project/remove-attr-from-struct.rs
+++ b/tests/ui/pin_project/remove-attr-from-struct.rs
@@ -1,4 +1,4 @@
-use auxiliary_macros::remove_attr;
+use auxiliary_macro::remove_attr;
use pin_project::pin_project;
use std::{marker::PhantomPinned, pin::Pin};
@@ -8,26 +8,26 @@ fn is_unpin<T: Unpin>() {}
#[remove_attr(struct_all)]
struct A {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
- field: PhantomPinned,
+ f: PhantomPinned,
}
#[remove_attr(struct_all)]
#[pin_project]
struct B {
#[pin] //~ ERROR cannot find attribute `pin` in this scope
- field: PhantomPinned,
+ f: PhantomPinned,
}
#[pin_project] //~ ERROR has been removed
#[remove_attr(struct_pin)]
struct C {
- field: PhantomPinned,
+ f: PhantomPinned,
}
#[remove_attr(struct_pin)]
#[pin_project] // Ok
struct D {
- field: PhantomPinned,
+ f: PhantomPinned,
}
fn main() {
@@ -35,12 +35,12 @@ fn main() {
is_unpin::<B>(); //~ ERROR E0277
is_unpin::<D>(); // Ok
- let mut x = A { field: PhantomPinned };
+ let mut x = A { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- let mut x = B { field: PhantomPinned };
+ let mut x = B { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- let mut x = D { field: PhantomPinned };
+ let mut x = D { f: PhantomPinned };
let _ = Pin::new(&mut x).project(); //~ Ok
}
diff --git a/tests/ui/pin_project/remove-attr-from-struct.stderr b/tests/ui/pin_project/remove-attr-from-struct.stderr
index 112584e..97d9c23 100644
--- a/tests/ui/pin_project/remove-attr-from-struct.stderr
+++ b/tests/ui/pin_project/remove-attr-from-struct.stderr
@@ -18,54 +18,54 @@ error: cannot find attribute `pin` in this scope
17 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
| ^^^
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/remove-attr-from-struct.rs:34:5
|
5 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
34 | is_unpin::<A>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^ within `A`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: required because it appears within the type `A`
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/remove-attr-from-struct.rs:35:5
|
5 | fn is_unpin<T: Unpin>() {}
| ----- required by this bound in `is_unpin`
...
35 | is_unpin::<B>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^ within `B`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: required because it appears within the type `B`
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/remove-attr-from-struct.rs:39:13
|
39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^^ within `A`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: required because it appears within the type `A`
- = note: required by `std::pin::Pin::<P>::new`
+ = note: required by `Pin::<P>::new`
-error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut A>` in the current scope
+error[E0599]: no method named `project` found for struct `Pin<&mut A>` in the current scope
--> $DIR/remove-attr-from-struct.rs:39:30
|
39 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^ method not found in `std::pin::Pin<&mut A>`
+ | ^^^^^^^ method not found in `Pin<&mut A>`
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/remove-attr-from-struct.rs:42:13
|
42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^^ within `B`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: required because it appears within the type `B`
- = note: required by `std::pin::Pin::<P>::new`
+ = note: required by `Pin::<P>::new`
-error[E0599]: no method named `project` found for struct `std::pin::Pin<&mut B>` in the current scope
+error[E0599]: no method named `project` found for struct `Pin<&mut B>` in the current scope
--> $DIR/remove-attr-from-struct.rs:42:30
|
42 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
- | ^^^^^^^ method not found in `std::pin::Pin<&mut B>`
+ | ^^^^^^^ method not found in `Pin<&mut B>`
diff --git a/tests/ui/pin_project/safe_packed_borrows.rs b/tests/ui/pin_project/safe_packed_borrows.rs
index c1a7d55..db4ac2d 100644
--- a/tests/ui/pin_project/safe_packed_borrows.rs
+++ b/tests/ui/pin_project/safe_packed_borrows.rs
@@ -1,21 +1,21 @@
-#![deny(safe_packed_borrows)]
+#![forbid(safe_packed_borrows)]
// Refs: https://github.com/rust-lang/rust/issues/46043
#[repr(packed)]
struct A {
- field: u32,
+ f: u32,
}
#[repr(packed(2))]
struct B {
- field: u32,
+ f: u32,
}
fn main() {
- let a = A { field: 1 };
- &a.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ let a = A { f: 1 };
+ &a.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
- let b = B { field: 1 };
- &b.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ let b = B { f: 1 };
+ &b.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
}
diff --git a/tests/ui/pin_project/safe_packed_borrows.stderr b/tests/ui/pin_project/safe_packed_borrows.stderr
index 7b4cc08..c1f734a 100644
--- a/tests/ui/pin_project/safe_packed_borrows.stderr
+++ b/tests/ui/pin_project/safe_packed_borrows.stderr
@@ -1,14 +1,14 @@
error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
--> $DIR/safe_packed_borrows.rs:17:5
|
-17 | &a.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
- | ^^^^^^^^
+17 | &a.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ | ^^^^
|
note: the lint level is defined here
- --> $DIR/safe_packed_borrows.rs:1:9
+ --> $DIR/safe_packed_borrows.rs:1:11
|
-1 | #![deny(safe_packed_borrows)]
- | ^^^^^^^^^^^^^^^^^^^
+1 | #![forbid(safe_packed_borrows)]
+ | ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior
@@ -16,8 +16,8 @@ note: the lint level is defined here
error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
--> $DIR/safe_packed_borrows.rs:20:5
|
-20 | &b.field; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
- | ^^^^^^^^
+20 | &b.f; //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
+ | ^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
diff --git a/tests/ui/pin_project/unpin_sneaky.rs b/tests/ui/pin_project/unpin_sneaky.rs
index 3ccb1a9..3f5f32b 100644
--- a/tests/ui/pin_project/unpin_sneaky.rs
+++ b/tests/ui/pin_project/unpin_sneaky.rs
@@ -1,11 +1,11 @@
use pin_project::pin_project;
#[pin_project]
-struct Foo {
+struct S {
#[pin]
- inner: u8,
+ f: u8,
}
-impl Unpin for __Foo {} //~ ERROR E0412,E0321
+impl Unpin for __S {} //~ ERROR E0412,E0321
fn main() {}
diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr
index 0637a66..ab5e794 100644
--- a/tests/ui/pin_project/unpin_sneaky.stderr
+++ b/tests/ui/pin_project/unpin_sneaky.stderr
@@ -1,11 +1,11 @@
-error[E0412]: cannot find type `__Foo` in this scope
+error[E0412]: cannot find type `__S` in this scope
--> $DIR/unpin_sneaky.rs:9:16
|
-9 | impl Unpin for __Foo {} //~ ERROR E0412,E0321
- | ^^^^^ not found 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 `std::marker::Unpin`, can only be implemented for a struct/enum type, not `[type error]`
+error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]`
--> $DIR/unpin_sneaky.rs:9:1
|
-9 | impl Unpin for __Foo {} //~ ERROR E0412,E0321
- | ^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
+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/pin_project/visibility.rs b/tests/ui/pin_project/visibility.rs
index 01c0831..fdff5a6 100644
--- a/tests/ui/pin_project/visibility.rs
+++ b/tests/ui/pin_project/visibility.rs
@@ -1,23 +1,26 @@
+/// Only named projected types can be imported.
+/// See import_unnamed.rs for unnamed projected types.
+
mod pub_ {
use pin_project::pin_project;
- #[pin_project]
+ #[pin_project(project = DProj, project_ref = DProjRef)]
pub struct Default(());
- #[pin_project(project_replace)]
+ #[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
pub struct Replace(());
}
pub mod pub_use {
#[rustfmt::skip]
- pub use crate::pub_::__DefaultProjection; //~ ERROR E0365
+ pub use crate::pub_::DProj; //~ ERROR E0365
#[rustfmt::skip]
- pub use crate::pub_::__DefaultProjectionRef; //~ ERROR E0365
+ pub use crate::pub_::DProjRef; //~ ERROR E0365
#[rustfmt::skip]
- pub use crate::pub_::__ReplaceProjection; //~ ERROR E0365
+ pub use crate::pub_::RProj; //~ ERROR E0365
#[rustfmt::skip]
- pub use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0365
+ pub use crate::pub_::RProjOwn; //~ ERROR E0365
#[rustfmt::skip]
- pub use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0365
+ pub use crate::pub_::RProjRef; //~ ERROR E0365
// Confirm that the visibility of the original type is not changed.
pub use crate::pub_::{Default, Replace};
@@ -25,58 +28,22 @@ pub mod pub_use {
pub mod pub_use2 {
// Ok
#[allow(unused_imports)]
- pub(crate) use crate::pub_::{
- __DefaultProjection, __DefaultProjectionRef, __ReplaceProjection, __ReplaceProjectionOwned,
- __ReplaceProjectionRef,
- };
+ pub(crate) use crate::pub_::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
}
mod pub_crate {
use pin_project::pin_project;
- #[pin_project]
+ #[pin_project(project = DProj, project_ref = DProjRef)]
pub(crate) struct Default(());
- #[pin_project(project_replace)]
+ #[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
pub(crate) struct Replace(());
}
pub mod pub_crate_use {
// Ok
#[allow(unused_imports)]
- pub(crate) use crate::pub_crate::{
- __DefaultProjection, __DefaultProjectionRef, __ReplaceProjection, __ReplaceProjectionOwned,
- __ReplaceProjectionRef,
- };
-}
-
-mod pub_renamed {
- use pin_project::pin_project;
-
- #[pin_project(project = DProj, project_ref = DProjRef)]
- pub struct Default(());
-
- #[pin_project(project = RProj, project_ref = RProjRef, project_replace = RProjOwn)]
- pub struct Replace(());
-}
-pub mod pub_renamed_use {
- #[rustfmt::skip]
- pub use crate::pub_renamed::DProj; //~ ERROR E0365
- #[rustfmt::skip]
- pub use crate::pub_renamed::DProjRef; //~ ERROR E0365
- #[rustfmt::skip]
- pub use crate::pub_renamed::RProj; //~ ERROR E0365
- #[rustfmt::skip]
- pub use crate::pub_renamed::RProjOwn; //~ ERROR E0365
- #[rustfmt::skip]
- pub use crate::pub_renamed::RProjRef; //~ ERROR E0365
-
- // Confirm that the visibility of the original type is not changed.
- pub use crate::pub_renamed::{Default, Replace};
-}
-pub mod pub_renamed_use2 {
- // Ok
- #[allow(unused_imports)]
- pub(crate) use crate::pub_renamed::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
+ pub(crate) use crate::pub_crate::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
}
fn main() {}
diff --git a/tests/ui/pin_project/visibility.stderr b/tests/ui/pin_project/visibility.stderr
index cab0e2e..a1f0423 100644
--- a/tests/ui/pin_project/visibility.stderr
+++ b/tests/ui/pin_project/visibility.stderr
@@ -1,79 +1,39 @@
-error[E0365]: `__DefaultProjection` is private, and cannot be re-exported
- --> $DIR/visibility.rs:12:13
- |
-12 | pub use crate::pub_::__DefaultProjection; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `__DefaultProjection`
- |
- = note: consider declaring type or module `__DefaultProjection` with `pub`
-
-error[E0365]: `__DefaultProjectionRef` is private, and cannot be re-exported
- --> $DIR/visibility.rs:14:13
- |
-14 | pub use crate::pub_::__DefaultProjectionRef; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `__DefaultProjectionRef`
- |
- = note: consider declaring type or module `__DefaultProjectionRef` with `pub`
-
-error[E0365]: `__ReplaceProjection` is private, and cannot be re-exported
- --> $DIR/visibility.rs:16:13
- |
-16 | pub use crate::pub_::__ReplaceProjection; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `__ReplaceProjection`
- |
- = note: consider declaring type or module `__ReplaceProjection` with `pub`
-
-error[E0365]: `__ReplaceProjectionOwned` is private, and cannot be re-exported
- --> $DIR/visibility.rs:18:13
- |
-18 | pub use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `__ReplaceProjectionOwned`
- |
- = note: consider declaring type or module `__ReplaceProjectionOwned` with `pub`
-
-error[E0365]: `__ReplaceProjectionRef` is private, and cannot be re-exported
- --> $DIR/visibility.rs:20:13
- |
-20 | pub use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `__ReplaceProjectionRef`
- |
- = note: consider declaring type or module `__ReplaceProjectionRef` with `pub`
-
error[E0365]: `DProj` is private, and cannot be re-exported
- --> $DIR/visibility.rs:63:13
+ --> $DIR/visibility.rs:15:13
|
-63 | pub use crate::pub_renamed::DProj; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `DProj`
+15 | pub use crate::pub_::DProj; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^ re-export of private `DProj`
|
= note: consider declaring type or module `DProj` with `pub`
error[E0365]: `DProjRef` is private, and cannot be re-exported
- --> $DIR/visibility.rs:65:13
+ --> $DIR/visibility.rs:17:13
|
-65 | pub use crate::pub_renamed::DProjRef; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `DProjRef`
+17 | pub use crate::pub_::DProjRef; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of private `DProjRef`
|
= note: consider declaring type or module `DProjRef` with `pub`
error[E0365]: `RProj` is private, and cannot be re-exported
- --> $DIR/visibility.rs:67:13
+ --> $DIR/visibility.rs:19:13
|
-67 | pub use crate::pub_renamed::RProj; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProj`
+19 | pub use crate::pub_::RProj; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^ re-export of private `RProj`
|
= note: consider declaring type or module `RProj` with `pub`
error[E0365]: `RProjOwn` is private, and cannot be re-exported
- --> $DIR/visibility.rs:69:13
+ --> $DIR/visibility.rs:21:13
|
-69 | pub use crate::pub_renamed::RProjOwn; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProjOwn`
+21 | pub use crate::pub_::RProjOwn; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProjOwn`
|
= note: consider declaring type or module `RProjOwn` with `pub`
error[E0365]: `RProjRef` is private, and cannot be re-exported
- --> $DIR/visibility.rs:71:13
+ --> $DIR/visibility.rs:23:13
|
-71 | pub use crate::pub_renamed::RProjRef; //~ ERROR E0365
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProjRef`
+23 | pub use crate::pub_::RProjRef; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProjRef`
|
= note: consider declaring type or module `RProjRef` with `pub`
diff --git a/tests/ui/pinned_drop/call-drop-inner.rs b/tests/ui/pinned_drop/call-drop-inner.rs
index c953acb..4171ed5 100644
--- a/tests/ui/pinned_drop/call-drop-inner.rs
+++ b/tests/ui/pinned_drop/call-drop-inner.rs
@@ -3,7 +3,7 @@ use std::pin::Pin;
#[pin_project(PinnedDrop)]
struct Struct {
- dropped: bool,
+ f: bool,
}
#[pinned_drop]
diff --git a/tests/ui/pinned_drop/conditional-drop-impl.rs b/tests/ui/pinned_drop/conditional-drop-impl.rs
index 42d18b7..fecfd50 100644
--- a/tests/ui/pinned_drop/conditional-drop-impl.rs
+++ b/tests/ui/pinned_drop/conditional-drop-impl.rs
@@ -4,7 +4,7 @@ use std::pin::Pin;
// In `Drop` impl, the implementor must specify the same requirement as type definition.
struct DropImpl<T> {
- field: T,
+ f: T,
}
impl<T: Unpin> Drop for DropImpl<T> {
@@ -15,7 +15,7 @@ impl<T: Unpin> Drop for DropImpl<T> {
#[pin_project(PinnedDrop)] //~ ERROR E0277
struct PinnedDropImpl<T> {
#[pin]
- field: T,
+ f: T,
}
#[pinned_drop]
diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr
index ad8fb69..6381a29 100644
--- a/tests/ui/pinned_drop/conditional-drop-impl.stderr
+++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -1,4 +1,4 @@
-error[E0367]: `Drop` impl requires `T: std::marker::Unpin` but the struct it is implemented for does not
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
--> $DIR/conditional-drop-impl.rs:10:9
|
10 | impl<T: Unpin> Drop for DropImpl<T> {
@@ -8,7 +8,7 @@ note: the implementor must specify the same requirement
--> $DIR/conditional-drop-impl.rs:6:1
|
6 | / struct DropImpl<T> {
-7 | | field: T,
+7 | | f: T,
8 | | }
| |_^
@@ -16,11 +16,11 @@ error[E0277]: `T` cannot be unpinned
--> $DIR/conditional-drop-impl.rs:15:15
|
15 | #[pin_project(PinnedDrop)] //~ ERROR E0277
- | ^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `T`
+ | ^^^^^^^^^^ the trait `Unpin` is not implemented for `T`
|
- = note: required because of the requirements on the impl of `pin_project::__private::PinnedDrop` for `PinnedDropImpl<T>`
+ = note: required because of the requirements on the impl of `PinnedDrop` for `PinnedDropImpl<T>`
= note: required by `pin_project::__private::PinnedDrop::drop`
help: consider restricting type parameter `T`
|
-16 | struct PinnedDropImpl<T: std::marker::Unpin> {
- | ^^^^^^^^^^^^^^^^^^^^
+16 | struct PinnedDropImpl<T: Unpin> {
+ | ^^^^^^^
diff --git a/tests/ui/pinned_drop/forget-pinned-drop-impl.rs b/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
index 6c9f718..e31f46f 100644
--- a/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
+++ b/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
@@ -3,7 +3,7 @@ use pin_project::pin_project;
#[pin_project(PinnedDrop)] //~ ERROR E0277
struct Struct {
#[pin]
- field: u8,
+ f: u8,
}
fn main() {}
diff --git a/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr b/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
index 67bdbe1..9fd7cdb 100644
--- a/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
+++ b/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
@@ -1,7 +1,7 @@
-error[E0277]: the trait bound `Struct: pin_project::__private::PinnedDrop` is not satisfied
+error[E0277]: the trait bound `Struct: PinnedDrop` is not satisfied
--> $DIR/forget-pinned-drop-impl.rs:3:15
|
3 | #[pin_project(PinnedDrop)] //~ ERROR E0277
- | ^^^^^^^^^^ the trait `pin_project::__private::PinnedDrop` is not implemented for `Struct`
+ | ^^^^^^^^^^ the trait `PinnedDrop` is not implemented for `Struct`
|
= note: required by `pin_project::__private::PinnedDrop::drop`
diff --git a/tests/ui/pinned_drop/invalid-self.rs b/tests/ui/pinned_drop/invalid-self.rs
index 73d3b43..783167f 100644
--- a/tests/ui/pinned_drop/invalid-self.rs
+++ b/tests/ui/pinned_drop/invalid-self.rs
@@ -2,13 +2,13 @@
use std::pin::Pin;
-struct Struct {}
+struct S {}
-impl Struct {
+impl S {
fn take_ref_self(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
fn take_ref_mut_self(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
- fn self_subpat(self @ Struct {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+ fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
}
fn main() {}
diff --git a/tests/ui/pinned_drop/invalid-self.stderr b/tests/ui/pinned_drop/invalid-self.stderr
index a43e91d..3248704 100644
--- a/tests/ui/pinned_drop/invalid-self.stderr
+++ b/tests/ui/pinned_drop/invalid-self.stderr
@@ -13,13 +13,13 @@ error: expected identifier, found keyword `self`
error: expected parameter name, found `@`
--> $DIR/invalid-self.rs:11:25
|
-11 | fn self_subpat(self @ Struct {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+11 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
| ^ expected parameter name
error: expected one of `)`, `,`, or `:`, found `@`
--> $DIR/invalid-self.rs:11:25
|
-11 | fn self_subpat(self @ Struct {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+11 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
| -^ expected one of `)`, `,`, or `:`
| |
| help: missing `,`
diff --git a/tests/ui/pinned_drop/invalid.rs b/tests/ui/pinned_drop/invalid.rs
index 7065ec9..7e36750 100644
--- a/tests/ui/pinned_drop/invalid.rs
+++ b/tests/ui/pinned_drop/invalid.rs
@@ -48,7 +48,7 @@ mod item {
impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
#[pinned_drop]
- fn drop(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
+ fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
}
mod unsafety {
@@ -200,7 +200,7 @@ mod method {
#[pinned_drop]
impl PinnedDrop for InvalidName {
- fn pinned_drop(&mut self) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop
+ fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop
}
}
diff --git a/tests/ui/pinned_drop/invalid.stderr b/tests/ui/pinned_drop/invalid.stderr
index 65ef9ff..277a2fa 100644
--- a/tests/ui/pinned_drop/invalid.stderr
+++ b/tests/ui/pinned_drop/invalid.stderr
@@ -25,7 +25,7 @@ error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` tr
error: expected `impl`
--> $DIR/invalid.rs:51:5
|
-51 | fn drop(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
+51 | fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
| ^^
error: implementing the trait `PinnedDrop` is not unsafe
@@ -121,7 +121,7 @@ error: method `drop` must take an argument `self: Pin<&mut Self>`
error: method `pinned_drop` is not a member of trait `PinnedDrop
--> $DIR/invalid.rs:203:12
|
-203 | fn pinned_drop(&mut self) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop
+203 | fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop
| ^^^^^^^^^^^
error: implementing the trait `PinnedDrop` on this type is unsupported
diff --git a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
index 1241b5b..f9db79c 100644
--- a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
+++ b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
@@ -2,13 +2,14 @@ use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;
#[pin_project]
-struct Foo {
+struct S {
#[pin]
- field: u8,
+ f: u8,
}
#[pinned_drop]
-impl PinnedDrop for Foo { //~ ERROR E0119
+impl PinnedDrop for S {
+ //~^ ERROR E0119
fn drop(self: Pin<&mut Self>) {}
}
diff --git a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
index 7353dc4..6f868bf 100644
--- a/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
+++ b/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
@@ -1,8 +1,8 @@
-error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `Foo`:
+error[E0119]: conflicting implementations of trait `pin_project::__private::PinnedDrop` for type `S`:
--> $DIR/pinned-drop-no-attr-arg.rs:11:1
|
4 | #[pin_project]
| -------------- first implementation here
...
-11 | impl PinnedDrop for Foo { //~ ERROR E0119
- | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo`
+11 | impl PinnedDrop for S {
+ | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S`
diff --git a/tests/ui/pinned_drop/self.rs b/tests/ui/pinned_drop/self.rs
index 9176066..03825ca 100644
--- a/tests/ui/pinned_drop/self.rs
+++ b/tests/ui/pinned_drop/self.rs
@@ -3,12 +3,12 @@ pub mod self_in_macro_def {
use std::pin::Pin;
#[pin_project(PinnedDrop)]
- pub struct Struct {
- x: (),
+ pub struct S {
+ f: (),
}
#[pinned_drop]
- impl PinnedDrop for Struct {
+ impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
macro_rules! t {
() => {{
@@ -28,7 +28,7 @@ pub mod self_span {
#[pin_project(PinnedDrop)]
pub struct S {
- x: (),
+ f: (),
}
#[pinned_drop]
@@ -41,7 +41,7 @@ pub mod self_span {
#[pin_project(PinnedDrop)]
pub enum E {
- V { x: () },
+ V { f: () },
}
#[pinned_drop]
diff --git a/tests/ui/pinned_drop/self.stderr b/tests/ui/pinned_drop/self.stderr
index 4ac0e63..edab117 100644
--- a/tests/ui/pinned_drop/self.stderr
+++ b/tests/ui/pinned_drop/self.stderr
@@ -26,34 +26,34 @@ error[E0423]: expected value, found struct `S`
--> $DIR/self.rs:38:27
|
30 | / pub struct S {
-31 | | x: (),
+31 | | f: (),
32 | | }
| |_____- `S` defined here
...
38 | let _: Self = Self; //~ ERROR E0423
- | ^^^^ help: use struct literal syntax instead: `S { x: val }`
+ | ^^^^ help: use struct literal syntax instead: `S { f: val }`
error[E0308]: mismatched types
--> $DIR/self.rs:37:25
|
37 | let _: () = self; //~ ERROR E0308
- | -- ^^^^ expected `()`, found struct `std::pin::Pin`
+ | -- ^^^^ expected `()`, found struct `Pin`
| |
| expected due to this
|
= note: expected unit type `()`
- found struct `std::pin::Pin<&mut self_span::S>`
+ found struct `Pin<&mut self_span::S>`
error[E0308]: mismatched types
--> $DIR/self.rs:50:25
|
50 | let _: () = self; //~ ERROR E0308
- | -- ^^^^ expected `()`, found struct `std::pin::Pin`
+ | -- ^^^^ expected `()`, found struct `Pin`
| |
| expected due to this
|
= note: expected unit type `()`
- found struct `std::pin::Pin<&mut self_span::E>`
+ found struct `Pin<&mut E>`
error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V`
--> $DIR/self.rs:51:27
diff --git a/tests/ui/pinned_drop/unsafe-call.rs b/tests/ui/pinned_drop/unsafe-call.rs
index 2f400c1..7faf0fa 100644
--- a/tests/ui/pinned_drop/unsafe-call.rs
+++ b/tests/ui/pinned_drop/unsafe-call.rs
@@ -2,15 +2,15 @@ use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;
#[pin_project(PinnedDrop)]
-struct Struct {
+struct S {
#[pin]
- field: u8,
+ f: u8,
}
#[pinned_drop]
-impl PinnedDrop for Struct {
+impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
- self.project().field.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
+ self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
}
}
diff --git a/tests/ui/pinned_drop/unsafe-call.stderr b/tests/ui/pinned_drop/unsafe-call.stderr
index 4e8e00b..cd5e572 100644
--- a/tests/ui/pinned_drop/unsafe-call.stderr
+++ b/tests/ui/pinned_drop/unsafe-call.stderr
@@ -1,7 +1,7 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/unsafe-call.rs:13:9
|
-13 | self.project().field.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+13 | self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
diff --git a/tests/ui/project/ambiguous-let.rs b/tests/ui/project/ambiguous-let.rs
deleted file mode 100644
index bbb3a2c..0000000
--- a/tests/ui/project/ambiguous-let.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-#![allow(deprecated)]
-
-use pin_project::{pin_project, project};
-
-#[pin_project]
-enum Enum<A, B> {
- A(#[pin] A),
- B(B),
-}
-
-struct Struct<T>(T);
-
-#[project]
-fn foo() {
- let mut foo: Enum<bool, bool> = Enum::A(true);
-
- #[project]
- let Struct(x) = match Pin::new(&mut foo).project() {
- //~^ ERROR Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
- Enum::A(_) => Struct(true),
- Enum::B(_) => unreachable!(),
- };
- assert!(x);
-}
-
-fn main() {}
diff --git a/tests/ui/project/ambiguous-let.stderr b/tests/ui/project/ambiguous-let.stderr
deleted file mode 100644
index 2e66484..0000000
--- a/tests/ui/project/ambiguous-let.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-error: Both initializer expression and pattern are replaceable, you need to split the initializer expression into separate let bindings to avoid ambiguity
- --> $DIR/ambiguous-let.rs:18:9
- |
-18 | let Struct(x) = match Pin::new(&mut foo).project() {
- | ^^^^^^^^^
diff --git a/tests/ui/project/deprecated.rs b/tests/ui/project/deprecated.rs
deleted file mode 100644
index 78d593d..0000000
--- a/tests/ui/project/deprecated.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#![deny(deprecated)]
-
-use pin_project::{project, project_ref, project_replace};
-
-#[project]
-#[project_ref]
-#[project_replace]
-fn main() {}
diff --git a/tests/ui/project/deprecated.stderr b/tests/ui/project/deprecated.stderr
deleted file mode 100644
index 015b8df..0000000
--- a/tests/ui/project/deprecated.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error: use of deprecated item 'project': consider naming projected type by passing `project` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
- --> $DIR/deprecated.rs:5:3
- |
-5 | #[project]
- | ^^^^^^^
- |
-note: the lint level is defined here
- --> $DIR/deprecated.rs:1:9
- |
-1 | #![deny(deprecated)]
- | ^^^^^^^^^^
-
-error: use of deprecated item 'project_ref': consider naming projected type by passing `project_ref` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
- --> $DIR/deprecated.rs:6:3
- |
-6 | #[project_ref]
- | ^^^^^^^^^^^
-
-error: use of deprecated item 'project_replace': consider naming projected type by passing `project_replace` argument to #[pin_project] attribute instead, see release note <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> for details
- --> $DIR/deprecated.rs:7:3
- |
-7 | #[project_replace]
- | ^^^^^^^^^^^^^^^
diff --git a/tests/ui/project/invalid.rs b/tests/ui/project/invalid.rs
deleted file mode 100644
index e72f84c..0000000
--- a/tests/ui/project/invalid.rs
+++ /dev/null
@@ -1,192 +0,0 @@
-#![allow(deprecated)]
-
-mod argument {
- use pin_project::{pin_project, project};
-
- #[pin_project]
- struct A(#[pin] ());
-
- #[project]
- fn unexpected_local1() {
- let mut x = A(());
- #[project()] //~ ERROR unexpected token
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- fn unexpected_local1() {
- let mut x = A(());
- #[project(foo)] //~ ERROR unexpected token
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- fn unexpected_expr1() {
- let mut x = A(());
- #[project()] //~ ERROR unexpected token
- match Pin::new(&mut x).project() {
- A(_) => {}
- }
- }
-
- #[project]
- fn unexpected_expr1() {
- let mut x = A(());
- #[project(foo)] //~ ERROR unexpected token
- match Pin::new(&mut x).project() {
- A(_) => {}
- }
- }
-
- #[project()] // Ok
- fn unexpected_item1() {}
-
- #[project(foo)] //~ ERROR unexpected token
- fn unexpected_item2() {}
-}
-
-mod attribute {
- use pin_project::{pin_project, project, project_ref, project_replace};
-
- #[pin_project(project_replace)]
- struct A(#[pin] ());
-
- #[project]
- fn duplicate_stmt_project() {
- let mut x = A(());
- #[project]
- #[project] //~ ERROR duplicate #[project] attribute
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_ref]
- fn duplicate_stmt_project_ref() {
- let mut x = A(());
- #[project_ref]
- #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_replace]
- fn duplicate_stmt_project_replace() {
- let mut x = A(());
- #[project_replace]
- #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- fn combine_stmt_project1() {
- let mut x = A(());
- #[project]
- #[project_ref] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- fn combine_stmt_project2() {
- let mut x = A(());
- #[project]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- fn combine_stmt_project3() {
- let mut x = A(());
- #[project_ref]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_ref]
- fn combine_stmt_project_ref1() {
- let mut x = A(());
- #[project]
- #[project_ref] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_ref]
- fn combine_stmt_project_ref2() {
- let mut x = A(());
- #[project]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_ref]
- fn combine_stmt_project_ref3() {
- let mut x = A(());
- #[project_ref]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_replace]
- fn combine_stmt_project_replace1() {
- let mut x = A(());
- #[project]
- #[project_ref] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_replace]
- fn combine_stmt_project_replace2() {
- let mut x = A(());
- #[project]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project_replace]
- fn combine_stmt_project_replace3() {
- let mut x = A(());
- #[project_ref]
- #[project_replace] //~ ERROR are mutually exclusive
- let A(_) = Pin::new(&mut x).project();
- }
-
- #[project]
- #[project] //~ ERROR duplicate #[project] attribute
- fn duplicate_fn_project() {}
-
- #[project_ref]
- #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- fn duplicate_fn_project_ref() {}
-
- #[project_replace]
- #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- fn duplicate_fn_project_replace() {}
-
- #[project]
- #[project] //~ ERROR duplicate #[project] attribute
- impl A {}
-
- #[project_ref]
- #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- impl A {}
-
- #[project_replace]
- #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- impl A {}
-
- #[allow(unused_imports)]
- mod use_ {
- use pin_project::{project, project_ref, project_replace};
-
- #[project]
- #[project] //~ ERROR duplicate #[project] attribute
- use super::A;
-
- #[project_ref]
- #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- use super::A;
-
- #[project_replace]
- #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- use super::A;
- }
-}
-
-fn main() {}
diff --git a/tests/ui/project/invalid.stderr b/tests/ui/project/invalid.stderr
deleted file mode 100644
index e1dc388..0000000
--- a/tests/ui/project/invalid.stderr
+++ /dev/null
@@ -1,155 +0,0 @@
-error: unexpected token: ()
- --> $DIR/invalid.rs:12:18
- |
-12 | #[project()] //~ ERROR unexpected token
- | ^^
-
-error: unexpected token: (foo)
- --> $DIR/invalid.rs:19:18
- |
-19 | #[project(foo)] //~ ERROR unexpected token
- | ^^^^^
-
-error: unexpected token: ()
- --> $DIR/invalid.rs:26:18
- |
-26 | #[project()] //~ ERROR unexpected token
- | ^^
-
-error: unexpected token: (foo)
- --> $DIR/invalid.rs:35:18
- |
-35 | #[project(foo)] //~ ERROR unexpected token
- | ^^^^^
-
-error: unexpected token: foo
- --> $DIR/invalid.rs:44:15
- |
-44 | #[project(foo)] //~ ERROR unexpected token
- | ^^^
-
-error: duplicate #[project] attribute
- --> $DIR/invalid.rs:58:9
- |
-58 | #[project] //~ ERROR duplicate #[project] attribute
- | ^^^^^^^^^^
-
-error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:66:9
- |
-66 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- | ^^^^^^^^^^^^^^
-
-error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:74:9
- |
-74 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_ref` are mutually exclusive
- --> $DIR/invalid.rs:82:9
- |
-82 | #[project_ref] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:90:9
- |
-90 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:98:9
- |
-98 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_ref` are mutually exclusive
- --> $DIR/invalid.rs:106:9
- |
-106 | #[project_ref] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:114:9
- |
-114 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:122:9
- |
-122 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_ref` are mutually exclusive
- --> $DIR/invalid.rs:130:9
- |
-130 | #[project_ref] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^
-
-error: attributes `project` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:138:9
- |
-138 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: attributes `project_ref` and `project_replace` are mutually exclusive
- --> $DIR/invalid.rs:146:9
- |
-146 | #[project_replace] //~ ERROR are mutually exclusive
- | ^^^^^^^^^^^^^^^^^^
-
-error: duplicate #[project] attribute
- --> $DIR/invalid.rs:151:5
- |
-151 | #[project] //~ ERROR duplicate #[project] attribute
- | ^^^^^^^^^^
-
-error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:155:5
- |
-155 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- | ^^^^^^^^^^^^^^
-
-error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:159:5
- |
-159 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- | ^^^^^^^^^^^^^^^^^^
-
-error: duplicate #[project] attribute
- --> $DIR/invalid.rs:163:5
- |
-163 | #[project] //~ ERROR duplicate #[project] attribute
- | ^^^^^^^^^^
-
-error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:167:5
- |
-167 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- | ^^^^^^^^^^^^^^
-
-error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:171:5
- |
-171 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- | ^^^^^^^^^^^^^^^^^^
-
-error: duplicate #[project] attribute
- --> $DIR/invalid.rs:179:9
- |
-179 | #[project] //~ ERROR duplicate #[project] attribute
- | ^^^^^^^^^^
-
-error: duplicate #[project_ref] attribute
- --> $DIR/invalid.rs:183:9
- |
-183 | #[project_ref] //~ ERROR duplicate #[project_ref] attribute
- | ^^^^^^^^^^^^^^
-
-error: duplicate #[project_replace] attribute
- --> $DIR/invalid.rs:187:9
- |
-187 | #[project_replace] //~ ERROR duplicate #[project_replace] attribute
- | ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/project/type-mismatch.rs b/tests/ui/project/type-mismatch.rs
deleted file mode 100644
index 0e40c83..0000000
--- a/tests/ui/project/type-mismatch.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-#![allow(deprecated)]
-#![feature(proc_macro_hygiene, stmt_expr_attributes)]
-
-use pin_project::{pin_project, project};
-use std::pin::Pin;
-
-#[project]
-fn type_mismatch() {
- #[pin_project]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut foo = Enum::Variant1(1, 2);
- let mut foo = Pin::new(&mut foo).project();
-
- #[project]
- match &mut foo {
- Enum::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- None => {} //~ ERROR mismatched types
- }
-}
-
-fn type_mismatch_span_issue() {
- #[pin_project]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut foo = Enum::Variant1(1, 2);
- let mut foo = Pin::new(&mut foo).project();
-
- #[project]
- match &mut foo {
- Enum::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- None => {} //~ ERROR mismatched types
- }
-}
-
-fn main() {}
diff --git a/tests/ui/project/type-mismatch.stderr b/tests/ui/project/type-mismatch.stderr
deleted file mode 100644
index 4199c17..0000000
--- a/tests/ui/project/type-mismatch.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/type-mismatch.rs:36:9
- |
-24 | match &mut foo {
- | -------- this expression has type `&mut type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
-...
-36 | None => {} //~ ERROR mismatched types
- | ^^^^ expected enum `type_mismatch::__EnumProjection`, found enum `std::option::Option`
- |
- = note: expected enum `type_mismatch::__EnumProjection<'_, {integer}, {integer}, _, _>`
- found enum `std::option::Option<_>`
-
-error[E0308]: mismatched types
- --> $DIR/type-mismatch.rs:68:9
- |
-56 | match &mut foo {
- | -------- this expression has type `&mut type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
-...
-68 | None => {} //~ ERROR mismatched types
- | ^^^^ expected enum `type_mismatch_span_issue::__EnumProjection`, found enum `std::option::Option`
- |
- = note: expected enum `type_mismatch_span_issue::__EnumProjection<'_, {integer}, {integer}, _, _>`
- found enum `std::option::Option<_>`
diff --git a/tests/ui/project/use-public.rs b/tests/ui/project/use-public.rs
deleted file mode 100644
index aa82a95..0000000
--- a/tests/ui/project/use-public.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#![allow(deprecated)]
-
-use pin_project::pin_project;
-
-#[pin_project]
-struct A {
- field: u8,
-}
-
-pub mod b {
- use pin_project::project;
-
- #[project]
- pub use crate::A; //~ ERROR E0365
-}
-
-fn main() {}
diff --git a/tests/ui/project/use-public.stderr b/tests/ui/project/use-public.stderr
deleted file mode 100644
index 6956656..0000000
--- a/tests/ui/project/use-public.stderr
+++ /dev/null
@@ -1,7 +0,0 @@
-error[E0365]: `__AProjection` is private, and cannot be re-exported
- --> $DIR/use-public.rs:14:13
- |
-14 | pub use crate::A; //~ ERROR E0365
- | ^^^^^^^^ re-export of private `__AProjection`
- |
- = note: consider declaring type or module `__AProjection` with `pub`
diff --git a/tests/ui/project/use.rs b/tests/ui/project/use.rs
deleted file mode 100644
index ba56382..0000000
--- a/tests/ui/project/use.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![allow(deprecated)]
-
-use pin_project::pin_project;
-
-#[pin_project]
-struct A {
- field: u8,
-}
-
-mod b {
- use pin_project::project;
-
- #[project]
- use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
- #[project]
- use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
-}
-
-fn main() {}
diff --git a/tests/ui/project/use.stderr b/tests/ui/project/use.stderr
deleted file mode 100644
index daddb16..0000000
--- a/tests/ui/project/use.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: #[project] attribute may not be used on renamed imports
- --> $DIR/use.rs:14:16
- |
-14 | use crate::A as B; //~ ERROR #[project] attribute may not be used on renamed imports
- | ^^^^^^
-
-error: #[project] attribute may not be used on glob imports
- --> $DIR/use.rs:16:16
- |
-16 | use crate::*; //~ ERROR #[project] attribute may not be used on glob imports
- | ^
diff --git a/tests/ui/unsafe_unpin/conflict-unpin.rs b/tests/ui/unsafe_unpin/conflict-unpin.rs
index e0c8a7b..ac9d1f8 100644
--- a/tests/ui/unsafe_unpin/conflict-unpin.rs
+++ b/tests/ui/unsafe_unpin/conflict-unpin.rs
@@ -3,8 +3,8 @@ use pin_project::pin_project;
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
@@ -12,8 +12,8 @@ impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T, U> Unpin for Bar<T, U> {}
@@ -21,8 +21,8 @@ impl<T, U> Unpin for Bar<T, U> {}
#[pin_project(UnsafeUnpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
- future: T,
- field: U,
+ f1: T,
+ f2: U,
}
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
diff --git a/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs b/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs
deleted file mode 100644
index 429d60f..0000000
--- a/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use pin_project::pin_project;
-
-#[pin_project(UnsafeUnpin)]
-struct Struct<T, U> {
- #[pin]
- inner: T,
- other: U,
-}
-
-fn is_unpin<T: Unpin>() {}
-
-fn main() {
- is_unpin::<Struct<(), ()>>(); //~ ERROR E0277
-}
diff --git a/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr b/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr
deleted file mode 100644
index 0baefe3..0000000
--- a/tests/ui/unsafe_unpin/not-implement-unsafe-unpin.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0277]: the trait bound `Struct<(), ()>: pin_project::UnsafeUnpin` is not satisfied
- --> $DIR/not-implement-unsafe-unpin.rs:13:16
- |
-10 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-13 | is_unpin::<Struct<(), ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^ the trait `pin_project::UnsafeUnpin` is not implemented for `Struct<(), ()>`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Struct<(), ()>>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Struct<(), ()>`
diff --git a/tests/ui/unsafe_unpin/proper_unpin.rs b/tests/ui/unsafe_unpin/proper_unpin.rs
deleted file mode 100644
index 6573aec..0000000
--- a/tests/ui/unsafe_unpin/proper_unpin.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use pin_project::{pin_project, UnsafeUnpin};
-use std::marker::PhantomPinned;
-
-fn is_unpin<T: Unpin>() {}
-
-#[pin_project(UnsafeUnpin)]
-struct Blah<T, U> {
- field1: U,
- #[pin]
- field2: T,
-}
-
-unsafe impl<T: Unpin, U> UnsafeUnpin for Blah<T, U> {}
-
-#[pin_project(UnsafeUnpin)]
-struct TrivialBounds {
- #[pin]
- field1: PhantomPinned,
-}
-
-#[pin_project(UnsafeUnpin)]
-struct OverlappingLifetimeNames<'pin, T, U> {
- #[pin]
- field1: U,
- #[pin]
- field2: Option<T>,
- field3: &'pin (),
-}
-
-unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
-
-fn main() {
- is_unpin::<Blah<PhantomPinned, ()>>(); //~ ERROR E0277
- is_unpin::<Blah<(), PhantomPinned>>(); // Ok
- is_unpin::<Blah<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
-
- is_unpin::<TrivialBounds>(); //~ ERROR E0277
-
- is_unpin::<OverlappingLifetimeNames<'_, PhantomPinned, ()>>(); //~ ERROR E0277
- is_unpin::<OverlappingLifetimeNames<'_, (), PhantomPinned>>(); //~ ERROR E0277
-}
diff --git a/tests/ui/unsafe_unpin/proper_unpin.stderr b/tests/ui/unsafe_unpin/proper_unpin.stderr
deleted file mode 100644
index 410dd0e..0000000
--- a/tests/ui/unsafe_unpin/proper_unpin.stderr
+++ /dev/null
@@ -1,63 +0,0 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:33:5
- |
-4 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-33 | is_unpin::<Blah<PhantomPinned, ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, ()>`
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, ()>>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:35:5
- |
-4 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-35 | is_unpin::<Blah<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>`
-
-error[E0277]: the trait bound `TrivialBounds: pin_project::UnsafeUnpin` is not satisfied
- --> $DIR/proper_unpin.rs:37:16
- |
-4 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-37 | is_unpin::<TrivialBounds>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^ the trait `pin_project::UnsafeUnpin` is not implemented for `TrivialBounds`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, TrivialBounds>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `TrivialBounds`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:39:5
- |
-4 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-39 | is_unpin::<OverlappingLifetimeNames<'_, PhantomPinned, ()>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>`
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>`
-
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/proper_unpin.rs:40:5
- |
-4 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
-40 | is_unpin::<OverlappingLifetimeNames<'_, (), PhantomPinned>>(); //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
- |
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>`
- = note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>>`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>`
diff --git a/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs b/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
index fa4b01e..8860f4f 100644
--- a/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
+++ b/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
@@ -6,7 +6,7 @@ use std::marker::PhantomPinned;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
- x: T,
+ f: T,
}
// unsound Unpin impl
diff --git a/tests/ui/unstable-features/marker_trait_attr.rs b/tests/ui/unstable-features/marker_trait_attr.rs
index 0b8b30a..a6ca357 100644
--- a/tests/ui/unstable-features/marker_trait_attr.rs
+++ b/tests/ui/unstable-features/marker_trait_attr.rs
@@ -12,7 +12,7 @@ use std::marker::PhantomPinned;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
- x: T,
+ f: T,
}
// unsound Unpin impl
diff --git a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
index 0bd4a32..3af3cf0 100644
--- a/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
+++ b/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
@@ -6,7 +6,7 @@ use std::marker::PhantomPinned;
#[pin_project] //~ ERROR E0119
struct Struct<T> {
#[pin]
- x: T,
+ f: T,
}
// unsound Unpin impl
diff --git a/tests/ui/unstable-features/overlapping_marker_traits.rs b/tests/ui/unstable-features/overlapping_marker_traits.rs
index 27d37a3..c897d1c 100644
--- a/tests/ui/unstable-features/overlapping_marker_traits.rs
+++ b/tests/ui/unstable-features/overlapping_marker_traits.rs
@@ -16,7 +16,7 @@ use std::marker::PhantomPinned;
#[pin_project]
struct Struct<T> {
#[pin]
- x: T,
+ f: T,
}
// unsound Unpin impl
diff --git a/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs b/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
deleted file mode 100644
index 2b6377a..0000000
--- a/tests/ui/unstable-features/run-pass/stmt_expr_attributes.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-// NB: If you change this test, change 'stmt_expr_attributes-feature-gate.rs' at the same time.
-
-#![allow(deprecated)]
-// proc_macro_hygiene
-// Tracking issue: https://github.com/rust-lang/rust/issues/54727
-#![feature(proc_macro_hygiene)]
-// stmt_expr_attributes
-// Tracking issue: https://github.com/rust-lang/rust/issues/15701
-#![feature(stmt_expr_attributes)]
-
-use pin_project::{pin_project, project};
-use std::pin::Pin;
-
-fn project_stmt_expr_nightly() {
- #[pin_project]
- enum Baz<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut baz = Baz::Variant1(1, 2);
-
- let mut baz = Pin::new(&mut baz).project();
-
- #[project]
- match &mut baz {
- Baz::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Baz::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- Baz::None => {}
- }
-
- let () = #[project]
- match &mut baz {
- Baz::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Baz::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- Baz::None => {}
- };
-}
-
-fn main() {}
diff --git a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
deleted file mode 100644
index 5dbe523..0000000
--- a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-// NB: If you change this test, change 'stmt_expr_attributes.rs' at the same time.
-
-#![allow(deprecated)]
-
-use pin_project::{pin_project, project};
-use std::pin::Pin;
-
-fn project_stmt_expr_nightly() {
- #[pin_project]
- enum Enum<A, B, C, D> {
- Variant1(#[pin] A, B),
- Variant2 {
- #[pin]
- field1: C,
- field2: D,
- },
- None,
- }
-
- let mut baz = Enum::Variant1(1, 2);
-
- let mut baz = Pin::new(&mut baz).project();
-
- #[project] //~ ERROR E0658
- match &mut baz {
- Enum::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- Enum::None => {}
- }
-
- let () = #[project] //~ ERROR E0658
- match &mut baz {
- Enum::Variant1(x, y) => {
- let x: &mut Pin<&mut i32> = x;
- assert_eq!(**x, 1);
-
- let y: &mut &mut i32 = y;
- assert_eq!(**y, 2);
- }
- Enum::Variant2 { field1, field2 } => {
- let _x: &mut Pin<&mut i32> = field1;
- let _y: &mut &mut i32 = field2;
- }
- Enum::None => {}
- };
-}
-
-fn main() {}
diff --git a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr b/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
deleted file mode 100644
index 3c0501a..0000000
--- a/tests/ui/unstable-features/stmt_expr_attributes-feature-gate.stderr
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0658]: attributes on expressions are experimental
- --> $DIR/stmt_expr_attributes-feature-gate.rs:24:5
- |
-24 | #[project] //~ ERROR E0658
- | ^^^^^^^^^^
- |
- = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
- = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
-
-error[E0658]: attributes on expressions are experimental
- --> $DIR/stmt_expr_attributes-feature-gate.rs:40:14
- |
-40 | let () = #[project] //~ ERROR E0658
- | ^^^^^^^^^^
- |
- = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
- = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
-
-error[E0658]: custom attributes cannot be applied to expressions
- --> $DIR/stmt_expr_attributes-feature-gate.rs:24:5
- |
-24 | #[project] //~ ERROR E0658
- | ^^^^^^^^^^
- |
- = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
- = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
-
-error[E0658]: custom attributes cannot be applied to expressions
- --> $DIR/stmt_expr_attributes-feature-gate.rs:40:14
- |
-40 | let () = #[project] //~ ERROR E0658
- | ^^^^^^^^^^
- |
- = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
- = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
diff --git a/tests/ui/unstable-features/trivial_bounds-bug.stderr b/tests/ui/unstable-features/trivial_bounds-bug.stderr
index 8370c45..fff09f9 100644
--- a/tests/ui/unstable-features/trivial_bounds-bug.stderr
+++ b/tests/ui/unstable-features/trivial_bounds-bug.stderr
@@ -1,5 +1,5 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/trivial_bounds-bug.rs:13:43
|
13 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
- | ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
diff --git a/tests/ui/unstable-features/trivial_bounds-feature-gate.rs b/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
index 0453a3f..ccdb182 100644
--- a/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
+++ b/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
@@ -21,8 +21,7 @@ mod phantom_pinned {
struct C(PhantomPinned);
- impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {}
- // Ok
+ impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {} // Ok
}
mod inner {
diff --git a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
index 70450dc..dd151b0 100644
--- a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
+++ b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
@@ -1,45 +1,45 @@
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/trivial_bounds-feature-gate.rs:8:5
|
8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
|
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/trivial_bounds-feature-gate.rs:8:43
|
8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
- | ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
+error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/trivial_bounds-feature-gate.rs:16:5
|
16 | impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `phantom_pinned::Wrapper<std::marker::PhantomPinned>`
+ = note: required because of the requirements on the impl of `Unpin` for `phantom_pinned::Wrapper<PhantomPinned>`
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/trivial_bounds-feature-gate.rs:35:5
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:34:5
|
-35 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `inner::Inner`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+34 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because it appears within the type `inner::Inner`
+ = note: required because it appears within the type `Inner`
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
-error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
- --> $DIR/trivial_bounds-feature-gate.rs:43:5
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> $DIR/trivial_bounds-feature-gate.rs:42:5
|
-43 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `inner::Inner`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
+42 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned`
|
- = note: required because it appears within the type `inner::Inner`
- = note: required because of the requirements on the impl of `std::marker::Unpin` for `inner::Wrapper<inner::Inner>`
+ = note: required because it appears within the type `Inner`
+ = note: required because of the requirements on the impl of `Unpin` for `inner::Wrapper<Inner>`
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
diff --git a/tests/ui/unstable-features/trivial_bounds.stderr b/tests/ui/unstable-features/trivial_bounds.stderr
index 03d0161..6a3bb94 100644
--- a/tests/ui/unstable-features/trivial_bounds.stderr
+++ b/tests/ui/unstable-features/trivial_bounds.stderr
@@ -1,4 +1,4 @@
-error: Trait bound inner::Inner: std::marker::Unpin does not depend on any type or lifetime parameters
+error: Trait bound Inner: Unpin does not depend on any type or lifetime parameters
--> $DIR/trivial_bounds.rs:15:35
|
15 | impl Unpin for A where Inner: Unpin {} //~ ERROR std::marker::Unpin does not depend on any type or lifetime parameters
@@ -10,7 +10,7 @@ note: the lint level is defined here
6 | #![deny(trivial_bounds)]
| ^^^^^^^^^^^^^^
-error: Trait bound inner::Wrapper<inner::Inner>: std::marker::Unpin does not depend on any type or lifetime parameters
+error: Trait bound Wrapper<Inner>: Unpin does not depend on any type or lifetime parameters
--> $DIR/trivial_bounds.rs:23:44
|
23 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR std::marker::Unpin does not depend on any type or lifetime parameters
diff --git a/tests/unsafe_unpin.rs b/tests/unsafe_unpin.rs
index 5e0e7cf..1bd6c0b 100644
--- a/tests/unsafe_unpin.rs
+++ b/tests/unsafe_unpin.rs
@@ -1,53 +1,49 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
-use pin_project::{pin_project, UnsafeUnpin};
-use std::{marker::PhantomPinned, pin::Pin};
+#[macro_use]
+mod auxiliary;
-fn is_unpin<T: Unpin>() {}
+use pin_project::{pin_project, UnsafeUnpin};
+use std::marker::PhantomPinned;
#[pin_project(UnsafeUnpin)]
pub struct Blah<T, U> {
- field1: U,
+ f1: U,
#[pin]
- field2: T,
+ f2: T,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Blah<T, U> {}
+assert_unpin!(Blah<(), ()>);
+assert_unpin!(Blah<(), PhantomPinned>);
+assert_not_unpin!(Blah<PhantomPinned, ()>);
+assert_not_unpin!(Blah<PhantomPinned, PhantomPinned>);
+
#[pin_project(UnsafeUnpin)]
-pub struct OverlappingLifetimeNames<'pin, T, U> {
+struct OverlappingLifetimeNames<'pin, T, U> {
+ #[pin]
+ f1: U,
#[pin]
- field1: T,
- field2: U,
- field3: &'pin (),
+ f2: Option<T>,
+ f3: &'pin (),
}
-unsafe impl<T: Unpin, U> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
+unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
-#[test]
-fn unsafe_unpin() {
- is_unpin::<Blah<(), PhantomPinned>>();
- is_unpin::<OverlappingLifetimeNames<'_, (), ()>>();
-}
+assert_unpin!(OverlappingLifetimeNames<'_, (), ()>);
+assert_not_unpin!(OverlappingLifetimeNames<'_, PhantomPinned, ()>);
+assert_not_unpin!(OverlappingLifetimeNames<'_, (), PhantomPinned>);
+assert_not_unpin!(OverlappingLifetimeNames<'_, PhantomPinned, PhantomPinned>);
#[test]
fn trivial_bounds() {
#[pin_project(UnsafeUnpin)]
pub struct NotImplementUnsafUnpin {
#[pin]
- field: PhantomPinned,
+ f: PhantomPinned,
}
-}
-#[test]
-fn test() {
- let mut x = OverlappingLifetimeNames { field1: 0, field2: 1, field3: &() };
- let x = Pin::new(&mut x);
- let y = x.as_ref().project_ref();
- let _: Pin<&u8> = y.field1;
- let _: &u8 = y.field2;
- let y = x.project();
- let _: Pin<&mut u8> = y.field1;
- let _: &mut u8 = y.field2;
+ assert_not_unpin!(NotImplementUnsafUnpin);
}