Upgrade rust/crates/pin-project to 0.4.17 am: 2960bb3286

Change-Id: Ia4acb7aa09766cc098c3a4301f4f0068915f6fd1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 89b20e6..816bd88 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,31 +23,22 @@
     name: test
     strategy:
       matrix:
-        include:
+        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.
-          - build: 1.34.0
-            rust: 1.34.0
-          - build: 1.36.0
-            rust: 1.36.0
-          - build: 1.37.0
-            rust: 1.37.0
-          - build: stable
-            rust: stable
-          - build: beta
-            rust: beta
-          - build: nightly
+          # 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
             rust: nightly
           # pin-project itself has no platform-dependent implementation.
           # macOS is only used to check that pin-project can interoperate
           # correctly with `#[cfg()]`.
-          - build: macos
-            os: macos
+          - os: macos
             rust: nightly
-          # - build: windows
-          #   os: windows
-          #   rust: nightly
     runs-on: ${{ matrix.os || 'ubuntu' }}-latest
     steps:
       - uses: actions/checkout@master
@@ -58,32 +49,40 @@
         if: matrix.rust == 'nightly'
         run: |
           cargo install cargo-hack
-      - name: Install cargo-expand
-        if: matrix.rust == 'nightly' && matrix.build != 'macos'
-        run: |
-          cargo install cargo-expand
       - name: Add targets
         if: matrix.rust == 'nightly'
         run: |
           rustup target add thumbv7m-none-eabi
-      - name: cargo test (stable)
-        if: matrix.rust != 'nightly'
+      - name: cargo test
         run: |
           cargo test --all --all-features --exclude expandtest
-      - name: cargo test (nightly)
+      - name: cargo test (compiletest)
         if: matrix.rust == 'nightly'
         run: |
-          cargo test --all --all-features -- -Zunstable-options --include-ignored
-      - name: cargo check --target thumbv7m-none-eabi
+          cargo test -p pin-project --all-features --test compiletest -- --ignored
+      - name: cargo check (no-std)
         if: matrix.rust == 'nightly'
         run: |
           cargo check --target thumbv7m-none-eabi --manifest-path tests/no-std/Cargo.toml
-      # Refs: https://github.com/rust-lang/cargo/issues/5657
-      - name: cargo check -Zminimal-versions
+      - name: cargo check (minimal versions)
         if: matrix.rust == 'nightly'
         run: |
-          cargo update -Zminimal-versions
-          cargo hack check --all --all-features --no-dev-deps --ignore-private
+          . ./ci/check-minimal-versions.sh
+
+  expandtest:
+    name: expandtest
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@master
+      - name: Install Rust
+        run: |
+          . ./ci/install-rust.sh
+      - name: Install cargo-expand
+        run: |
+          cargo install cargo-expand
+      - name: cargo test (expandtest)
+        run: |
+          cargo test --all-features --manifest-path tests/expand/Cargo.toml
 
   style:
     name: style
@@ -101,7 +100,6 @@
         run: |
           . ./ci/install-rust.sh
       - name: Install component
-        if: matrix.component != 'rustdoc'
         run: |
           . ./ci/install-component.sh ${{ matrix.component }}
       - name: cargo clippy
@@ -115,12 +113,13 @@
       - name: cargo doc
         if: matrix.component == 'rustdoc'
         env:
-          # TODO: once https://github.com/rust-lang/rust/issues/70814 fixed, remove '-Aunused_braces'
-          RUSTDOCFLAGS: -Dwarnings -Aunused_braces
+          RUSTDOCFLAGS: -Dwarnings
         run: |
           cargo doc --no-deps --all --all-features
 
-  # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149
+  # 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.
   #
   # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
 
@@ -130,6 +129,7 @@
     needs:
       - style
       - test
+      - expandtest
     runs-on: ubuntu-latest
     steps:
       - name: Mark the job as a success
@@ -140,6 +140,7 @@
     needs:
       - style
       - test
+      - expandtest
     runs-on: ubuntu-latest
     steps:
       - name: Mark the job as a failure
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28f705c..ed7cfbc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,32 @@
 
 ## [Unreleased]
 
+## [0.4.17] - 2020-05-18
+
+* [Allowed naming the projected types.][202]
+
+  By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:
+
+  ```rust
+  use pin_project::pin_project;
+  use std::pin::Pin;
+
+  #[pin_project(project = EnumProj)]
+  enum Enum<T> {
+      Variant(#[pin] T),
+  }
+
+  fn func<T>(x: Pin<&mut Enum<T>>) {
+      match x.project() {
+          EnumProj::Variant(y) => {
+              let _: Pin<&mut T> = y;
+          }
+      }
+  }
+  ```
+
+[202]: https://github.com/taiki-e/pin-project/pull/202
+
 ## [0.4.16] - 2020-05-11
 
 * [Fixed an issue that users can call internal function generated by `#[pinned_drop]`.][223]
@@ -411,7 +437,8 @@
 
 Initial release
 
-[Unreleased]: https://github.com/taiki-e/pin-project/compare/v0.4.16...HEAD
+[Unreleased]: https://github.com/taiki-e/pin-project/compare/v0.4.17...HEAD
+[0.4.17]: https://github.com/taiki-e/pin-project/compare/v0.4.16...v0.4.17
 [0.4.16]: https://github.com/taiki-e/pin-project/compare/v0.4.15...v0.4.16
 [0.4.15]: https://github.com/taiki-e/pin-project/compare/v0.4.14...v0.4.15
 [0.4.14]: https://github.com/taiki-e/pin-project/compare/v0.4.13...v0.4.14
diff --git a/Cargo.toml b/Cargo.toml
index 39280ab..df64f70 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
 [package]
 edition = "2018"
 name = "pin-project"
-version = "0.4.16"
+version = "0.4.17"
 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,5 @@
 [package.metadata.docs.rs]
 targets = ["x86_64-unknown-linux-gnu"]
 [dependencies.pin-project-internal]
-version = "=0.4.16"
+version = "=0.4.17"
 default-features = false
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index c886996..3c43001 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "pin-project"
-version = "0.4.16"
+version = "0.4.17"
 authors = ["Taiki Endo <te316e89@gmail.com>"]
 edition = "2018"
 license = "Apache-2.0 OR MIT"
@@ -27,5 +27,5 @@
 ]
 
 [dependencies]
-pin-project-internal = { version = "=0.4.16", path = "pin-project-internal", default-features = false }
+pin-project-internal = { version = "=0.4.17", path = "pin-project-internal", default-features = false }
 
diff --git a/METADATA b/METADATA
index 7c1feb9..09ca0bf 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@
     type: GIT
     value: "https://github.com/taiki-e/pin-project"
   }
-  version: "0.4.16"
+  version: "0.4.17"
   license_type: NOTICE
   last_upgrade_date {
     year: 2020
     month: 5
-    day: 11
+    day: 18
   }
 }
diff --git a/ci/check-minimal-versions.sh b/ci/check-minimal-versions.sh
new file mode 100644
index 0000000..a11d2cb
--- /dev/null
+++ b/ci/check-minimal-versions.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Check all public crates with minimal version dependencies.
+#
+# Note that this script modifies Cargo.toml and Cargo.lock and does not restore
+# them after a run.
+#
+# 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
+
+# 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
diff --git a/ci/install-component.sh b/ci/install-component.sh
index de08b8f..37ccdfa 100644
--- a/ci/install-component.sh
+++ b/ci/install-component.sh
@@ -4,7 +4,7 @@
 
 component="${1}"
 
-if ! rustup component add "${component}" 2>/dev/null; then
+if [[ "${component}" != "rustdoc" ]] && ! 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
diff --git a/examples/enum-default-expanded.rs b/examples/enum-default-expanded.rs
index 036c01f..845645a 100644
--- a/examples/enum-default-expanded.rs
+++ b/examples/enum-default-expanded.rs
@@ -5,7 +5,7 @@
 //
 // use pin_project::pin_project;
 //
-// #[pin_project]
+// #[pin_project(project = EnumProj)]
 // enum Enum<T, U> {
 //     Pinned(#[pin] T),
 //     Unpinned(U),
@@ -24,11 +24,10 @@
     Unpinned(U),
 }
 
-#[doc(hidden)]
 #[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`.
 #[allow(dead_code)] // This lint warns unused fields/variants.
 #[allow(single_use_lifetimes)]
-enum __EnumProjection<'pin, T, U>
+enum EnumProj<'pin, T, U>
 where
     Enum<T, U>: 'pin,
 {
@@ -53,13 +52,13 @@
     impl<T, U> Enum<T, U> {
         fn project<'pin>(
             self: ::pin_project::__reexport::pin::Pin<&'pin mut Self>,
-        ) -> __EnumProjection<'pin, T, U> {
+        ) -> EnumProj<'pin, T, U> {
             unsafe {
                 match self.get_unchecked_mut() {
-                    Enum::Pinned(_0) => __EnumProjection::Pinned(
-                        ::pin_project::__reexport::pin::Pin::new_unchecked(_0),
-                    ),
-                    Enum::Unpinned(_0) => __EnumProjection::Unpinned(_0),
+                    Enum::Pinned(_0) => {
+                        EnumProj::Pinned(::pin_project::__reexport::pin::Pin::new_unchecked(_0))
+                    }
+                    Enum::Unpinned(_0) => EnumProj::Unpinned(_0),
                 }
             }
         }
diff --git a/examples/enum-default.rs b/examples/enum-default.rs
index ab5a4bc..bd3f2e6 100644
--- a/examples/enum-default.rs
+++ b/examples/enum-default.rs
@@ -4,7 +4,7 @@
 
 use pin_project::pin_project;
 
-#[pin_project]
+#[pin_project(project = EnumProj)]
 enum Enum<T, U> {
     Pinned(#[pin] T),
     Unpinned(U),
diff --git a/src/lib.rs b/src/lib.rs
index 45c58fa..42005cc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,15 +34,15 @@
 
 #![no_std]
 #![recursion_limit = "256"]
-#![doc(html_root_url = "https://docs.rs/pin-project/0.4.16")]
+#![doc(html_root_url = "https://docs.rs/pin-project/0.4.17")]
 #![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(clippy::all, clippy::default_trait_access)]
-// mem::take requires Rust 1.40
-#![allow(clippy::mem_replace_with_default)]
+// mem::take and #[non_exhaustive] requires Rust 1.40
+#![allow(clippy::mem_replace_with_default, clippy::manual_non_exhaustive)]
 #![allow(clippy::needless_doctest_main)]
 
 #[doc(inline)]
diff --git a/tests/pin_project.rs b/tests/pin_project.rs
index c84ca4b..72bcd15 100644
--- a/tests/pin_project.rs
+++ b/tests/pin_project.rs
@@ -9,7 +9,12 @@
 
 #[test]
 fn projection() {
-    #[pin_project(Replace)]
+    #[pin_project(
+        Replace,
+        project = StructProj,
+        project_ref = StructProjRef,
+        project_replace = StructProjOwn,
+    )]
     struct Struct<T, U> {
         #[pin]
         field1: T,
@@ -31,16 +36,16 @@
 
     let mut s = Struct { field1: 1, field2: 2 };
 
-    let __StructProjection { field1, field2 } = Pin::new(&mut s).project();
+    let StructProj { field1, field2 } = Pin::new(&mut s).project();
     let _: Pin<&mut i32> = field1;
     let _: &mut i32 = field2;
 
-    let __StructProjectionRef { field1, field2 } = Pin::new(&s).project_ref();
+    let StructProjRef { field1, field2 } = Pin::new(&s).project_ref();
     let _: Pin<&i32> = field1;
     let _: &i32 = field2;
 
     let mut s = Pin::new(&mut s);
-    let __StructProjectionOwned { field1, field2 } =
+    let StructProjOwn { field1, field2 } =
         s.as_mut().project_replace(Struct { field1: 3, field2: 4 });
     let _: PhantomData<i32> = field1;
     let _: i32 = field2;
@@ -60,7 +65,7 @@
     let y: &mut i32 = s.1;
     assert_eq!(*y, 2);
 
-    #[pin_project(Replace)]
+    #[pin_project(Replace, project = EnumProj)]
     #[derive(Eq, PartialEq, Debug)]
     enum Enum<A, B, C, D> {
         Variant1(#[pin] A, B),
@@ -77,18 +82,18 @@
     let e = e_orig.as_mut().project();
 
     match e {
-        __EnumProjection::Variant1(x, y) => {
+        EnumProj::Variant1(x, y) => {
             let x: Pin<&mut i32> = x;
             assert_eq!(*x, 1);
 
             let y: &mut i32 = y;
             assert_eq!(*y, 2);
         }
-        __EnumProjection::Variant2 { field1, field2 } => {
+        EnumProj::Variant2 { field1, field2 } => {
             let _x: Pin<&mut i32> = field1;
             let _y: &mut i32 = field2;
         }
-        __EnumProjection::None => {}
+        EnumProj::None => {}
     }
 
     assert_eq!(Pin::into_ref(e_orig).get_ref(), &Enum::Variant1(1, 2));
@@ -97,21 +102,21 @@
     let mut e = Pin::new(&mut e).project();
 
     match &mut e {
-        __EnumProjection::Variant1(x, y) => {
+        EnumProj::Variant1(x, y) => {
             let _x: &mut Pin<&mut i32> = x;
             let _y: &mut &mut i32 = y;
         }
-        __EnumProjection::Variant2 { field1, field2 } => {
+        EnumProj::Variant2 { field1, field2 } => {
             let x: &mut Pin<&mut i32> = field1;
             assert_eq!(**x, 3);
 
             let y: &mut &mut i32 = field2;
             assert_eq!(**y, 4);
         }
-        __EnumProjection::None => {}
+        EnumProj::None => {}
     }
 
-    if let __EnumProjection::Variant2 { field1, field2 } = e {
+    if let EnumProj::Variant2 { field1, field2 } = e {
         let x: Pin<&mut i32> = field1;
         assert_eq!(*x, 3);
 
@@ -122,7 +127,7 @@
 
 #[test]
 fn enum_project_set() {
-    #[pin_project(Replace)]
+    #[pin_project(Replace, project = EnumProj)]
     #[derive(Eq, PartialEq, Debug)]
     enum Enum {
         Variant1(#[pin] u8),
@@ -134,7 +139,7 @@
     let e_proj = e_orig.as_mut().project();
 
     match e_proj {
-        __EnumProjection::Variant1(val) => {
+        EnumProj::Variant1(val) => {
             let new_e = Enum::Variant2(val.as_ref().get_ref() == &25);
             e_orig.set(new_e);
         }
@@ -409,7 +414,7 @@
         unpinned: U,
     }
 
-    #[pin_project(Replace)]
+    #[pin_project(Replace, project = EnumProj, project_ref = EnumProjRef)]
     enum Enum<T, U> {
         Variant {
             #[pin]
@@ -439,12 +444,12 @@
     impl<T, U> Enum<T, U> {
         fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
             match self.project_ref() {
-                __EnumProjectionRef::Variant { pinned, .. } => pinned,
+                EnumProjRef::Variant { pinned, .. } => pinned,
             }
         }
         fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
             match self.project() {
-                __EnumProjection::Variant { pinned, .. } => pinned,
+                EnumProj::Variant { pinned, .. } => pinned,
             }
         }
     }
@@ -467,7 +472,7 @@
         unpinned: U,
     }
 
-    #[pin_project(Replace)]
+    #[pin_project(Replace, project = EnumProj, project_ref = EnumProjRef)]
     enum Enum<T, U> {
         Variant {
             #[pin]
@@ -497,12 +502,12 @@
     impl<T, U> Enum<T, U> {
         fn get_pin_ref(self: Pin<&Self>) -> Pin<&T> {
             match self.project_ref() {
-                __EnumProjectionRef::Variant { pinned, .. } => pinned,
+                EnumProjRef::Variant { pinned, .. } => pinned,
             }
         }
         fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
             match self.project() {
-                __EnumProjection::Variant { pinned, .. } => pinned,
+                EnumProj::Variant { pinned, .. } => pinned,
             }
         }
     }
diff --git a/tests/ui/pin_project/conflict-naming.rs b/tests/ui/pin_project/conflict-naming.rs
new file mode 100644
index 0000000..1cb50b4
--- /dev/null
+++ b/tests/ui/pin_project/conflict-naming.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
+struct Struct(#[pin] ());
+
+fn main() {}
diff --git a/tests/ui/pin_project/conflict-naming.stderr b/tests/ui/pin_project/conflict-naming.stderr
new file mode 100644
index 0000000..bbac1eb
--- /dev/null
+++ b/tests/ui/pin_project/conflict-naming.stderr
@@ -0,0 +1,21 @@
+error[E0428]: the name `A` is defined multiple times
+ --> $DIR/conflict-naming.rs:3:1
+  |
+3 | #[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
+  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+  | |
+  | `A` redefined here
+  | previous definition of the type `A` here
+  |
+  = note: `A` must be defined only once in the type namespace of this module
+  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0308]: mismatched types
+ --> $DIR/conflict-naming.rs:3:1
+  |
+3 | #[pin_project(project = A, project_ref = A)] //~ ERROR E0428,E0308
+  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
+  |
+  = note: expected mutable reference `&mut ()`
+                     found reference `&()`
+  = 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/invalid.rs b/tests/ui/pin_project/invalid.rs
index 1d05608..d7911df 100644
--- a/tests/ui/pin_project/invalid.rs
+++ b/tests/ui/pin_project/invalid.rs
@@ -118,6 +118,18 @@
     #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
     struct Duplicate4(#[pin] ());
 
+    #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
+    struct DuplicateProject(#[pin] ());
+
+    #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
+    struct DuplicateProjectRef(#[pin] ());
+
+    #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+    struct DuplicateProjectReplace(#[pin] ());
+
+    #[pin_project(project_replace = A)] //~ ERROR `project_replace` argument can only be used together with `Replace` argument
+    struct ProjectReplaceWithoutReplace(#[pin] ());
+
     #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
     struct PinnedDropWithReplace1(#[pin] ());
 
@@ -135,6 +147,24 @@
 
     #[pin_project(Unpin)] //~ ERROR unexpected argument
     struct NotUnpin2(#[pin] ());
+
+    #[pin_project(project)] //~ ERROR expected `=`
+    struct Project1(#[pin] ());
+
+    #[pin_project(project = )] //~ ERROR unexpected end of input, expected identifier
+    struct Project2(#[pin] ());
+
+    #[pin_project(project_ref)] //~ ERROR expected `=`
+    struct ProjectRef1(#[pin] ());
+
+    #[pin_project(project_ref = )] //~ ERROR unexpected end of input, expected identifier
+    struct ProjectRef2(#[pin] ());
+
+    #[pin_project(project_replace)] //~ ERROR expected `=`
+    struct ProjectReplace1(#[pin] ());
+
+    #[pin_project(project_replace = )] //~ ERROR unexpected end of input, expected identifier
+    struct ProjectReplace2(#[pin] ());
 }
 
 mod pin_project_attribute {
diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr
index 95b57f0..82026aa 100644
--- a/tests/ui/pin_project/invalid.stderr
+++ b/tests/ui/pin_project/invalid.stderr
@@ -118,111 +118,183 @@
 118 |     #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
     |                                            ^^^^^^^^^^
 
-error: arguments `PinnedDrop` and `Replace` are mutually exclusive
-   --> $DIR/invalid.rs:121:19
+error: duplicate `project` argument
+   --> $DIR/invalid.rs:121:32
     |
-121 |     #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
+121 |     #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
+    |                                ^^^^^^^
+
+error: duplicate `project_ref` argument
+   --> $DIR/invalid.rs:124:36
+    |
+124 |     #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
+    |                                    ^^^^^^^^^^^
+
+error: duplicate `project_replace` argument
+   --> $DIR/invalid.rs:127:40
+    |
+127 |     #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+    |                                        ^^^^^^^^^^^^^^^
+
+error: `project_replace` argument can only be used together with `Replace` argument
+   --> $DIR/invalid.rs:130:19
+    |
+130 |     #[pin_project(project_replace = A)] //~ ERROR `project_replace` argument can only be used together with `Replace` argument
+    |                   ^^^^^^^^^^^^^^^
+
+error: arguments `PinnedDrop` and `Replace` are mutually exclusive
+   --> $DIR/invalid.rs:133:19
+    |
+133 |     #[pin_project(PinnedDrop, Replace)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
     |                   ^^^^^^^^^^
 
 error: arguments `PinnedDrop` and `Replace` are mutually exclusive
-   --> $DIR/invalid.rs:124:41
+   --> $DIR/invalid.rs:136:41
     |
-124 |     #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
+136 |     #[pin_project(Replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `Replace` are mutually exclusive
     |                                         ^^^^^^^^^^
 
 error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
-   --> $DIR/invalid.rs:127:19
+   --> $DIR/invalid.rs:139:19
     |
-127 |     #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+139 |     #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
     |                   ^^^^^^^^^^^
 
 error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
-   --> $DIR/invalid.rs:130:39
+   --> $DIR/invalid.rs:142:39
     |
-130 |     #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+142 |     #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
     |                                       ^^^^^^^^^^^
 
 error: unexpected end of input, expected `Unpin`
-   --> $DIR/invalid.rs:133:5
+   --> $DIR/invalid.rs:145:5
     |
-133 |     #[pin_project(!)] //~ ERROR unexpected end of input, expected `Unpin`
+145 |     #[pin_project(!)] //~ ERROR unexpected end of input, expected `Unpin`
     |     ^^^^^^^^^^^^^^^^^
     |
     = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unexpected argument: Unpin
-   --> $DIR/invalid.rs:136:19
+   --> $DIR/invalid.rs:148:19
     |
-136 |     #[pin_project(Unpin)] //~ ERROR unexpected argument
+148 |     #[pin_project(Unpin)] //~ ERROR unexpected argument
     |                   ^^^^^
 
-error: duplicate #[pin_project] attribute
-   --> $DIR/invalid.rs:144:5
+error: expected `=`
+   --> $DIR/invalid.rs:151:5
     |
-144 |     #[pin_project] //~ ERROR duplicate #[pin_project] attribute
+151 |     #[pin_project(project)] //~ ERROR expected `=`
+    |     ^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected end of input, expected identifier
+   --> $DIR/invalid.rs:154:5
+    |
+154 |     #[pin_project(project = )] //~ ERROR unexpected end of input, expected identifier
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `=`
+   --> $DIR/invalid.rs:157:5
+    |
+157 |     #[pin_project(project_ref)] //~ ERROR expected `=`
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected end of input, expected identifier
+   --> $DIR/invalid.rs:160:5
+    |
+160 |     #[pin_project(project_ref = )] //~ ERROR unexpected end of input, expected identifier
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `=`
+   --> $DIR/invalid.rs:163:5
+    |
+163 |     #[pin_project(project_replace)] //~ ERROR expected `=`
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected end of input, expected identifier
+   --> $DIR/invalid.rs:166:5
+    |
+166 |     #[pin_project(project_replace = )] //~ ERROR unexpected end of input, expected identifier
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    |
+    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: duplicate #[pin_project] attribute
+   --> $DIR/invalid.rs:174:5
+    |
+174 |     #[pin_project] //~ ERROR duplicate #[pin_project] attribute
     |     ^^^^^^^^^^^^^^
 
 error: #[pin_project] attribute may not be used on structs with zero fields
-   --> $DIR/invalid.rs:152:19
+   --> $DIR/invalid.rs:182:19
     |
-152 |     struct Struct {} //~ ERROR may not be used on structs with zero fields
+182 |     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:155:23
+   --> $DIR/invalid.rs:185:23
     |
-155 |     struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
+185 |     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:158:12
+   --> $DIR/invalid.rs:188:12
     |
-158 |     struct UnitStruct; //~ ERROR may not be used on structs with zero fields
+188 |     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:161:20
+   --> $DIR/invalid.rs:191:20
     |
-161 |     enum EnumEmpty {} //~ ERROR may not be used on enums without variants
+191 |     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:165:13
+   --> $DIR/invalid.rs:195:13
     |
-165 |         V = 2, //~ ERROR may not be used on enums with discriminants
+195 |         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:170:9
+   --> $DIR/invalid.rs:200:9
     |
-170 | /         Unit, //~ ERROR may not be used on enums with zero fields
-171 | |         Tuple(),
-172 | |         Struct {},
+200 | /         Unit, //~ ERROR may not be used on enums with zero fields
+201 | |         Tuple(),
+202 | |         Struct {},
     | |__________________^
 
 error: #[pin_project] attribute may only be used on structs or enums
-   --> $DIR/invalid.rs:176:5
+   --> $DIR/invalid.rs:206:5
     |
-176 | /     union Union {
-177 | |         //~^ ERROR may only be used on structs or enums
-178 | |         f: (),
-179 | |     }
+206 | /     union Union {
+207 | |         //~^ ERROR may only be used on structs or enums
+208 | |         f: (),
+209 | |     }
     | |_____^
 
 error: #[pin_project] attribute may not be used on #[repr(packed)] types
-   --> $DIR/invalid.rs:187:12
+   --> $DIR/invalid.rs:217:12
     |
-187 |     #[repr(packed)]
+217 |     #[repr(packed)]
     |            ^^^^^^
 
 error: #[pin_project] attribute may not be used on #[repr(packed)] types
-   --> $DIR/invalid.rs:191:12
+   --> $DIR/invalid.rs:221:12
     |
-191 |     #[repr(packed)]
+221 |     #[repr(packed)]
     |            ^^^^^^
 
 error: #[pin_project] attribute may not be used on #[repr(packed)] types
-   --> $DIR/invalid.rs:195:12
+   --> $DIR/invalid.rs:225:12
     |
-195 |     #[repr(packed)]
+225 |     #[repr(packed)]
     |            ^^^^^^
diff --git a/tests/ui/pin_project/visibility.rs b/tests/ui/pin_project/visibility.rs
index 4f0cb1b..7dce6ab 100644
--- a/tests/ui/pin_project/visibility.rs
+++ b/tests/ui/pin_project/visibility.rs
@@ -49,4 +49,34 @@
     };
 }
 
+mod pub_renamed {
+    use pin_project::pin_project;
+
+    #[pin_project(project = DProj, project_ref = DProjRef)]
+    pub struct Default(());
+
+    #[pin_project(Replace, 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};
+}
+
 fn main() {}
diff --git a/tests/ui/pin_project/visibility.stderr b/tests/ui/pin_project/visibility.stderr
index 1ea60d7..cab0e2e 100644
--- a/tests/ui/pin_project/visibility.stderr
+++ b/tests/ui/pin_project/visibility.stderr
@@ -37,3 +37,43 @@
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
+   |
+63 |     pub use crate::pub_renamed::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
+   |
+65 |     pub use crate::pub_renamed::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
+   |
+67 |     pub use crate::pub_renamed::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
+   |
+69 |     pub use crate::pub_renamed::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
+   |
+71 |     pub use crate::pub_renamed::RProjRef; //~ ERROR E0365
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ re-export of private `RProjRef`
+   |
+   = note: consider declaring type or module `RProjRef` with `pub`
diff --git a/tests/ui/unstable-features/trivial_bounds-bug.stderr b/tests/ui/unstable-features/trivial_bounds-bug.stderr
index 7ddf10c..8370c45 100644
--- a/tests/ui/unstable-features/trivial_bounds-bug.stderr
+++ b/tests/ui/unstable-features/trivial_bounds-bug.stderr
@@ -3,8 +3,3 @@
     |
 13  |     impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
     |                                           ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
-    |
-   ::: /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/marker.rs:736:1
-    |
-736 | pub auto trait Unpin {}
-    | -------------------- required by this bound in `std::marker::Unpin`
diff --git a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
index 31196a2..70450dc 100644
--- a/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
+++ b/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
@@ -12,11 +12,6 @@
     |
 8   |     impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
     |                                           ^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
-    |
-   ::: /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/marker.rs:736:1
-    |
-736 | pub auto trait Unpin {}
-    | -------------------- required by this bound in `std::marker::Unpin`
 
 error[E0277]: `std::marker::PhantomPinned` cannot be unpinned
   --> $DIR/trivial_bounds-feature-gate.rs:16:5