summaryrefslogtreecommitdiffstats
path: root/third_party/rust/pin-project
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/pin-project
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--third_party/rust/pin-project-internal/.cargo-checksum.json1
-rw-r--r--third_party/rust/pin-project-internal/Cargo.toml51
-rw-r--r--third_party/rust/pin-project-internal/LICENSE-APACHE177
-rw-r--r--third_party/rust/pin-project-internal/LICENSE-MIT23
-rw-r--r--third_party/rust/pin-project-internal/src/lib.rs584
-rw-r--r--third_party/rust/pin-project-internal/src/pin_project/args.rs254
-rw-r--r--third_party/rust/pin-project-internal/src/pin_project/attribute.rs65
-rw-r--r--third_party/rust/pin-project-internal/src/pin_project/derive.rs1127
-rw-r--r--third_party/rust/pin-project-internal/src/pin_project/mod.rs17
-rw-r--r--third_party/rust/pin-project-internal/src/pinned_drop.rs226
-rw-r--r--third_party/rust/pin-project-internal/src/utils.rs402
-rw-r--r--third_party/rust/pin-project-lite/.cargo-checksum.json1
-rw-r--r--third_party/rust/pin-project-lite/CHANGELOG.md222
-rw-r--r--third_party/rust/pin-project-lite/Cargo.toml45
-rw-r--r--third_party/rust/pin-project-lite/LICENSE-APACHE177
-rw-r--r--third_party/rust/pin-project-lite/LICENSE-MIT23
-rw-r--r--third_party/rust/pin-project-lite/README.md125
-rw-r--r--third_party/rust/pin-project-lite/src/lib.rs1559
-rw-r--r--third_party/rust/pin-project-lite/tests/README.md46
-rw-r--r--third_party/rust/pin-project-lite/tests/auxiliary/mod.rs12
-rw-r--r--third_party/rust/pin-project-lite/tests/compiletest.rs15
-rw-r--r--third_party/rust/pin-project-lite/tests/drop_order.rs169
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/default/enum.expanded.rs127
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/default/enum.rs17
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/default/struct.expanded.rs84
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/default/struct.rs11
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/multifields/enum.expanded.rs88
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/multifields/enum.rs18
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/multifields/struct.expanded.rs152
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/multifields/struct.rs15
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-all.expanded.rs127
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-all.rs17
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.expanded.rs57
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.rs15
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-none.expanded.rs26
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-none.rs14
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.expanded.rs57
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.rs15
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-all.expanded.rs117
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-all.rs14
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.expanded.rs84
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.rs12
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-none.expanded.rs84
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-none.rs11
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.expanded.rs84
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.rs12
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.expanded.rs95
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.rs22
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.expanded.rs92
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.rs17
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pub/enum.expanded.rs87
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pub/enum.rs16
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pub/struct.expanded.rs84
-rw-r--r--third_party/rust/pin-project-lite/tests/expand/pub/struct.rs11
-rw-r--r--third_party/rust/pin-project-lite/tests/expandtest.rs43
-rw-r--r--third_party/rust/pin-project-lite/tests/include/basic.rs35
-rw-r--r--third_party/rust/pin-project-lite/tests/lint.rs263
-rw-r--r--third_party/rust/pin-project-lite/tests/proper_unpin.rs67
-rw-r--r--third_party/rust/pin-project-lite/tests/test.rs695
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.rs15
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.stderr16
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.rs40
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.stderr50
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.rs93
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.stderr428
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.rs25
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.stderr59
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.rs10
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.stderr75
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.rs20
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.stderr33
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/packed.rs21
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/packed.stderr57
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.rs12
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.stderr11
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.rs27
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.stderr79
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs17
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr22
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs26
-rw-r--r--third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr38
-rw-r--r--third_party/rust/pin-project/.cargo-checksum.json1
-rw-r--r--third_party/rust/pin-project/CHANGELOG.md758
-rw-r--r--third_party/rust/pin-project/Cargo.lock222
-rw-r--r--third_party/rust/pin-project/Cargo.toml54
-rw-r--r--third_party/rust/pin-project/LICENSE-APACHE177
-rw-r--r--third_party/rust/pin-project/LICENSE-MIT23
-rw-r--r--third_party/rust/pin-project/README.md99
-rw-r--r--third_party/rust/pin-project/examples/README.md39
-rw-r--r--third_party/rust/pin-project/examples/enum-default-expanded.rs101
-rw-r--r--third_party/rust/pin-project/examples/enum-default.rs13
-rw-r--r--third_party/rust/pin-project/examples/not_unpin-expanded.rs125
-rw-r--r--third_party/rust/pin-project/examples/not_unpin.rs17
-rw-r--r--third_party/rust/pin-project/examples/pinned_drop-expanded.rs154
-rw-r--r--third_party/rust/pin-project/examples/pinned_drop.rs23
-rw-r--r--third_party/rust/pin-project/examples/project_replace-expanded.rs156
-rw-r--r--third_party/rust/pin-project/examples/project_replace.rs14
-rw-r--r--third_party/rust/pin-project/examples/struct-default-expanded.rs155
-rw-r--r--third_party/rust/pin-project/examples/struct-default.rs14
-rw-r--r--third_party/rust/pin-project/examples/unsafe_unpin-expanded.rs107
-rw-r--r--third_party/rust/pin-project/examples/unsafe_unpin.rs16
-rw-r--r--third_party/rust/pin-project/src/lib.rs315
-rw-r--r--third_party/rust/pin-project/tests/README.md44
-rw-r--r--third_party/rust/pin-project/tests/auxiliary/mod.rs12
-rw-r--r--third_party/rust/pin-project/tests/cfg.rs184
-rw-r--r--third_party/rust/pin-project/tests/compiletest.rs16
-rw-r--r--third_party/rust/pin-project/tests/drop_order.rs162
-rw-r--r--third_party/rust/pin-project/tests/expand/default/enum.expanded.rs145
-rw-r--r--third_party/rust/pin-project/tests/expand/default/enum.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/default/struct.expanded.rs104
-rw-r--r--third_party/rust/pin-project/tests/expand/default/struct.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs98
-rw-r--r--third_party/rust/pin-project/tests/expand/default/tuple_struct.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs268
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/enum.rs17
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs155
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/struct.rs13
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs145
-rw-r--r--third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs204
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-all.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs99
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-mut.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs56
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-none.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs119
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-own.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs100
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/enum-ref.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs163
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-all.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs114
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-mut.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs104
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-none.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs143
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-own.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs114
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/struct-ref.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs148
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs105
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs98
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs134
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs105
-rw-r--r--third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs139
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/enum.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs99
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/struct.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs93
-rw-r--r--third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs157
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs23
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs116
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs19
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs110
-rw-r--r--third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs15
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs119
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/enum.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs133
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/struct.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs127
-rw-r--r--third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs145
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/enum.rs14
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs104
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/struct.rs10
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs98
-rw-r--r--third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs6
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs129
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs16
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs89
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs12
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs83
-rw-r--r--third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs8
-rw-r--r--third_party/rust/pin-project/tests/expandtest.rs43
-rw-r--r--third_party/rust/pin-project/tests/include/basic-safe-part.rs193
-rw-r--r--third_party/rust/pin-project/tests/include/basic.rs17
-rw-r--r--third_party/rust/pin-project/tests/lint.rs1190
-rw-r--r--third_party/rust/pin-project/tests/pin_project.rs887
-rw-r--r--third_party/rust/pin-project/tests/pinned_drop.rs284
-rw-r--r--third_party/rust/pin-project/tests/proper_unpin.rs153
-rw-r--r--third_party/rust/pin-project/tests/repr_packed.rs52
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs25
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs15
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs15
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs12
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/unsupported.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.stderr26
-rw-r--r--third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs20
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr15
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr52
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr19
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs37
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.stderr29
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/invalid.rs280
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr364
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs19
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr25
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.rs32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed-enum.rs24
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed-enum.stderr42
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.rs27
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed.rs33
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed.stderr23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs41
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr25
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs12
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr13
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.rs32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.rs15
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.stderr16
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs23
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr17
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.stderr118
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.rs13
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.stderr112
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs33
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr21
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs47
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr107
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs26
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr11
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.rs21
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.stderr26
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs11
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/visibility.rs49
-rw-r--r--third_party/rust/pin-project/tests/ui/pin_project/visibility.stderr39
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.rs17
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.stderr16
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.rs27
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.stderr28
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs9
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr5
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.rs14
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.stderr25
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs231
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr143
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs17
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr8
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/self.rs58
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr62
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.rs18
-rw-r--r--third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.stderr7
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.stderr32
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/README.md7
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs20
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs26
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs23
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr19
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs20
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr10
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs30
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr18
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs53
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr59
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs38
-rw-r--r--third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr23
-rw-r--r--third_party/rust/pin-project/tests/unsafe_unpin.rs50
287 files changed, 23514 insertions, 0 deletions
diff --git a/third_party/rust/pin-project-internal/.cargo-checksum.json b/third_party/rust/pin-project-internal/.cargo-checksum.json
new file mode 100644
index 0000000000..db974b518b
--- /dev/null
+++ b/third_party/rust/pin-project-internal/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"ae1169ef7f2dc32d4b461732284ad5d66019fd3d2a5897254c240759b61e675d","LICENSE-APACHE":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/lib.rs":"3c1b4ae774d0c05d74997e5f88fe43d95162df14f5eaf6ebbf03ca92b2ebdf7d","src/pin_project/args.rs":"903be7b22a2eda4ed59d890feb75bd4c98e243b4faaa809aff0621d15cd06431","src/pin_project/attribute.rs":"3e392493e875f0c935525579ba9bd888d8e00b57b3d6594b7fde040c31790784","src/pin_project/derive.rs":"0060e78285d89f5807126eb7f3d8a721dd4592a9e070ca0cda2f6cf2bf34e27b","src/pin_project/mod.rs":"83e6fc982a8c136811332512abc7d368e5d09b94f245de5d19490f835e85943a","src/pinned_drop.rs":"f3d386e00ce2fe25fc817ac57f07569f9e43a519e12d977db39f4c239be4dcf4","src/utils.rs":"24372d39be74fb9b6728bca08d74ed0a8ed7915de97ada6b20ebb6243ae6eed0"},"package":"069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"} \ No newline at end of file
diff --git a/third_party/rust/pin-project-internal/Cargo.toml b/third_party/rust/pin-project-internal/Cargo.toml
new file mode 100644
index 0000000000..b2f5450923
--- /dev/null
+++ b/third_party/rust/pin-project-internal/Cargo.toml
@@ -0,0 +1,51 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+rust-version = "1.37"
+name = "pin-project-internal"
+version = "1.0.12"
+description = """
+Implementation detail of the `pin-project` crate.
+"""
+keywords = [
+ "pin",
+ "macros",
+ "attribute",
+]
+categories = [
+ "no-std",
+ "rust-patterns",
+]
+license = "Apache-2.0 OR MIT"
+repository = "https://github.com/taiki-e/pin-project"
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]
+
+[lib]
+proc-macro = true
+
+[dependencies.proc-macro2]
+version = "1"
+
+[dependencies.quote]
+version = "1"
+
+[dependencies.syn]
+version = "1.0.56"
+features = [
+ "full",
+ "visit-mut",
+]
+
+[dev-dependencies]
diff --git a/third_party/rust/pin-project-internal/LICENSE-APACHE b/third_party/rust/pin-project-internal/LICENSE-APACHE
new file mode 100644
index 0000000000..f433b1a53f
--- /dev/null
+++ b/third_party/rust/pin-project-internal/LICENSE-APACHE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/third_party/rust/pin-project-internal/LICENSE-MIT b/third_party/rust/pin-project-internal/LICENSE-MIT
new file mode 100644
index 0000000000..31aa79387f
--- /dev/null
+++ b/third_party/rust/pin-project-internal/LICENSE-MIT
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/third_party/rust/pin-project-internal/src/lib.rs b/third_party/rust/pin-project-internal/src/lib.rs
new file mode 100644
index 0000000000..07683c417e
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/lib.rs
@@ -0,0 +1,584 @@
+//! Implementation detail of the `pin-project` crate. - **do not use directly**
+
+#![doc(test(
+ no_crate_inject,
+ attr(
+ deny(warnings, rust_2018_idioms, single_use_lifetimes),
+ allow(dead_code, unused_variables)
+ )
+))]
+#![forbid(unsafe_code)]
+#![warn(rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
+#![warn(clippy::pedantic)]
+#![allow(
+ clippy::needless_doctest_main,
+ clippy::similar_names,
+ clippy::single_match_else,
+ clippy::too_many_lines,
+ clippy::unnested_or_patterns
+)]
+
+// older compilers require explicit `extern crate`.
+#[allow(unused_extern_crates)]
+extern crate proc_macro;
+
+#[macro_use]
+mod utils;
+
+mod pin_project;
+mod pinned_drop;
+
+use proc_macro::TokenStream;
+
+/// An attribute that creates projection types covering all the fields of
+/// struct or enum.
+///
+/// This attribute creates projection types according to the following rules:
+///
+/// - For the fields that use `#[pin]` attribute, create the pinned reference to
+/// the field.
+/// - For the other fields, create a normal reference to the field.
+///
+/// And the following methods are implemented on the original type:
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// # type Projection<'a> = &'a ();
+/// # type ProjectionRef<'a> = &'a ();
+/// # trait Dox {
+/// fn project(self: Pin<&mut Self>) -> Projection<'_>;
+/// fn project_ref(self: Pin<&Self>) -> ProjectionRef<'_>;
+/// # }
+/// ```
+///
+/// By passing an argument with the same name as the method to the attribute,
+/// you can name the projection type returned from the method. This allows you
+/// to use pattern matching on the projected types.
+///
+/// ```rust
+/// # use pin_project::pin_project;
+/// # use std::pin::Pin;
+/// #[pin_project(project = EnumProj)]
+/// enum Enum<T> {
+/// Variant(#[pin] T),
+/// }
+///
+/// impl<T> Enum<T> {
+/// fn method(self: Pin<&mut Self>) {
+/// let this: EnumProj<'_, T> = self.project();
+/// match this {
+/// EnumProj::Variant(x) => {
+/// let _: Pin<&mut T> = x;
+/// }
+/// }
+/// }
+/// }
+/// ```
+///
+/// Note that the projection types returned by `project` and `project_ref` have
+/// an additional lifetime at the beginning of generics.
+///
+/// ```text
+/// let this: EnumProj<'_, T> = self.project();
+/// ^^
+/// ```
+///
+/// The visibility of the projected types and projection methods is based on the
+/// original type. However, if the visibility of the original type is `pub`, the
+/// visibility of the projected types and the projection methods is downgraded
+/// to `pub(crate)`.
+///
+/// # Safety
+///
+/// This attribute is completely safe. In the absence of other `unsafe` code
+/// *that you write*, it is impossible to cause [undefined
+/// behavior][undefined-behavior] with this attribute.
+///
+/// This is accomplished by enforcing the four requirements for pin projection
+/// stated in [the Rust documentation][pin-projection]:
+///
+/// 1. The struct must only be [`Unpin`] if all the structural fields are
+/// [`Unpin`].
+///
+/// To enforce this, this attribute will automatically generate an [`Unpin`]
+/// implementation for you, which will require that all structurally pinned
+/// fields be [`Unpin`].
+///
+/// If you attempt to provide an [`Unpin`] impl, the blanket impl will then
+/// apply to your type, causing a compile-time error due to the conflict with
+/// the second impl.
+///
+/// If you wish to provide a manual [`Unpin`] impl, you can do so via the
+/// [`UnsafeUnpin`][unsafe-unpin] argument.
+///
+/// 2. The destructor of the struct must not move structural fields out of its
+/// argument.
+///
+/// To enforce this, this attribute will generate code like this:
+///
+/// ```rust
+/// struct MyStruct {}
+/// trait MyStructMustNotImplDrop {}
+/// # #[allow(unknown_lints, drop_bounds)]
+/// impl<T: Drop> MyStructMustNotImplDrop for T {}
+/// impl MyStructMustNotImplDrop for MyStruct {}
+/// ```
+///
+/// If you attempt to provide an [`Drop`] impl, the blanket impl will then
+/// apply to your type, causing a compile-time error due to the conflict with
+/// the second impl.
+///
+/// If you wish to provide a custom [`Drop`] impl, you can annotate an impl
+/// with [`#[pinned_drop]`][pinned-drop]. This impl takes a pinned version of
+/// your struct - that is, [`Pin`]`<&mut MyStruct>` where `MyStruct` is the
+/// type of your struct.
+///
+/// You can call `.project()` on this type as usual, along with any other
+/// methods you have defined. Because your code is never provided with
+/// a `&mut MyStruct`, it is impossible to move out of pin-projectable
+/// fields in safe code in your destructor.
+///
+/// 3. You must make sure that you uphold the [`Drop`
+/// guarantee][drop-guarantee]: once your struct is pinned, the memory that
+/// contains the content is not overwritten or deallocated without calling
+/// the content's destructors.
+///
+/// Safe code doesn't need to worry about this - the only way to violate
+/// this requirement is to manually deallocate memory (which is `unsafe`),
+/// or to overwrite a field with something else.
+/// Because your custom destructor takes [`Pin`]`<&mut MyStruct>`, it's
+/// impossible to obtain a mutable reference to a pin-projected field in safe
+/// code.
+///
+/// 4. You must not offer any other operations that could lead to data being
+/// moved out of the structural fields when your type is pinned.
+///
+/// As with requirement 3, it is impossible for safe code to violate this.
+/// This crate ensures that safe code can never obtain a mutable reference to
+/// `#[pin]` fields, which prevents you from ever moving out of them in safe
+/// code.
+///
+/// Pin projections are also incompatible with [`#[repr(packed)]`][repr-packed]
+/// types. Attempting to use this attribute on a `#[repr(packed)]` type results
+/// in a compile-time error.
+///
+/// # Examples
+///
+/// `#[pin_project]` can be used on structs and enums.
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project]
+/// struct Struct<T, U> {
+/// #[pin]
+/// pinned: T,
+/// unpinned: U,
+/// }
+///
+/// impl<T, U> Struct<T, U> {
+/// fn method(self: Pin<&mut Self>) {
+/// let this = self.project();
+/// let _: Pin<&mut T> = this.pinned;
+/// let _: &mut U = this.unpinned;
+/// }
+/// }
+/// ```
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project]
+/// struct TupleStruct<T, U>(#[pin] T, U);
+///
+/// impl<T, U> TupleStruct<T, U> {
+/// fn method(self: Pin<&mut Self>) {
+/// let this = self.project();
+/// let _: Pin<&mut T> = this.0;
+/// let _: &mut U = this.1;
+/// }
+/// }
+/// ```
+///
+/// To use `#[pin_project]` on enums, you need to name the projection type
+/// returned from the method.
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project(project = EnumProj)]
+/// enum Enum<T, U> {
+/// Tuple(#[pin] T),
+/// Struct { field: U },
+/// Unit,
+/// }
+///
+/// impl<T, U> Enum<T, U> {
+/// fn method(self: Pin<&mut Self>) {
+/// match self.project() {
+/// EnumProj::Tuple(x) => {
+/// let _: Pin<&mut T> = x;
+/// }
+/// EnumProj::Struct { field } => {
+/// let _: &mut U = field;
+/// }
+/// EnumProj::Unit => {}
+/// }
+/// }
+/// }
+/// ```
+///
+/// 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.
+/// For example, in the above example, only the `project` method is generated,
+/// and the `project_ref` method is not generated.
+/// (When `#[pin_project]` is used on structs, both methods are always generated.)
+///
+/// ```rust,compile_fail,E0599
+/// # use pin_project::pin_project;
+/// # use std::pin::Pin;
+/// #
+/// # #[pin_project(project = EnumProj)]
+/// # enum Enum<T, U> {
+/// # Tuple(#[pin] T),
+/// # Struct { field: U },
+/// # Unit,
+/// # }
+/// #
+/// impl<T, U> Enum<T, U> {
+/// fn call_project_ref(self: Pin<&Self>) {
+/// let _this = self.project_ref();
+/// //~^ ERROR no method named `project_ref` found for struct `Pin<&Enum<T, U>>` in the current scope
+/// }
+/// }
+/// ```
+///
+/// If you want to call `.project()` multiple times or later use the
+/// original [`Pin`] type, it needs to use [`.as_mut()`][`Pin::as_mut`] to avoid
+/// consuming the [`Pin`].
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project]
+/// struct Struct<T> {
+/// #[pin]
+/// field: T,
+/// }
+///
+/// impl<T> Struct<T> {
+/// fn call_project_twice(mut self: Pin<&mut Self>) {
+/// // `project` consumes `self`, so reborrow the `Pin<&mut Self>` via `as_mut`.
+/// self.as_mut().project();
+/// self.as_mut().project();
+/// }
+/// }
+/// ```
+///
+/// # `!Unpin`
+///
+/// If you want to ensure that [`Unpin`] is not implemented, use the `!Unpin`
+/// argument to `#[pin_project]`.
+///
+/// ```rust
+/// use pin_project::pin_project;
+///
+/// #[pin_project(!Unpin)]
+/// struct Struct<T> {
+/// field: T,
+/// }
+/// ```
+///
+/// This is equivalent to using `#[pin]` attribute for the [`PhantomPinned`]
+/// field.
+///
+/// ```rust
+/// use std::marker::PhantomPinned;
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project]
+/// struct Struct<T> {
+/// field: T,
+/// #[pin] // <------ This `#[pin]` is required to make `Struct` to `!Unpin`.
+/// _pin: PhantomPinned,
+/// }
+/// ```
+///
+/// Note that using [`PhantomPinned`] without `#[pin]` attribute has no effect.
+///
+/// # `UnsafeUnpin`
+///
+/// If you want to implement [`Unpin`] manually, you must use the `UnsafeUnpin`
+/// argument to `#[pin_project]`.
+///
+/// ```rust
+/// use pin_project::{pin_project, UnsafeUnpin};
+///
+/// #[pin_project(UnsafeUnpin)]
+/// struct Struct<T, U> {
+/// #[pin]
+/// pinned: T,
+/// unpinned: U,
+/// }
+///
+/// unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+/// ```
+///
+/// Note the usage of the unsafe [`UnsafeUnpin`] trait, instead of the usual
+/// [`Unpin`] trait. [`UnsafeUnpin`] behaves exactly like [`Unpin`], except that
+/// is unsafe to implement. This unsafety comes from the fact that pin
+/// projections are being used. If you implement [`UnsafeUnpin`], you must
+/// ensure that it is only implemented when all pin-projected fields implement
+/// [`Unpin`].
+///
+/// See [`UnsafeUnpin`] trait for more details.
+///
+/// # `#[pinned_drop]`
+///
+/// In order to correctly implement pin projections, a type's [`Drop`] impl must
+/// not move out of any structurally pinned fields. Unfortunately,
+/// [`Drop::drop`] takes `&mut Self`, not [`Pin`]`<&mut Self>`.
+///
+/// To ensure that this requirement is upheld, the `#[pin_project]` attribute
+/// will provide a [`Drop`] impl for you. This [`Drop`] impl will delegate to
+/// an impl block annotated with `#[pinned_drop]` if you use the `PinnedDrop`
+/// argument to `#[pin_project]`.
+///
+/// This impl block acts just like a normal [`Drop`] impl,
+/// except for the following two:
+///
+/// - `drop` method takes [`Pin`]`<&mut Self>`
+/// - Name of the trait is `PinnedDrop`.
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// pub trait PinnedDrop {
+/// fn drop(self: Pin<&mut Self>);
+/// }
+/// ```
+///
+/// `#[pin_project]` implements the actual [`Drop`] trait via `PinnedDrop` you
+/// implemented. To drop a type that implements `PinnedDrop`, use the [`drop`]
+/// function just like dropping a type that directly implements [`Drop`].
+///
+/// In particular, it will never be called more than once, just like
+/// [`Drop::drop`].
+///
+/// For example:
+///
+/// ```rust
+/// use std::{fmt::Debug, pin::Pin};
+///
+/// use pin_project::{pin_project, pinned_drop};
+///
+/// #[pin_project(PinnedDrop)]
+/// struct PrintOnDrop<T: Debug, U: Debug> {
+/// #[pin]
+/// pinned_field: T,
+/// unpin_field: U,
+/// }
+///
+/// #[pinned_drop]
+/// impl<T: Debug, U: Debug> PinnedDrop for PrintOnDrop<T, U> {
+/// fn drop(self: Pin<&mut Self>) {
+/// println!("Dropping pinned field: {:?}", self.pinned_field);
+/// println!("Dropping unpin field: {:?}", self.unpin_field);
+/// }
+/// }
+///
+/// fn main() {
+/// let _x = PrintOnDrop { pinned_field: true, unpin_field: 40 };
+/// }
+/// ```
+///
+/// See also [`#[pinned_drop]`][macro@pinned_drop] attribute.
+///
+/// # `project_replace` method
+///
+/// In addition to the `project` and `project_ref` methods which are always
+/// provided when you use the `#[pin_project]` attribute, there is a third
+/// method, `project_replace` which can be useful in some situations. It is
+/// equivalent to [`Pin::set`], except that the unpinned fields are moved and
+/// returned, instead of being dropped in-place.
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// # type ProjectionOwned = ();
+/// # trait Dox {
+/// fn project_replace(self: Pin<&mut Self>, other: Self) -> ProjectionOwned;
+/// # }
+/// ```
+///
+/// The `ProjectionOwned` type is identical to the `Self` type, except that
+/// all pinned fields have been replaced by equivalent [`PhantomData`] types.
+///
+/// This method is opt-in, because it is only supported for [`Sized`] types, and
+/// because it is incompatible with the [`#[pinned_drop]`][pinned-drop]
+/// attribute described above. It can be enabled by using
+/// `#[pin_project(project_replace)]`.
+///
+/// For example:
+///
+/// ```rust
+/// use std::{marker::PhantomData, pin::Pin};
+///
+/// use pin_project::pin_project;
+///
+/// #[pin_project(project_replace)]
+/// struct Struct<T, U> {
+/// #[pin]
+/// pinned_field: T,
+/// unpinned_field: U,
+/// }
+///
+/// impl<T, U> Struct<T, U> {
+/// fn method(self: Pin<&mut Self>, other: Self) {
+/// let this = self.project_replace(other);
+/// let _: U = this.unpinned_field;
+/// let _: PhantomData<T> = this.pinned_field;
+/// }
+/// }
+/// ```
+///
+/// By passing the value to the `project_replace` argument, you can name the
+/// returned type of the `project_replace` method. This is necessary whenever
+/// destructuring the return type of the `project_replace` method, and work in exactly
+/// the same way as the `project` and `project_ref` arguments.
+///
+/// ```rust
+/// use pin_project::pin_project;
+///
+/// #[pin_project(project_replace = EnumProjOwn)]
+/// enum Enum<T, U> {
+/// A {
+/// #[pin]
+/// pinned_field: T,
+/// unpinned_field: U,
+/// },
+/// B,
+/// }
+///
+/// let mut x = Box::pin(Enum::A { pinned_field: 42, unpinned_field: "hello" });
+///
+/// match x.as_mut().project_replace(Enum::B) {
+/// EnumProjOwn::A { unpinned_field, .. } => assert_eq!(unpinned_field, "hello"),
+/// EnumProjOwn::B => unreachable!(),
+/// }
+/// ```
+///
+/// [`PhantomData`]: core::marker::PhantomData
+/// [`PhantomPinned`]: core::marker::PhantomPinned
+/// [`Pin::as_mut`]: core::pin::Pin::as_mut
+/// [`Pin::set`]: core::pin::Pin::set
+/// [`Pin`]: core::pin::Pin
+/// [`UnsafeUnpin`]: https://docs.rs/pin-project/1/pin_project/trait.UnsafeUnpin.html
+/// [drop-guarantee]: core::pin#drop-guarantee
+/// [pin-projection]: core::pin#projections-and-structural-pinning
+/// [pinned-drop]: macro@pin_project#pinned_drop
+/// [repr-packed]: https://doc.rust-lang.org/nomicon/other-reprs.html#reprpacked
+/// [undefined-behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
+/// [unsafe-unpin]: macro@pin_project#unsafeunpin
+#[proc_macro_attribute]
+pub fn pin_project(args: TokenStream, input: TokenStream) -> TokenStream {
+ pin_project::attribute(&args.into(), input.into()).into()
+}
+
+/// An attribute used for custom implementations of [`Drop`].
+///
+/// This attribute is used in conjunction with the `PinnedDrop` argument to
+/// the [`#[pin_project]`][macro@pin_project] attribute.
+///
+/// The impl block annotated with this attribute acts just like a normal
+/// [`Drop`] impl, except for the following two:
+///
+/// - `drop` method takes [`Pin`]`<&mut Self>`
+/// - Name of the trait is `PinnedDrop`.
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// pub trait PinnedDrop {
+/// fn drop(self: Pin<&mut Self>);
+/// }
+/// ```
+///
+/// `#[pin_project]` implements the actual [`Drop`] trait via `PinnedDrop` you
+/// implemented. To drop a type that implements `PinnedDrop`, use the [`drop`]
+/// function just like dropping a type that directly implements [`Drop`].
+///
+/// In particular, it will never be called more than once, just like
+/// [`Drop::drop`].
+///
+/// # Examples
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project::{pin_project, pinned_drop};
+///
+/// #[pin_project(PinnedDrop)]
+/// struct PrintOnDrop {
+/// #[pin]
+/// field: u8,
+/// }
+///
+/// #[pinned_drop]
+/// impl PinnedDrop for PrintOnDrop {
+/// fn drop(self: Pin<&mut Self>) {
+/// println!("Dropping: {}", self.field);
+/// }
+/// }
+///
+/// fn main() {
+/// let _x = PrintOnDrop { field: 50 };
+/// }
+/// ```
+///
+/// See also ["pinned-drop" section of `#[pin_project]` attribute][pinned-drop].
+///
+/// # Why `#[pinned_drop]` attribute is needed?
+///
+/// Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
+/// This is because destructors can be called multiple times in safe code and
+/// [double dropping is unsound][rust-lang/rust#62360].
+///
+/// Ideally, it would be desirable to be able to forbid manual calls in
+/// the same way as [`Drop::drop`], but the library cannot do it. So, by using
+/// macros and replacing them with private traits like the following,
+/// this crate prevent users from calling `PinnedDrop::drop` in safe code.
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// pub trait PinnedDrop {
+/// unsafe fn drop(self: Pin<&mut Self>);
+/// }
+/// ```
+///
+/// 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
+/// [`Pin`]: core::pin::Pin
+/// [pinned-drop]: macro@pin_project#pinned_drop
+#[proc_macro_attribute]
+pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream {
+ let input = syn::parse_macro_input!(input);
+ pinned_drop::attribute(&args.into(), input).into()
+}
+
+// Not public API.
+#[doc(hidden)]
+#[proc_macro_derive(__PinProjectInternalDerive, attributes(pin))]
+pub fn __pin_project_internal_derive(input: TokenStream) -> TokenStream {
+ pin_project::derive(input.into()).into()
+}
diff --git a/third_party/rust/pin-project-internal/src/pin_project/args.rs b/third_party/rust/pin-project-internal/src/pin_project/args.rs
new file mode 100644
index 0000000000..d0d4f362f5
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/pin_project/args.rs
@@ -0,0 +1,254 @@
+use proc_macro2::{Span, TokenStream};
+use quote::quote;
+use syn::{
+ parse::{Parse, ParseStream},
+ spanned::Spanned,
+ Attribute, Error, Ident, Result, Token,
+};
+
+use super::PIN;
+use crate::utils::{ParseBufferExt, SliceExt};
+
+pub(super) fn parse_args(attrs: &[Attribute]) -> Result<Args> {
+ // `(__private(<args>))` -> `<args>`
+ struct Input(Option<TokenStream>);
+
+ impl Parse for Input {
+ fn parse(input: ParseStream<'_>) -> Result<Self> {
+ Ok(Self((|| {
+ let content = input.parenthesized().ok()?;
+ let private = content.parse::<Ident>().ok()?;
+ if private == "__private" {
+ content.parenthesized().ok()?.parse::<TokenStream>().ok()
+ } else {
+ None
+ }
+ })()))
+ }
+ }
+
+ if let Some(attr) = attrs.find("pin_project") {
+ bail!(attr, "duplicate #[pin_project] attribute");
+ }
+
+ let mut attrs = attrs.iter().filter(|attr| attr.path.is_ident(PIN));
+
+ let prev = if let Some(attr) = attrs.next() {
+ (attr, syn::parse2::<Input>(attr.tokens.clone()).unwrap().0)
+ } else {
+ // This only fails if another macro removes `#[pin]`.
+ bail!(TokenStream::new(), "#[pin_project] attribute has been removed");
+ };
+
+ if let Some(attr) = attrs.next() {
+ let (prev_attr, prev_res) = &prev;
+ // As the `#[pin]` attribute generated by `#[pin_project]`
+ // has the same span as `#[pin_project]`, it is possible
+ // that a useless error message will be generated.
+ // So, use the span of `prev_attr` if it is not a valid attribute.
+ let res = syn::parse2::<Input>(attr.tokens.clone()).unwrap().0;
+ let span = match (prev_res, res) {
+ (Some(_), _) => attr,
+ (None, _) => prev_attr,
+ };
+ bail!(span, "duplicate #[pin] attribute");
+ }
+ // This `unwrap` only fails if another macro removes `#[pin]` and inserts own `#[pin]`.
+ syn::parse2(prev.1.unwrap())
+}
+
+pub(super) struct Args {
+ /// `PinnedDrop` argument.
+ pub(super) pinned_drop: Option<Span>,
+ /// `UnsafeUnpin` or `!Unpin` argument.
+ pub(super) unpin_impl: UnpinImpl,
+ /// `project = <ident>` argument.
+ pub(super) project: Option<Ident>,
+ /// `project_ref = <ident>` argument.
+ pub(super) project_ref: Option<Ident>,
+ /// `project_replace [= <ident>]` argument.
+ pub(super) project_replace: ProjReplace,
+}
+
+impl Parse for Args {
+ fn parse(input: ParseStream<'_>) -> Result<Self> {
+ mod kw {
+ syn::custom_keyword!(Unpin);
+ }
+
+ /// Parses `= <value>` in `<name> = <value>` and returns value and span of name-value pair.
+ fn parse_value(
+ input: ParseStream<'_>,
+ name: &Ident,
+ has_prev: bool,
+ ) -> Result<(Ident, TokenStream)> {
+ if input.is_empty() {
+ bail!(name, "expected `{0} = <identifier>`, found `{0}`", name);
+ }
+ let eq_token: Token![=] = input.parse()?;
+ if input.is_empty() {
+ let span = quote!(#name #eq_token);
+ bail!(span, "expected `{0} = <identifier>`, found `{0} =`", name);
+ }
+ let value: Ident = input.parse()?;
+ let span = quote!(#name #value);
+ if has_prev {
+ bail!(span, "duplicate `{}` argument", name);
+ }
+ Ok((value, span))
+ }
+
+ let mut pinned_drop = None;
+ let mut unsafe_unpin = None;
+ let mut not_unpin = None;
+ let mut project = None;
+ let mut project_ref = None;
+ let mut project_replace_value = None;
+ let mut project_replace_span = None;
+
+ while !input.is_empty() {
+ if input.peek(Token![!]) {
+ let bang: Token![!] = input.parse()?;
+ if input.is_empty() {
+ bail!(bang, "expected `!Unpin`, found `!`");
+ }
+ let unpin: kw::Unpin = input.parse()?;
+ let span = quote!(#bang #unpin);
+ if not_unpin.replace(span.span()).is_some() {
+ bail!(span, "duplicate `!Unpin` argument");
+ }
+ } else {
+ let token = input.parse::<Ident>()?;
+ match &*token.to_string() {
+ "PinnedDrop" => {
+ if pinned_drop.replace(token.span()).is_some() {
+ bail!(token, "duplicate `PinnedDrop` argument");
+ }
+ }
+ "UnsafeUnpin" => {
+ if unsafe_unpin.replace(token.span()).is_some() {
+ bail!(token, "duplicate `UnsafeUnpin` argument");
+ }
+ }
+ "project" => {
+ project = Some(parse_value(input, &token, project.is_some())?.0);
+ }
+ "project_ref" => {
+ project_ref = Some(parse_value(input, &token, project_ref.is_some())?.0);
+ }
+ "project_replace" => {
+ if input.peek(Token![=]) {
+ let (value, span) =
+ parse_value(input, &token, project_replace_span.is_some())?;
+ project_replace_value = Some(value);
+ project_replace_span = Some(span.span());
+ } else if project_replace_span.is_some() {
+ bail!(token, "duplicate `project_replace` argument");
+ } else {
+ project_replace_span = Some(token.span());
+ }
+ }
+ "Replace" => {
+ bail!(
+ token,
+ "`Replace` argument was removed, use `project_replace` argument instead"
+ );
+ }
+ _ => bail!(token, "unexpected argument: {}", token),
+ }
+ }
+
+ if input.is_empty() {
+ break;
+ }
+ let _: Token![,] = input.parse()?;
+ }
+
+ if project.is_some() || project_ref.is_some() {
+ if project == project_ref {
+ bail!(
+ project_ref,
+ "name `{}` is already specified by `project` argument",
+ project_ref.as_ref().unwrap()
+ );
+ }
+ if let Some(ident) = &project_replace_value {
+ if project == project_replace_value {
+ bail!(ident, "name `{}` is already specified by `project` argument", ident);
+ } else if project_ref == project_replace_value {
+ bail!(ident, "name `{}` is already specified by `project_ref` argument", ident);
+ }
+ }
+ }
+
+ if let Some(span) = pinned_drop {
+ if project_replace_span.is_some() {
+ return Err(Error::new(
+ span,
+ "arguments `PinnedDrop` and `project_replace` are mutually exclusive",
+ ));
+ }
+ }
+ let project_replace = match (project_replace_span, project_replace_value) {
+ (None, _) => ProjReplace::None,
+ (Some(span), Some(ident)) => ProjReplace::Named { ident, span },
+ (Some(span), None) => ProjReplace::Unnamed { span },
+ };
+ let unpin_impl = match (unsafe_unpin, not_unpin) {
+ (None, None) => UnpinImpl::Default,
+ (Some(span), None) => UnpinImpl::Unsafe(span),
+ (None, Some(span)) => UnpinImpl::Negative(span),
+ (Some(span), Some(_)) => {
+ return Err(Error::new(
+ span,
+ "arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive",
+ ));
+ }
+ };
+
+ Ok(Self { pinned_drop, unpin_impl, project, project_ref, project_replace })
+ }
+}
+
+/// `UnsafeUnpin` or `!Unpin` argument.
+#[derive(Clone, Copy)]
+pub(super) enum UnpinImpl {
+ Default,
+ /// `UnsafeUnpin`.
+ Unsafe(Span),
+ /// `!Unpin`.
+ Negative(Span),
+}
+
+/// `project_replace [= <ident>]` argument.
+pub(super) enum ProjReplace {
+ None,
+ /// `project_replace`.
+ Unnamed {
+ span: Span,
+ },
+ /// `project_replace = <ident>`.
+ #[allow(dead_code)] // false positive that fixed in Rust 1.38
+ Named {
+ span: Span,
+ ident: Ident,
+ },
+}
+
+impl ProjReplace {
+ /// Return the span of this argument.
+ pub(super) fn span(&self) -> Option<Span> {
+ match self {
+ Self::None => None,
+ Self::Named { span, .. } | Self::Unnamed { span, .. } => Some(*span),
+ }
+ }
+
+ pub(super) fn ident(&self) -> Option<&Ident> {
+ if let Self::Named { ident, .. } = self {
+ Some(ident)
+ } else {
+ None
+ }
+ }
+}
diff --git a/third_party/rust/pin-project-internal/src/pin_project/attribute.rs b/third_party/rust/pin-project-internal/src/pin_project/attribute.rs
new file mode 100644
index 0000000000..7adfc07d59
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/pin_project/attribute.rs
@@ -0,0 +1,65 @@
+use proc_macro2::TokenStream;
+use quote::quote;
+use syn::{
+ parse::{Parse, ParseStream},
+ Attribute, Result, Token, Visibility,
+};
+
+use super::PIN;
+use crate::utils::SliceExt;
+
+// To generate the correct `Unpin` implementation and the projection methods,
+// we need to collect the types of the pinned fields.
+// However, since proc-macro-attribute is applied before `cfg` and `cfg_attr`
+// on fields, we cannot be collecting field types properly at this timing.
+// So instead of generating the `Unpin` implementation and the projection
+// methods here, delegate their processing to proc-macro-derive.
+//
+// At this stage, only attributes are parsed and the following attributes are
+// added to the attributes of the item.
+// - `#[derive(InternalDerive)]` - An internal helper macro that does the above
+// processing.
+// - `#[pin(__private(#args))]` - Pass the argument of `#[pin_project]` to
+// proc-macro-derive (`InternalDerive`).
+
+pub(super) fn parse_attribute(args: &TokenStream, input: TokenStream) -> Result<TokenStream> {
+ let Input { attrs, body } = syn::parse2(input)?;
+
+ Ok(quote! {
+ #(#attrs)*
+ #[derive(::pin_project::__private::__PinProjectInternalDerive)]
+ // Use `__private` to prevent users from trying to control `InternalDerive`
+ // manually. `__private` does not guarantee compatibility between patch
+ // versions, so it should be sufficient for this purpose in most cases.
+ #[pin(__private(#args))]
+ #body
+ })
+}
+
+#[allow(dead_code)] // false positive that fixed in Rust 1.39
+struct Input {
+ attrs: Vec<Attribute>,
+ body: TokenStream,
+}
+
+impl Parse for Input {
+ fn parse(input: ParseStream<'_>) -> Result<Self> {
+ let attrs = input.call(Attribute::parse_outer)?;
+
+ let ahead = input.fork();
+ let _vis: Visibility = ahead.parse()?;
+ if !ahead.peek(Token![struct]) && !ahead.peek(Token![enum]) {
+ // If we check this only on proc-macro-derive, it may generate unhelpful error
+ // messages. So it is preferable to be able to detect it here.
+ bail!(
+ input.parse::<TokenStream>()?,
+ "#[pin_project] attribute may only be used on structs or enums"
+ );
+ } else if let Some(attr) = attrs.find(PIN) {
+ bail!(attr, "#[pin] attribute may only be used on fields of structs or variants");
+ } else if let Some(attr) = attrs.find("pin_project") {
+ bail!(attr, "duplicate #[pin_project] attribute");
+ }
+ Ok(Self { attrs, body: input.parse()? })
+ }
+}
diff --git a/third_party/rust/pin-project-internal/src/pin_project/derive.rs b/third_party/rust/pin-project-internal/src/pin_project/derive.rs
new file mode 100644
index 0000000000..fd2375dc3b
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/pin_project/derive.rs
@@ -0,0 +1,1127 @@
+use proc_macro2::{Delimiter, Group, Span, TokenStream};
+use quote::{format_ident, quote, quote_spanned, ToTokens};
+use syn::{
+ parse_quote, token, visit_mut::VisitMut, Attribute, Data, DataEnum, DeriveInput, Error, Field,
+ Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Index, Lifetime, LifetimeDef, Meta,
+ MetaList, MetaNameValue, NestedMeta, Result, Token, Type, Variant, Visibility, WhereClause,
+};
+
+use super::{
+ args::{parse_args, Args, ProjReplace, UnpinImpl},
+ PIN,
+};
+use crate::utils::{
+ determine_lifetime_name, determine_visibility, insert_lifetime_and_bound, ReplaceReceiver,
+ SliceExt, Variants,
+};
+
+pub(super) fn parse_derive(input: TokenStream) -> Result<TokenStream> {
+ let mut input: DeriveInput = syn::parse2(input)?;
+
+ let mut cx;
+ let mut generate = GenerateTokens::default();
+
+ let ident = &input.ident;
+ let ty_generics = input.generics.split_for_impl().1;
+ let self_ty = parse_quote!(#ident #ty_generics);
+ let mut visitor = ReplaceReceiver(&self_ty);
+ visitor.visit_generics_mut(&mut input.generics);
+ visitor.visit_data_mut(&mut input.data);
+
+ match &input.data {
+ Data::Struct(data) => {
+ cx = Context::new(&input.attrs, &input.vis, ident, &mut input.generics, Struct)?;
+ parse_struct(&mut cx, &data.fields, &mut generate)?;
+ }
+ Data::Enum(data) => {
+ cx = Context::new(&input.attrs, &input.vis, ident, &mut input.generics, Enum)?;
+ parse_enum(&mut cx, data, &mut generate)?;
+ }
+ Data::Union(_) => {
+ bail!(input, "#[pin_project] attribute may only be used on structs or enums");
+ }
+ }
+
+ Ok(generate.into_tokens(&cx))
+}
+
+#[derive(Default)]
+struct GenerateTokens {
+ exposed: TokenStream,
+ scoped: TokenStream,
+}
+
+impl GenerateTokens {
+ fn extend(&mut self, expose: bool, tokens: TokenStream) {
+ if expose {
+ self.exposed.extend(tokens);
+ } else {
+ self.scoped.extend(tokens);
+ }
+ }
+
+ fn into_tokens(self, cx: &Context<'_>) -> TokenStream {
+ let mut tokens = self.exposed;
+ let scoped = self.scoped;
+
+ let unpin_impl = make_unpin_impl(cx);
+ let drop_impl = make_drop_impl(cx);
+ let allowed_lints = global_allowed_lints();
+
+ tokens.extend(quote! {
+ // All items except projected types are generated inside a `const` scope.
+ // This makes it impossible for user code to refer to these types.
+ // However, this prevents Rustdoc from displaying docs for any
+ // of our types. In particular, users cannot see the
+ // automatically generated `Unpin` impl for the '__UnpinStruct' types
+ //
+ // Previously, we provided a flag to correctly document the
+ // automatically generated `Unpin` impl by using def-site hygiene,
+ // but it is now removed.
+ //
+ // Refs:
+ // - https://github.com/rust-lang/rust/issues/63281
+ // - https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
+ // - https://github.com/taiki-e/pin-project/pull/70
+ #allowed_lints
+ #[allow(unused_qualifications)]
+ #[allow(clippy::semicolon_if_nothing_returned)]
+ #[allow(clippy::use_self)]
+ #[allow(clippy::used_underscore_binding)]
+ const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #scoped
+ #unpin_impl
+ #drop_impl
+ };
+ });
+ tokens
+ }
+}
+
+/// Returns attributes that should be applied to all generated code.
+fn global_allowed_lints() -> TokenStream {
+ quote! {
+ #[allow(box_pointers)] // This lint warns use of the `Box` type.
+ #[allow(deprecated)]
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
+ #[allow(unreachable_pub)] // This lint warns `pub` field in private struct.
+ #[allow(unused_tuple_struct_fields)]
+ // This lint warns of `clippy::*` generated by external macros.
+ // We allow this lint for compatibility with older compilers.
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::pattern_type_mismatch)]
+ #[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
+ #[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
+ }
+}
+
+/// Returns attributes used on projected types.
+fn proj_allowed_lints(cx: &Context<'_>) -> (TokenStream, TokenStream, TokenStream) {
+ let large_enum_variant = if cx.kind == Enum {
+ Some(quote! {
+ #[allow(variant_size_differences)]
+ #[allow(clippy::large_enum_variant)]
+ })
+ } else {
+ None
+ };
+ let global_allowed_lints = global_allowed_lints();
+ let proj_mut_allowed_lints = if cx.project { Some(&global_allowed_lints) } else { None };
+ let proj_mut = quote! {
+ #proj_mut_allowed_lints
+ #[allow(dead_code)] // This lint warns unused fields/variants.
+ #[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`.
+ };
+ let proj_ref_allowed_lints = if cx.project_ref { Some(&global_allowed_lints) } else { None };
+ let proj_ref = quote! {
+ #proj_ref_allowed_lints
+ #[allow(dead_code)] // This lint warns unused fields/variants.
+ #[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`.
+ };
+ let proj_own_allowed_lints =
+ if cx.project_replace.ident().is_some() { Some(&global_allowed_lints) } else { None };
+ let proj_own = quote! {
+ #proj_own_allowed_lints
+ #[allow(dead_code)] // This lint warns unused fields/variants.
+ #large_enum_variant
+ };
+ (proj_mut, proj_ref, proj_own)
+}
+
+struct Context<'a> {
+ /// The original type.
+ orig: OriginalType<'a>,
+ /// The projected types.
+ proj: ProjectedType,
+ /// Types of the pinned fields.
+ pinned_fields: Vec<&'a Type>,
+ /// Kind of the original type: struct or enum
+ kind: TypeKind,
+
+ /// `PinnedDrop` argument.
+ pinned_drop: Option<Span>,
+ /// `UnsafeUnpin` or `!Unpin` argument.
+ unpin_impl: UnpinImpl,
+ /// `project` argument.
+ project: bool,
+ /// `project_ref` argument.
+ project_ref: bool,
+ /// `project_replace [= <ident>]` argument.
+ project_replace: ProjReplace,
+}
+
+impl<'a> Context<'a> {
+ fn new(
+ attrs: &'a [Attribute],
+ vis: &'a Visibility,
+ ident: &'a Ident,
+ generics: &'a mut Generics,
+ kind: TypeKind,
+ ) -> Result<Self> {
+ let Args { pinned_drop, unpin_impl, project, project_ref, project_replace } =
+ parse_args(attrs)?;
+
+ if let Some(name) = [project.as_ref(), project_ref.as_ref(), project_replace.ident()]
+ .iter()
+ .filter_map(Option::as_ref)
+ .find(|name| **name == ident)
+ {
+ bail!(name, "name `{}` is the same as the original type name", name);
+ }
+
+ let mut lifetime_name = String::from("'pin");
+ determine_lifetime_name(&mut lifetime_name, generics);
+ let lifetime = Lifetime::new(&lifetime_name, Span::call_site());
+
+ let ty_generics = generics.split_for_impl().1;
+ let ty_generics_as_generics = parse_quote!(#ty_generics);
+ let mut proj_generics = generics.clone();
+ let pred = insert_lifetime_and_bound(
+ &mut proj_generics,
+ lifetime.clone(),
+ &ty_generics_as_generics,
+ ident,
+ );
+ let mut where_clause = generics.make_where_clause().clone();
+ where_clause.predicates.push(pred);
+
+ let own_ident = project_replace
+ .ident()
+ .cloned()
+ .unwrap_or_else(|| format_ident!("__{}ProjectionOwned", ident));
+
+ Ok(Self {
+ kind,
+ pinned_drop,
+ unpin_impl,
+ project: project.is_some(),
+ project_ref: project_ref.is_some(),
+ project_replace,
+ proj: ProjectedType {
+ vis: determine_visibility(vis),
+ mut_ident: project.unwrap_or_else(|| format_ident!("__{}Projection", ident)),
+ ref_ident: project_ref.unwrap_or_else(|| format_ident!("__{}ProjectionRef", ident)),
+ own_ident,
+ lifetime,
+ generics: proj_generics,
+ where_clause,
+ },
+ orig: OriginalType { attrs, vis, ident, generics },
+ pinned_fields: Vec::new(),
+ })
+ }
+}
+
+#[derive(Copy, Clone, Eq, PartialEq)]
+enum TypeKind {
+ Enum,
+ Struct,
+}
+
+use TypeKind::{Enum, Struct};
+
+struct OriginalType<'a> {
+ /// Attributes of the original type.
+ attrs: &'a [Attribute],
+ /// Visibility of the original type.
+ vis: &'a Visibility,
+ /// Name of the original type.
+ ident: &'a Ident,
+ /// Generics of the original type.
+ generics: &'a Generics,
+}
+
+struct ProjectedType {
+ /// Visibility of the projected types.
+ vis: Visibility,
+ /// Name of the projected type returned by `project` method.
+ mut_ident: Ident,
+ /// Name of the projected type returned by `project_ref` method.
+ ref_ident: Ident,
+ /// Name of the projected type returned by `project_replace` method.
+ own_ident: Ident,
+ /// Lifetime on the generated projected types.
+ lifetime: Lifetime,
+ /// Generics of the projected types.
+ generics: Generics,
+ /// `where` clause of the projected types. This has an additional
+ /// bound generated by `insert_lifetime_and_bound`
+ where_clause: WhereClause,
+}
+
+struct ProjectedVariants {
+ proj_variants: TokenStream,
+ proj_ref_variants: TokenStream,
+ proj_own_variants: TokenStream,
+ proj_arms: TokenStream,
+ proj_ref_arms: TokenStream,
+ proj_own_arms: TokenStream,
+}
+
+#[derive(Default)]
+struct ProjectedFields {
+ proj_pat: TokenStream,
+ proj_body: TokenStream,
+ proj_own_body: TokenStream,
+ proj_fields: TokenStream,
+ proj_ref_fields: TokenStream,
+ proj_own_fields: TokenStream,
+}
+
+fn validate_struct(ident: &Ident, fields: &Fields) -> Result<()> {
+ if fields.is_empty() {
+ let msg = "#[pin_project] attribute may not be used on structs with zero fields";
+ if let Fields::Unit = fields {
+ bail!(ident, msg)
+ }
+ bail!(fields, msg)
+ }
+ Ok(())
+}
+
+fn validate_enum(brace_token: token::Brace, variants: &Variants) -> Result<()> {
+ if variants.is_empty() {
+ return Err(Error::new(
+ brace_token.span,
+ "#[pin_project] attribute may not be used on enums without variants",
+ ));
+ }
+ let has_field = variants.iter().try_fold(false, |has_field, v| {
+ if let Some((_, e)) = &v.discriminant {
+ bail!(e, "#[pin_project] attribute may not be used on enums with discriminants");
+ } else if let Some(attr) = v.attrs.find(PIN) {
+ bail!(attr, "#[pin] attribute may only be used on fields of structs or variants");
+ } else if v.fields.is_empty() {
+ Ok(has_field)
+ } else {
+ Ok(true)
+ }
+ })?;
+ if has_field {
+ Ok(())
+ } else {
+ bail!(variants, "#[pin_project] attribute may not be used on enums with zero fields");
+ }
+}
+
+fn parse_struct<'a>(
+ cx: &mut Context<'a>,
+ fields: &'a Fields,
+ generate: &mut GenerateTokens,
+) -> Result<()> {
+ // Do this first for a better error message.
+ let packed_check = ensure_not_packed(&cx.orig, Some(fields))?;
+
+ validate_struct(cx.orig.ident, fields)?;
+
+ let ProjectedFields {
+ proj_pat,
+ proj_body,
+ proj_fields,
+ proj_ref_fields,
+ proj_own_fields,
+ proj_own_body,
+ } = match fields {
+ Fields::Named(_) => visit_fields(cx, None, fields, Delimiter::Brace)?,
+ Fields::Unnamed(_) => visit_fields(cx, None, fields, Delimiter::Parenthesis)?,
+ Fields::Unit => unreachable!(),
+ };
+
+ let proj_ident = &cx.proj.mut_ident;
+ let proj_ref_ident = &cx.proj.ref_ident;
+ let proj_own_ident = &cx.proj.own_ident;
+ let vis = &cx.proj.vis;
+ let mut orig_generics = cx.orig.generics.clone();
+ let orig_where_clause = orig_generics.where_clause.take();
+ let proj_generics = &cx.proj.generics;
+ let proj_where_clause = &cx.proj.where_clause;
+
+ // For tuple structs, we need to generate `(T1, T2) where Foo: Bar`
+ // For non-tuple structs, we need to generate `where Foo: Bar { field1: T }`
+ let (where_clause_fields, where_clause_ref_fields, where_clause_own_fields) = match fields {
+ Fields::Named(_) => (
+ quote!(#proj_where_clause #proj_fields),
+ quote!(#proj_where_clause #proj_ref_fields),
+ quote!(#orig_where_clause #proj_own_fields),
+ ),
+ Fields::Unnamed(_) => (
+ quote!(#proj_fields #proj_where_clause;),
+ quote!(#proj_ref_fields #proj_where_clause;),
+ quote!(#proj_own_fields #orig_where_clause;),
+ ),
+ Fields::Unit => unreachable!(),
+ };
+
+ let (proj_attrs, proj_ref_attrs, proj_own_attrs) = proj_allowed_lints(cx);
+ generate.extend(cx.project, quote! {
+ #proj_attrs
+ #vis struct #proj_ident #proj_generics #where_clause_fields
+ });
+ generate.extend(cx.project_ref, quote! {
+ #proj_ref_attrs
+ #vis struct #proj_ref_ident #proj_generics #where_clause_ref_fields
+ });
+ if cx.project_replace.span().is_some() {
+ generate.extend(cx.project_replace.ident().is_some(), quote! {
+ #proj_own_attrs
+ #vis struct #proj_own_ident #orig_generics #where_clause_own_fields
+ });
+ }
+
+ let proj_mut_body = quote! {
+ let Self #proj_pat = self.get_unchecked_mut();
+ #proj_ident #proj_body
+ };
+ let proj_ref_body = quote! {
+ let Self #proj_pat = self.get_ref();
+ #proj_ref_ident #proj_body
+ };
+ let proj_own_body = quote! {
+ let Self #proj_pat = &mut *__self_ptr;
+ #proj_own_body
+ };
+ generate.extend(false, make_proj_impl(cx, &proj_mut_body, &proj_ref_body, &proj_own_body));
+
+ generate.extend(false, packed_check);
+ Ok(())
+}
+
+fn parse_enum<'a>(
+ cx: &mut Context<'a>,
+ DataEnum { brace_token, variants, .. }: &'a DataEnum,
+ generate: &mut GenerateTokens,
+) -> Result<()> {
+ if let ProjReplace::Unnamed { span } = &cx.project_replace {
+ return Err(Error::new(
+ *span,
+ "`project_replace` argument requires a value when used on enums",
+ ));
+ }
+
+ // #[repr(packed)] cannot be apply on enums and will be rejected by rustc.
+ // However, we should not rely on the behavior of rustc that rejects this.
+ // https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+ //
+ // Do this first for a better error message.
+ ensure_not_packed(&cx.orig, None)?;
+
+ validate_enum(*brace_token, variants)?;
+
+ let ProjectedVariants {
+ proj_variants,
+ proj_ref_variants,
+ proj_own_variants,
+ proj_arms,
+ proj_ref_arms,
+ proj_own_arms,
+ } = visit_variants(cx, variants)?;
+
+ let proj_ident = &cx.proj.mut_ident;
+ let proj_ref_ident = &cx.proj.ref_ident;
+ let proj_own_ident = &cx.proj.own_ident;
+ let vis = &cx.proj.vis;
+ let mut orig_generics = cx.orig.generics.clone();
+ let orig_where_clause = orig_generics.where_clause.take();
+ let proj_generics = &cx.proj.generics;
+ let proj_where_clause = &cx.proj.where_clause;
+
+ let (proj_attrs, proj_ref_attrs, proj_own_attrs) = proj_allowed_lints(cx);
+ if cx.project {
+ generate.extend(true, quote! {
+ #proj_attrs
+ #vis enum #proj_ident #proj_generics #proj_where_clause {
+ #proj_variants
+ }
+ });
+ }
+ if cx.project_ref {
+ generate.extend(true, quote! {
+ #proj_ref_attrs
+ #vis enum #proj_ref_ident #proj_generics #proj_where_clause {
+ #proj_ref_variants
+ }
+ });
+ }
+ if cx.project_replace.ident().is_some() {
+ generate.extend(true, quote! {
+ #proj_own_attrs
+ #vis enum #proj_own_ident #orig_generics #orig_where_clause {
+ #proj_own_variants
+ }
+ });
+ }
+
+ let proj_mut_body = quote! {
+ match self.get_unchecked_mut() {
+ #proj_arms
+ }
+ };
+ let proj_ref_body = quote! {
+ match self.get_ref() {
+ #proj_ref_arms
+ }
+ };
+ let proj_own_body = quote! {
+ match &mut *__self_ptr {
+ #proj_own_arms
+ }
+ };
+ generate.extend(false, make_proj_impl(cx, &proj_mut_body, &proj_ref_body, &proj_own_body));
+
+ Ok(())
+}
+
+fn visit_variants<'a>(cx: &mut Context<'a>, variants: &'a Variants) -> Result<ProjectedVariants> {
+ let mut proj_variants = TokenStream::new();
+ let mut proj_ref_variants = TokenStream::new();
+ let mut proj_own_variants = TokenStream::new();
+ let mut proj_arms = TokenStream::new();
+ let mut proj_ref_arms = TokenStream::new();
+ let mut proj_own_arms = TokenStream::new();
+
+ for Variant { ident, fields, .. } in variants {
+ let ProjectedFields {
+ proj_pat,
+ proj_body,
+ proj_fields,
+ proj_ref_fields,
+ proj_own_fields,
+ proj_own_body,
+ } = match fields {
+ Fields::Named(_) => visit_fields(cx, Some(ident), fields, Delimiter::Brace)?,
+ Fields::Unnamed(_) => visit_fields(cx, Some(ident), fields, Delimiter::Parenthesis)?,
+ Fields::Unit => ProjectedFields {
+ proj_own_body: proj_own_body(cx, Some(ident), None, &[]),
+ ..Default::default()
+ },
+ };
+
+ let proj_ident = &cx.proj.mut_ident;
+ let proj_ref_ident = &cx.proj.ref_ident;
+ proj_variants.extend(quote! {
+ #ident #proj_fields,
+ });
+ proj_ref_variants.extend(quote! {
+ #ident #proj_ref_fields,
+ });
+ proj_own_variants.extend(quote! {
+ #ident #proj_own_fields,
+ });
+ proj_arms.extend(quote! {
+ Self::#ident #proj_pat => #proj_ident::#ident #proj_body,
+ });
+ proj_ref_arms.extend(quote! {
+ Self::#ident #proj_pat => #proj_ref_ident::#ident #proj_body,
+ });
+ proj_own_arms.extend(quote! {
+ Self::#ident #proj_pat => { #proj_own_body }
+ });
+ }
+
+ Ok(ProjectedVariants {
+ proj_variants,
+ proj_ref_variants,
+ proj_own_variants,
+ proj_arms,
+ proj_ref_arms,
+ proj_own_arms,
+ })
+}
+
+fn visit_fields<'a>(
+ cx: &mut Context<'a>,
+ variant_ident: Option<&Ident>,
+ fields: &'a Fields,
+ delim: Delimiter,
+) -> Result<ProjectedFields> {
+ fn surround(delim: Delimiter, tokens: TokenStream) -> TokenStream {
+ Group::new(delim, tokens).into_token_stream()
+ }
+
+ let mut proj_pat = TokenStream::new();
+ let mut proj_body = TokenStream::new();
+ let mut proj_fields = TokenStream::new();
+ let mut proj_ref_fields = TokenStream::new();
+ let mut proj_own_fields = TokenStream::new();
+ let mut proj_move = TokenStream::new();
+ let mut pinned_bindings = Vec::with_capacity(fields.len());
+
+ for (i, Field { attrs, vis, ident, colon_token, ty }) in fields.iter().enumerate() {
+ let binding = ident.clone().unwrap_or_else(|| format_ident!("_{}", i));
+ proj_pat.extend(quote!(#binding,));
+ let lifetime = &cx.proj.lifetime;
+ if attrs.position_exact(PIN)?.is_some() {
+ proj_fields.extend(quote! {
+ #vis #ident #colon_token ::pin_project::__private::Pin<&#lifetime mut (#ty)>,
+ });
+ proj_ref_fields.extend(quote! {
+ #vis #ident #colon_token ::pin_project::__private::Pin<&#lifetime (#ty)>,
+ });
+ proj_own_fields.extend(quote! {
+ #vis #ident #colon_token ::pin_project::__private::PhantomData<#ty>,
+ });
+ proj_body.extend(quote! {
+ #ident #colon_token _pin_project::__private::Pin::new_unchecked(#binding),
+ });
+ proj_move.extend(quote! {
+ #ident #colon_token _pin_project::__private::PhantomData,
+ });
+
+ cx.pinned_fields.push(ty);
+ pinned_bindings.push(binding);
+ } else {
+ proj_fields.extend(quote! {
+ #vis #ident #colon_token &#lifetime mut (#ty),
+ });
+ proj_ref_fields.extend(quote! {
+ #vis #ident #colon_token &#lifetime (#ty),
+ });
+ proj_own_fields.extend(quote! {
+ #vis #ident #colon_token #ty,
+ });
+ proj_body.extend(quote! {
+ #binding,
+ });
+ proj_move.extend(quote! {
+ #ident #colon_token _pin_project::__private::ptr::read(#binding),
+ });
+ }
+ }
+
+ let proj_pat = surround(delim, proj_pat);
+ let proj_body = surround(delim, proj_body);
+ let proj_fields = surround(delim, proj_fields);
+ let proj_ref_fields = surround(delim, proj_ref_fields);
+ let proj_own_fields = surround(delim, proj_own_fields);
+
+ let proj_move = Group::new(delim, proj_move);
+ let proj_own_body = proj_own_body(cx, variant_ident, Some(&proj_move), &pinned_bindings);
+
+ Ok(ProjectedFields {
+ proj_pat,
+ proj_body,
+ proj_own_body,
+ proj_fields,
+ proj_ref_fields,
+ proj_own_fields,
+ })
+}
+
+/// Generates the processing that `project_replace` does for the struct or each variant.
+///
+/// Note: `pinned_fields` must be in declaration order.
+fn proj_own_body(
+ cx: &Context<'_>,
+ variant_ident: Option<&Ident>,
+ proj_move: Option<&Group>,
+ pinned_fields: &[Ident],
+) -> TokenStream {
+ let ident = &cx.proj.own_ident;
+ let proj_own = match variant_ident {
+ Some(variant_ident) => quote!(#ident::#variant_ident),
+ None => quote!(#ident),
+ };
+
+ // The fields of the struct and the active enum variant are dropped
+ // in declaration order.
+ // Refs: https://doc.rust-lang.org/reference/destructors.html
+ let pinned_fields = pinned_fields.iter().rev();
+
+ quote! {
+ // First, extract all the unpinned fields.
+ let __result = #proj_own #proj_move;
+
+ // Now create guards to drop all the pinned fields.
+ //
+ // Due to a compiler bug (https://github.com/rust-lang/rust/issues/47949)
+ // this must be in its own scope, or else `__result` will not be dropped
+ // if any of the destructors panic.
+ {
+ #(
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(#pinned_fields);
+ )*
+ }
+
+ // Finally, return the result.
+ __result
+ }
+}
+
+/// Creates `Unpin` implementation for the original type.
+///
+/// The kind of `Unpin` impl generated depends on `unpin_impl` field:
+/// - `UnpinImpl::Unsafe` - Implements `Unpin` via `UnsafeUnpin` impl.
+/// - `UnpinImpl::Negative` - Generates `Unpin` impl with bounds that will never be true.
+/// - `UnpinImpl::Default` - Generates `Unpin` impl that requires `Unpin` for all pinned fields.
+fn make_unpin_impl(cx: &Context<'_>) -> TokenStream {
+ match cx.unpin_impl {
+ UnpinImpl::Unsafe(span) => {
+ let mut proj_generics = cx.proj.generics.clone();
+ let orig_ident = cx.orig.ident;
+ let lifetime = &cx.proj.lifetime;
+
+ // Make the error message highlight `UnsafeUnpin` argument.
+ proj_generics.make_where_clause().predicates.push(parse_quote_spanned! { span =>
+ _pin_project::__private::Wrapper<#lifetime, Self>: _pin_project::UnsafeUnpin
+ });
+
+ let (impl_generics, _, where_clause) = proj_generics.split_for_impl();
+ let ty_generics = cx.orig.generics.split_for_impl().1;
+
+ quote_spanned! { span =>
+ impl #impl_generics _pin_project::__private::Unpin for #orig_ident #ty_generics
+ #where_clause
+ {
+ }
+ }
+ }
+ UnpinImpl::Negative(span) => {
+ let mut proj_generics = cx.proj.generics.clone();
+ let orig_ident = cx.orig.ident;
+ let lifetime = &cx.proj.lifetime;
+
+ proj_generics.make_where_clause().predicates.push(parse_quote! {
+ _pin_project::__private::Wrapper<
+ #lifetime, _pin_project::__private::PhantomPinned
+ >: _pin_project::__private::Unpin
+ });
+
+ let (proj_impl_generics, _, proj_where_clause) = proj_generics.split_for_impl();
+ let ty_generics = cx.orig.generics.split_for_impl().1;
+
+ // For interoperability with `forbid(unsafe_code)`, `unsafe` token should be
+ // call-site span.
+ let unsafety = <Token![unsafe]>::default();
+ quote_spanned! { span =>
+ impl #proj_impl_generics _pin_project::__private::Unpin
+ for #orig_ident #ty_generics
+ #proj_where_clause
+ {
+ }
+
+ // Generate a dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ //
+ // To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
+ // impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
+ // impl, they'll get a "conflicting implementations of trait" error when
+ // coherence checks are run.
+ #[doc(hidden)]
+ #unsafety impl #proj_impl_generics _pin_project::UnsafeUnpin
+ for #orig_ident #ty_generics
+ #proj_where_clause
+ {
+ }
+ }
+ }
+ UnpinImpl::Default => {
+ let mut full_where_clause = cx.orig.generics.where_clause.clone().unwrap();
+
+ // Generate a field in our new struct for every
+ // pinned field in the original type.
+ let fields = cx.pinned_fields.iter().enumerate().map(|(i, ty)| {
+ let field_ident = format_ident!("__field{}", i);
+ quote!(#field_ident: #ty)
+ });
+
+ // We could try to determine the subset of type parameters
+ // and lifetimes that are actually used by the pinned fields
+ // (as opposed to those only used by unpinned fields).
+ // However, this would be tricky and error-prone, since
+ // it's possible for users to create types that would alias
+ // with generic parameters (e.g. 'struct T').
+ //
+ // Instead, we generate a use of every single type parameter
+ // and lifetime used in the original struct. For type parameters,
+ // we generate code like this:
+ //
+ // ```rust
+ // struct AlwaysUnpin<T: ?Sized>(PhantomData<T>) {}
+ // impl<T: ?Sized> Unpin for AlwaysUnpin<T> {}
+ //
+ // ...
+ // _field: AlwaysUnpin<(A, B, C)>
+ // ```
+ //
+ // This ensures that any unused type parameters
+ // don't end up with `Unpin` bounds.
+ let lifetime_fields = cx.orig.generics.lifetimes().enumerate().map(
+ |(i, LifetimeDef { lifetime, .. })| {
+ let field_ident = format_ident!("__lifetime{}", i);
+ quote!(#field_ident: &#lifetime ())
+ },
+ );
+
+ let orig_ident = cx.orig.ident;
+ let struct_ident = format_ident!("__{}", orig_ident);
+ let vis = cx.orig.vis;
+ let lifetime = &cx.proj.lifetime;
+ let type_params = cx.orig.generics.type_params().map(|t| &t.ident);
+ let proj_generics = &cx.proj.generics;
+ let (proj_impl_generics, proj_ty_generics, _) = proj_generics.split_for_impl();
+ let (_, ty_generics, where_clause) = cx.orig.generics.split_for_impl();
+
+ full_where_clause.predicates.push(parse_quote! {
+ #struct_ident #proj_ty_generics: _pin_project::__private::Unpin
+ });
+
+ quote! {
+ // This needs to have the same visibility as the original type,
+ // due to the limitations of the 'public in private' error.
+ //
+ // Our goal is to implement the public trait `Unpin` for
+ // a potentially public user type. Because of this, rust
+ // requires that any types mentioned in the where clause of
+ // our `Unpin` impl also be public. This means that our generated
+ // `__UnpinStruct` type must also be public.
+ // However, we ensure that the user can never actually reference
+ // this 'public' type by creating this type in the inside of `const`.
+ #[allow(missing_debug_implementations)]
+ #vis struct #struct_ident #proj_generics #where_clause {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ #lifetime, (#(_pin_project::__private::PhantomData<#type_params>),*)
+ >,
+
+ #(#fields,)*
+ #(#lifetime_fields,)*
+ }
+
+ impl #proj_impl_generics _pin_project::__private::Unpin
+ for #orig_ident #ty_generics
+ #full_where_clause
+ {
+ }
+
+ // Generate a dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ //
+ // To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
+ // impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
+ // impl, they'll get a "conflicting implementations of trait" error when
+ // coherence checks are run.
+ #[doc(hidden)]
+ unsafe impl #proj_impl_generics _pin_project::UnsafeUnpin
+ for #orig_ident #ty_generics
+ #full_where_clause
+ {
+ }
+ }
+ }
+ }
+}
+
+/// Creates `Drop` implementation for the original type.
+///
+/// The kind of `Drop` impl generated depends on `pinned_drop` field:
+/// - `Some` - implements `Drop` via `PinnedDrop` impl.
+/// - `None` - generates code that ensures that `Drop` trait is not implemented,
+/// instead of generating `Drop` impl.
+fn make_drop_impl(cx: &Context<'_>) -> TokenStream {
+ let ident = cx.orig.ident;
+ let (impl_generics, ty_generics, where_clause) = cx.orig.generics.split_for_impl();
+
+ if let Some(span) = cx.pinned_drop {
+ // For interoperability with `forbid(unsafe_code)`, `unsafe` token should be
+ // call-site span.
+ let unsafety = <Token![unsafe]>::default();
+ quote_spanned! { span =>
+ impl #impl_generics _pin_project::__private::Drop for #ident #ty_generics
+ #where_clause
+ {
+ fn drop(&mut self) {
+ #unsafety {
+ // Safety - we're in 'drop', so we know that 'self' will
+ // never move again.
+ let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
+ // We call `pinned_drop` only once. Since `PinnedDrop::drop`
+ // is an unsafe method and a private API, it is never called again in safe
+ // code *unless the user uses a maliciously crafted macro*.
+ _pin_project::__private::PinnedDrop::drop(__pinned_self);
+ }
+ }
+ }
+ }
+ } else {
+ // If the user does not provide a `PinnedDrop` impl,
+ // we need to ensure that they don't provide a `Drop` impl of their
+ // own.
+ // Based on https://github.com/upsuper/assert-impl/blob/f503255b292ab0ba8d085b657f4065403cfa46eb/src/lib.rs#L80-L87
+ //
+ // We create a new identifier for each struct, so that the traits
+ // for different types do not conflict with each other.
+ //
+ // Another approach would be to provide an empty Drop impl,
+ // which would conflict with a user-provided Drop impl.
+ // However, this would trigger the compiler's special handling
+ // of Drop types (e.g. fields cannot be moved out of a Drop type).
+ // This approach prevents the creation of needless Drop impls,
+ // giving users more flexibility.
+ let trait_ident = format_ident!("{}MustNotImplDrop", ident);
+
+ quote! {
+ // There are two possible cases:
+ // 1. The user type does not implement Drop. In this case,
+ // the first blanked impl will not apply to it. This code
+ // will compile, as there is only one impl of MustNotImplDrop for the user type
+ // 2. The user type does impl Drop. This will make the blanket impl applicable,
+ // which will then conflict with the explicit MustNotImplDrop impl below.
+ // This will result in a compilation error, which is exactly what we want.
+ trait #trait_ident {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> #trait_ident for T {}
+ impl #impl_generics #trait_ident for #ident #ty_generics #where_clause {}
+
+ // Generate a dummy impl of `PinnedDrop`, to ensure that the user cannot implement it.
+ // Since the user did not pass `PinnedDrop` to `#[pin_project]`, any `PinnedDrop`
+ // impl will not actually be called. Unfortunately, we can't detect this situation
+ // directly from either the `#[pin_project]` or `#[pinned_drop]` attributes, since
+ // we don't know what other attributes/impl may exist.
+ //
+ // To ensure that users don't accidentally write a non-functional `PinnedDrop`
+ // impls, we emit one ourselves. If the user ends up writing a `PinnedDrop` impl,
+ // they'll get a "conflicting implementations of trait" error when coherence
+ // checks are run.
+ #[doc(hidden)]
+ impl #impl_generics _pin_project::__private::PinnedDrop for #ident #ty_generics
+ #where_clause
+ {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+ }
+ }
+}
+
+/// Creates an implementation of the projection methods.
+///
+/// On structs, both the `project` and `project_ref` methods are always generated,
+/// and the `project_replace` method is only generated if `ProjReplace::span` is `Some`.
+///
+/// On enums, only methods that the returned projected type is named will be generated.
+fn make_proj_impl(
+ cx: &Context<'_>,
+ proj_body: &TokenStream,
+ proj_ref_body: &TokenStream,
+ proj_own_body: &TokenStream,
+) -> TokenStream {
+ let vis = &cx.proj.vis;
+ let lifetime = &cx.proj.lifetime;
+ let orig_ident = cx.orig.ident;
+ let proj_ident = &cx.proj.mut_ident;
+ let proj_ref_ident = &cx.proj.ref_ident;
+ let proj_own_ident = &cx.proj.own_ident;
+
+ let orig_ty_generics = cx.orig.generics.split_for_impl().1;
+ let proj_ty_generics = cx.proj.generics.split_for_impl().1;
+ let (impl_generics, ty_generics, where_clause) = cx.orig.generics.split_for_impl();
+ // TODO: For enums and project_replace, dead_code warnings should not be
+ // allowed because methods are not generated unless explicitly specified.
+ // However, there is currently no good way to allow warnings for generated
+ // code, so we allow warnings for all methods for now.
+ let allow_dead_code = quote! { #[allow(dead_code)] };
+
+ let mut project = Some(quote! {
+ #allow_dead_code
+ #vis fn project<#lifetime>(
+ self: _pin_project::__private::Pin<&#lifetime mut Self>,
+ ) -> #proj_ident #proj_ty_generics {
+ unsafe {
+ #proj_body
+ }
+ }
+ });
+ let mut project_ref = Some(quote! {
+ #allow_dead_code
+ #[allow(clippy::missing_const_for_fn)]
+ #vis fn project_ref<#lifetime>(
+ self: _pin_project::__private::Pin<&#lifetime Self>,
+ ) -> #proj_ref_ident #proj_ty_generics {
+ unsafe {
+ #proj_ref_body
+ }
+ }
+ });
+ let mut project_replace = cx.project_replace.span().map(|span| {
+ // It is enough to only set the span of the signature.
+ let sig = quote_spanned! { span =>
+ #allow_dead_code
+ #vis fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> #proj_own_ident #orig_ty_generics
+ };
+ quote! {
+ #sig {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+
+ // Destructors will run in reverse order, so next create a guard to overwrite
+ // `self` with the replacement value without calling destructors.
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+
+ #proj_own_body
+ }
+ }
+ }
+ });
+
+ if cx.kind == Enum {
+ if !cx.project {
+ project = None;
+ }
+ if !cx.project_ref {
+ project_ref = None;
+ }
+ if cx.project_replace.ident().is_none() {
+ project_replace = None;
+ }
+ }
+
+ quote! {
+ impl #impl_generics #orig_ident #ty_generics #where_clause {
+ #project
+ #project_ref
+ #project_replace
+ }
+ }
+}
+
+/// Checks that the `[repr(packed)]` attribute is not included.
+///
+/// This currently does two checks:
+/// - Checks the attributes of structs to ensure there is no `[repr(packed)]`.
+/// - Generates a function that borrows fields without an unsafe block and
+/// forbidding `unaligned_references` lint.
+fn ensure_not_packed(orig: &OriginalType<'_>, fields: Option<&Fields>) -> Result<TokenStream> {
+ for meta in orig.attrs.iter().filter_map(|attr| attr.parse_meta().ok()) {
+ if let Meta::List(list) = meta {
+ if list.path.is_ident("repr") {
+ for repr in list.nested.iter() {
+ match repr {
+ NestedMeta::Meta(Meta::Path(path))
+ | NestedMeta::Meta(Meta::List(MetaList { path, .. }))
+ | NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, .. })) => {
+ if path.is_ident("packed") {
+ let msg = if fields.is_none() {
+ // #[repr(packed)] cannot be apply on enums and will be rejected by rustc.
+ // However, we should not rely on the behavior of rustc that rejects this.
+ // https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+ "#[repr(packed)] attribute should be applied to a struct or union"
+ } else if let NestedMeta::Meta(Meta::NameValue(..)) = repr {
+ // #[repr(packed = "")] is not valid format of #[repr(packed)] and will be
+ // rejected by rustc.
+ // However, we should not rely on the behavior of rustc that rejects this.
+ // https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+ "#[repr(packed)] attribute should not be name-value pair"
+ } else {
+ "#[pin_project] attribute may not be used on #[repr(packed)] types"
+ };
+ bail!(repr, msg);
+ }
+ }
+ NestedMeta::Lit(..) => {}
+ }
+ }
+ }
+ }
+ }
+
+ let fields = match fields {
+ Some(fields) => fields,
+ None => return Ok(TokenStream::new()),
+ };
+
+ // Workaround for https://github.com/taiki-e/pin-project/issues/32
+ // Through the tricky use of proc macros, it's possible to bypass
+ // the above check for the `repr` attribute.
+ // To ensure that it's impossible to use pin projections on a `#[repr(packed)]`
+ // struct, we generate code like this:
+ //
+ // ```rust
+ // #[forbid(unaligned_references)]
+ // fn assert_not_repr_packed(val: &MyStruct) {
+ // let _field1 = &val.field1;
+ // let _field2 = &val.field2;
+ // ...
+ // let _fieldn = &val.fieldn;
+ // }
+ // ```
+ //
+ // Taking a reference to a packed field is UB, and applying
+ // `#[forbid(unaligned_references)]` makes sure that doing this is a hard error.
+ //
+ // If the struct ends up having `#[repr(packed)]` applied somehow,
+ // this will generate an (unfriendly) error message. Under all reasonable
+ // circumstances, we'll detect the `#[repr(packed)]` attribute, and generate
+ // a much nicer error above.
+ //
+ // There is one exception: If the type of a struct field has an alignment of 1
+ // (e.g. u8), it is always safe to take a reference to it, even if the struct
+ // is `#[repr(packed)]`. If the struct is composed entirely of types of
+ // alignment 1, our generated method will not trigger an error if the
+ // struct is `#[repr(packed)]`.
+ //
+ // Fortunately, this should have no observable consequence - `#[repr(packed)]`
+ // is essentially a no-op on such a type. Nevertheless, we include a test
+ // to ensure that the compiler doesn't ever try to copy the fields on
+ // such a struct when trying to drop it - which is reason we prevent
+ // `#[repr(packed)]` in the first place.
+ //
+ // See also https://github.com/taiki-e/pin-project/pull/34.
+ //
+ // Note:
+ // - Lint-based tricks aren't perfect, but they're much better than nothing:
+ // https://github.com/taiki-e/pin-project-lite/issues/26
+ //
+ // - Enable both unaligned_references and safe_packed_borrows lints
+ // because unaligned_references lint does not exist in older compilers:
+ // https://github.com/taiki-e/pin-project-lite/pull/55
+ // https://github.com/rust-lang/rust/pull/82525
+ let mut field_refs = vec![];
+ match fields {
+ Fields::Named(FieldsNamed { named, .. }) => {
+ for Field { ident, .. } in named {
+ field_refs.push(quote!(&this.#ident));
+ }
+ }
+ Fields::Unnamed(FieldsUnnamed { unnamed, .. }) => {
+ for (index, _) in unnamed.iter().enumerate() {
+ let index = Index::from(index);
+ field_refs.push(quote!(&this.#index));
+ }
+ }
+ Fields::Unit => {}
+ }
+
+ let (impl_generics, ty_generics, where_clause) = orig.generics.split_for_impl();
+ let ident = orig.ident;
+ Ok(quote! {
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed #impl_generics (this: &#ident #ty_generics) #where_clause {
+ #(let _ = #field_refs;)*
+ }
+ })
+}
diff --git a/third_party/rust/pin-project-internal/src/pin_project/mod.rs b/third_party/rust/pin-project-internal/src/pin_project/mod.rs
new file mode 100644
index 0000000000..2dce78f37f
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/pin_project/mod.rs
@@ -0,0 +1,17 @@
+mod args;
+mod attribute;
+mod derive;
+
+use proc_macro2::TokenStream;
+use syn::Error;
+
+/// The annotation for pinned type.
+const PIN: &str = "pin";
+
+pub(crate) fn attribute(args: &TokenStream, input: TokenStream) -> TokenStream {
+ attribute::parse_attribute(args, input).unwrap_or_else(Error::into_compile_error)
+}
+
+pub(crate) fn derive(input: TokenStream) -> TokenStream {
+ derive::parse_derive(input).unwrap_or_else(Error::into_compile_error)
+}
diff --git a/third_party/rust/pin-project-internal/src/pinned_drop.rs b/third_party/rust/pin-project-internal/src/pinned_drop.rs
new file mode 100644
index 0000000000..912989dd41
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/pinned_drop.rs
@@ -0,0 +1,226 @@
+use proc_macro2::TokenStream;
+use quote::{format_ident, quote, ToTokens};
+use syn::{
+ parse_quote, spanned::Spanned, visit_mut::VisitMut, Error, FnArg, GenericArgument, ImplItem,
+ ItemImpl, Pat, PatIdent, Path, PathArguments, Result, ReturnType, Signature, Token, Type,
+ TypePath, TypeReference,
+};
+
+use crate::utils::{parse_as_empty, prepend_underscore_to_self, ReplaceReceiver, SliceExt};
+
+pub(crate) fn attribute(args: &TokenStream, mut input: ItemImpl) -> TokenStream {
+ let res = (|| -> Result<()> {
+ parse_as_empty(args)?;
+ validate_impl(&input)?;
+ expand_impl(&mut input);
+ Ok(())
+ })();
+
+ if let Err(e) = res {
+ let mut tokens = e.to_compile_error();
+ if let Type::Path(self_ty) = &*input.self_ty {
+ let (impl_generics, _, where_clause) = input.generics.split_for_impl();
+
+ // Generate a dummy impl of `PinnedDrop`.
+ // In many cases, `#[pinned_drop] impl` is declared after `#[pin_project]`.
+ // Therefore, if `pinned_drop` compile fails, you will also get an error
+ // about `PinnedDrop` not being implemented.
+ // This can be prevented to some extent by generating a dummy
+ // `PinnedDrop` implementation.
+ // We already know that we will get a compile error, so this won't
+ // accidentally compile successfully.
+ //
+ // However, if `input.self_ty` is not Type::Path, there is a high possibility that
+ // the type does not exist (since #[pin_project] can only be used on struct/enum
+ // definitions), so do not generate a dummy impl.
+ tokens.extend(quote! {
+ impl #impl_generics ::pin_project::__private::PinnedDrop for #self_ty
+ #where_clause
+ {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+ });
+ }
+ tokens
+ } else {
+ input.into_token_stream()
+ }
+}
+
+/// Validates the signature of given `PinnedDrop` impl.
+fn validate_impl(item: &ItemImpl) -> Result<()> {
+ const INVALID_ITEM: &str =
+ "#[pinned_drop] may only be used on implementation for the `PinnedDrop` trait";
+
+ if let Some(attr) = item.attrs.find("pinned_drop") {
+ bail!(attr, "duplicate #[pinned_drop] attribute");
+ }
+
+ if let Some((_, path, _)) = &item.trait_ {
+ if !path.is_ident("PinnedDrop") {
+ bail!(path, INVALID_ITEM);
+ }
+ } else {
+ bail!(item.self_ty, INVALID_ITEM);
+ }
+
+ if item.unsafety.is_some() {
+ bail!(item.unsafety, "implementing the trait `PinnedDrop` is not unsafe");
+ }
+ if item.items.is_empty() {
+ bail!(item, "not all trait items implemented, missing: `drop`");
+ }
+
+ match &*item.self_ty {
+ Type::Path(_) => {}
+ ty => {
+ bail!(ty, "implementing the trait `PinnedDrop` on this type is unsupported");
+ }
+ }
+
+ item.items.iter().enumerate().try_for_each(|(i, item)| match item {
+ ImplItem::Const(item) => {
+ bail!(item, "const `{}` is not a member of trait `PinnedDrop`", item.ident)
+ }
+ ImplItem::Type(item) => {
+ bail!(item, "type `{}` is not a member of trait `PinnedDrop`", item.ident)
+ }
+ ImplItem::Method(method) => {
+ validate_sig(&method.sig)?;
+ if i == 0 {
+ Ok(())
+ } else {
+ bail!(method, "duplicate definitions with name `drop`")
+ }
+ }
+ _ => unreachable!("unexpected ImplItem"),
+ })
+}
+
+/// Validates the signature of given `PinnedDrop::drop` method.
+///
+/// The correct signature is: `(mut) self: (<path>::)Pin<&mut Self>`
+fn validate_sig(sig: &Signature) -> Result<()> {
+ fn get_ty_path(ty: &Type) -> Option<&Path> {
+ if let Type::Path(TypePath { qself: None, path }) = ty {
+ Some(path)
+ } else {
+ None
+ }
+ }
+
+ const INVALID_ARGUMENT: &str = "method `drop` must take an argument `self: Pin<&mut Self>`";
+
+ if sig.ident != "drop" {
+ bail!(sig.ident, "method `{}` is not a member of trait `PinnedDrop", sig.ident,);
+ }
+
+ if let ReturnType::Type(_, ty) = &sig.output {
+ match &**ty {
+ Type::Tuple(ty) if ty.elems.is_empty() => {}
+ _ => bail!(ty, "method `drop` must return the unit type"),
+ }
+ }
+
+ match sig.inputs.len() {
+ 1 => {}
+ 0 => return Err(Error::new(sig.paren_token.span, INVALID_ARGUMENT)),
+ _ => bail!(sig.inputs, INVALID_ARGUMENT),
+ }
+
+ if let Some(FnArg::Typed(arg)) = sig.receiver() {
+ // (mut) self: <path>
+ if let Some(path) = get_ty_path(&arg.ty) {
+ let ty = path.segments.last().unwrap();
+ if let PathArguments::AngleBracketed(args) = &ty.arguments {
+ // (mut) self: (<path>::)<ty><&mut <elem>..>
+ if let Some(GenericArgument::Type(Type::Reference(TypeReference {
+ mutability: Some(_),
+ elem,
+ ..
+ }))) = args.args.first()
+ {
+ // (mut) self: (<path>::)Pin<&mut Self>
+ if args.args.len() == 1
+ && ty.ident == "Pin"
+ && get_ty_path(elem).map_or(false, |path| path.is_ident("Self"))
+ {
+ if sig.unsafety.is_some() {
+ bail!(sig.unsafety, "implementing the method `drop` is not unsafe");
+ }
+ return Ok(());
+ }
+ }
+ }
+ }
+ }
+
+ bail!(sig.inputs[0], INVALID_ARGUMENT)
+}
+
+// from:
+//
+// fn drop(self: Pin<&mut Self>) {
+// // ...
+// }
+//
+// into:
+//
+// unsafe fn drop(self: Pin<&mut Self>) {
+// fn __drop_inner<T>(__self: Pin<&mut Foo<'_, T>>) {
+// fn __drop_inner() {}
+// // ...
+// }
+// __drop_inner(self);
+// }
+//
+fn expand_impl(item: &mut ItemImpl) {
+ fn get_arg_pat(arg: &mut FnArg) -> Option<&mut PatIdent> {
+ if let FnArg::Typed(arg) = arg {
+ if let Pat::Ident(ident) = &mut *arg.pat {
+ return Some(ident);
+ }
+ }
+ None
+ }
+
+ // `PinnedDrop` is a private trait and should not appear in docs.
+ item.attrs.push(parse_quote!(#[doc(hidden)]));
+
+ let path = &mut item.trait_.as_mut().unwrap().1;
+ *path = parse_quote_spanned! { path.span() =>
+ ::pin_project::__private::PinnedDrop
+ };
+
+ let method =
+ if let ImplItem::Method(method) = &mut item.items[0] { method } else { unreachable!() };
+
+ // `fn drop(mut self: Pin<&mut Self>)` -> `fn __drop_inner<T>(mut __self: Pin<&mut Receiver>)`
+ let drop_inner = {
+ let mut drop_inner = method.clone();
+ let ident = format_ident!("__drop_inner");
+ // Add a dummy `__drop_inner` function to prevent users call outer `__drop_inner`.
+ drop_inner.block.stmts.insert(0, parse_quote!(fn #ident() {}));
+ drop_inner.sig.ident = ident;
+ drop_inner.sig.generics = item.generics.clone();
+ let self_pat = get_arg_pat(&mut drop_inner.sig.inputs[0]).unwrap();
+ prepend_underscore_to_self(&mut self_pat.ident);
+ let self_ty = if let Type::Path(ty) = &*item.self_ty { ty } else { unreachable!() };
+ let mut visitor = ReplaceReceiver(self_ty);
+ visitor.visit_signature_mut(&mut drop_inner.sig);
+ visitor.visit_block_mut(&mut drop_inner.block);
+ drop_inner
+ };
+
+ // `fn drop(mut self: Pin<&mut Self>)` -> `unsafe fn drop(self: Pin<&mut Self>)`
+ method.sig.unsafety = Some(<Token![unsafe]>::default());
+ let self_pat = get_arg_pat(&mut method.sig.inputs[0]).unwrap();
+ self_pat.mutability = None;
+ let self_token = &self_pat.ident;
+
+ method.block.stmts = parse_quote! {
+ #[allow(clippy::needless_pass_by_value)] // This lint does not warn the receiver.
+ #drop_inner
+ __drop_inner(#self_token);
+ };
+}
diff --git a/third_party/rust/pin-project-internal/src/utils.rs b/third_party/rust/pin-project-internal/src/utils.rs
new file mode 100644
index 0000000000..27373efbae
--- /dev/null
+++ b/third_party/rust/pin-project-internal/src/utils.rs
@@ -0,0 +1,402 @@
+use std::{iter::FromIterator, mem};
+
+use proc_macro2::{Group, Spacing, Span, TokenStream, TokenTree};
+use quote::{quote, quote_spanned, ToTokens};
+use syn::{
+ parse::{Parse, ParseBuffer, ParseStream},
+ parse_quote,
+ punctuated::Punctuated,
+ token,
+ visit_mut::{self, VisitMut},
+ Attribute, ExprPath, ExprStruct, Generics, Ident, Item, Lifetime, LifetimeDef, Macro, PatPath,
+ PatStruct, PatTupleStruct, Path, PathArguments, PredicateType, QSelf, Result, Token, Type,
+ TypeParamBound, TypePath, Variant, Visibility, WherePredicate,
+};
+
+pub(crate) type Variants = Punctuated<Variant, Token![,]>;
+
+macro_rules! format_err {
+ ($span:expr, $msg:expr $(,)?) => {
+ syn::Error::new_spanned(&$span as &dyn quote::ToTokens, &$msg as &dyn std::fmt::Display)
+ };
+ ($span:expr, $($tt:tt)*) => {
+ format_err!($span, format!($($tt)*))
+ };
+}
+
+macro_rules! bail {
+ ($($tt:tt)*) => {
+ return Err(format_err!($($tt)*))
+ };
+}
+
+macro_rules! parse_quote_spanned {
+ ($span:expr => $($tt:tt)*) => {
+ syn::parse2(quote::quote_spanned!($span => $($tt)*)).unwrap_or_else(|e| panic!("{}", e))
+ };
+}
+
+/// Determines the lifetime names. Ensure it doesn't overlap with any existing
+/// lifetime names.
+pub(crate) fn determine_lifetime_name(lifetime_name: &mut String, generics: &mut Generics) {
+ struct CollectLifetimes(Vec<String>);
+
+ impl VisitMut for CollectLifetimes {
+ fn visit_lifetime_def_mut(&mut self, def: &mut LifetimeDef) {
+ self.0.push(def.lifetime.to_string());
+ }
+ }
+
+ debug_assert!(lifetime_name.starts_with('\''));
+
+ let mut lifetimes = CollectLifetimes(Vec::new());
+ lifetimes.visit_generics_mut(generics);
+
+ while lifetimes.0.iter().any(|name| name.starts_with(&**lifetime_name)) {
+ lifetime_name.push('_');
+ }
+}
+
+/// Like `insert_lifetime`, but also generates a bound of the form
+/// `OriginalType<A, B>: 'lifetime`. Used when generating the definition
+/// of a projection type
+pub(crate) fn insert_lifetime_and_bound(
+ generics: &mut Generics,
+ lifetime: Lifetime,
+ orig_generics: &Generics,
+ orig_ident: &Ident,
+) -> WherePredicate {
+ insert_lifetime(generics, lifetime.clone());
+
+ let orig_type: Type = parse_quote!(#orig_ident #orig_generics);
+ let mut punct = Punctuated::new();
+ punct.push(TypeParamBound::Lifetime(lifetime));
+
+ WherePredicate::Type(PredicateType {
+ lifetimes: None,
+ bounded_ty: orig_type,
+ colon_token: <Token![:]>::default(),
+ bounds: punct,
+ })
+}
+
+/// Inserts a `lifetime` at position `0` of `generics.params`.
+pub(crate) fn insert_lifetime(generics: &mut Generics, lifetime: Lifetime) {
+ generics.lt_token.get_or_insert_with(<Token![<]>::default);
+ generics.gt_token.get_or_insert_with(<Token![>]>::default);
+ generics.params.insert(0, LifetimeDef::new(lifetime).into());
+}
+
+/// Determines the visibility of the projected types and projection methods.
+///
+/// If given visibility is `pub`, returned visibility is `pub(crate)`.
+/// Otherwise, returned visibility is the same as given visibility.
+pub(crate) fn determine_visibility(vis: &Visibility) -> Visibility {
+ if let Visibility::Public(token) = vis {
+ parse_quote_spanned!(token.pub_token.span => pub(crate))
+ } else {
+ vis.clone()
+ }
+}
+
+/// Checks if `tokens` is an empty `TokenStream`.
+///
+/// This is almost equivalent to `syn::parse2::<Nothing>()`, but produces
+/// a better error message and does not require ownership of `tokens`.
+pub(crate) fn parse_as_empty(tokens: &TokenStream) -> Result<()> {
+ if tokens.is_empty() {
+ Ok(())
+ } else {
+ bail!(tokens, "unexpected token: `{}`", tokens)
+ }
+}
+
+pub(crate) fn respan<T>(node: &T, span: Span) -> T
+where
+ T: ToTokens + Parse,
+{
+ let tokens = node.to_token_stream();
+ let respanned = respan_tokens(tokens, span);
+ syn::parse2(respanned).unwrap()
+}
+
+fn respan_tokens(tokens: TokenStream, span: Span) -> TokenStream {
+ tokens
+ .into_iter()
+ .map(|mut token| {
+ token.set_span(span);
+ token
+ })
+ .collect()
+}
+
+// =================================================================================================
+// extension traits
+
+pub(crate) trait SliceExt {
+ fn position_exact(&self, ident: &str) -> Result<Option<usize>>;
+ fn find(&self, ident: &str) -> Option<&Attribute>;
+}
+
+impl SliceExt for [Attribute] {
+ /// # Errors
+ ///
+ /// - There are multiple specified attributes.
+ /// - The `Attribute::tokens` field of the specified attribute is not empty.
+ fn position_exact(&self, ident: &str) -> Result<Option<usize>> {
+ self.iter()
+ .try_fold((0, None), |(i, mut prev), attr| {
+ if attr.path.is_ident(ident) {
+ if prev.replace(i).is_some() {
+ bail!(attr, "duplicate #[{}] attribute", ident);
+ }
+ parse_as_empty(&attr.tokens)?;
+ }
+ Ok((i + 1, prev))
+ })
+ .map(|(_, pos)| pos)
+ }
+
+ fn find(&self, ident: &str) -> Option<&Attribute> {
+ self.iter().position(|attr| attr.path.is_ident(ident)).map(|i| &self[i])
+ }
+}
+
+pub(crate) trait ParseBufferExt<'a> {
+ fn parenthesized(self) -> Result<ParseBuffer<'a>>;
+}
+
+impl<'a> ParseBufferExt<'a> for ParseStream<'a> {
+ fn parenthesized(self) -> Result<ParseBuffer<'a>> {
+ let content;
+ let _: token::Paren = syn::parenthesized!(content in self);
+ Ok(content)
+ }
+}
+
+impl<'a> ParseBufferExt<'a> for ParseBuffer<'a> {
+ fn parenthesized(self) -> Result<ParseBuffer<'a>> {
+ let content;
+ let _: token::Paren = syn::parenthesized!(content in self);
+ Ok(content)
+ }
+}
+
+// =================================================================================================
+// visitors
+
+// Replace `self`/`Self` with `__self`/`self_ty`.
+// Based on:
+// - https://github.com/dtolnay/async-trait/blob/0.1.35/src/receiver.rs
+// - https://github.com/dtolnay/async-trait/commit/6029cbf375c562ca98fa5748e9d950a8ff93b0e7
+
+pub(crate) struct ReplaceReceiver<'a>(pub(crate) &'a TypePath);
+
+impl ReplaceReceiver<'_> {
+ fn self_ty(&self, span: Span) -> TypePath {
+ respan(self.0, span)
+ }
+
+ fn self_to_qself(&self, qself: &mut Option<QSelf>, path: &mut Path) {
+ if path.leading_colon.is_some() {
+ return;
+ }
+
+ let first = &path.segments[0];
+ if first.ident != "Self" || !first.arguments.is_empty() {
+ return;
+ }
+
+ if path.segments.len() == 1 {
+ self.self_to_expr_path(path);
+ return;
+ }
+
+ let span = first.ident.span();
+ *qself = Some(QSelf {
+ lt_token: Token![<](span),
+ ty: Box::new(self.self_ty(span).into()),
+ position: 0,
+ as_token: None,
+ gt_token: Token![>](span),
+ });
+
+ path.leading_colon = Some(**path.segments.pairs().next().unwrap().punct().unwrap());
+
+ let segments = mem::replace(&mut path.segments, Punctuated::new());
+ path.segments = segments.into_pairs().skip(1).collect();
+ }
+
+ fn self_to_expr_path(&self, path: &mut Path) {
+ if path.leading_colon.is_some() {
+ return;
+ }
+
+ let first = &path.segments[0];
+ if first.ident != "Self" || !first.arguments.is_empty() {
+ return;
+ }
+
+ let self_ty = self.self_ty(first.ident.span());
+ let variant = mem::replace(path, self_ty.path);
+ for segment in &mut path.segments {
+ if let PathArguments::AngleBracketed(bracketed) = &mut segment.arguments {
+ if bracketed.colon2_token.is_none() && !bracketed.args.is_empty() {
+ bracketed.colon2_token = Some(<Token![::]>::default());
+ }
+ }
+ }
+ if variant.segments.len() > 1 {
+ path.segments.push_punct(<Token![::]>::default());
+ path.segments.extend(variant.segments.into_pairs().skip(1));
+ }
+ }
+
+ fn visit_token_stream(&self, tokens: &mut TokenStream) -> bool {
+ let mut out = Vec::new();
+ let mut modified = false;
+ let mut iter = tokens.clone().into_iter().peekable();
+ while let Some(tt) = iter.next() {
+ match tt {
+ TokenTree::Ident(mut ident) => {
+ modified |= prepend_underscore_to_self(&mut ident);
+ if ident == "Self" {
+ modified = true;
+ let self_ty = self.self_ty(ident.span());
+ match iter.peek() {
+ Some(TokenTree::Punct(p))
+ if p.as_char() == ':' && p.spacing() == Spacing::Joint =>
+ {
+ let next = iter.next().unwrap();
+ match iter.peek() {
+ Some(TokenTree::Punct(p)) if p.as_char() == ':' => {
+ let span = ident.span();
+ out.extend(quote_spanned!(span=> <#self_ty>));
+ }
+ _ => out.extend(quote!(#self_ty)),
+ }
+ out.push(next);
+ }
+ _ => out.extend(quote!(#self_ty)),
+ }
+ } else {
+ out.push(TokenTree::Ident(ident));
+ }
+ }
+ TokenTree::Group(group) => {
+ let mut content = group.stream();
+ modified |= self.visit_token_stream(&mut content);
+ let mut new = Group::new(group.delimiter(), content);
+ new.set_span(group.span());
+ out.push(TokenTree::Group(new));
+ }
+ other => out.push(other),
+ }
+ }
+ if modified {
+ *tokens = TokenStream::from_iter(out);
+ }
+ modified
+ }
+}
+
+impl VisitMut for ReplaceReceiver<'_> {
+ // `Self` -> `Receiver`
+ fn visit_type_mut(&mut self, ty: &mut Type) {
+ if let Type::Path(node) = ty {
+ if node.qself.is_none() && node.path.is_ident("Self") {
+ *ty = self.self_ty(node.path.segments[0].ident.span()).into();
+ } else {
+ self.visit_type_path_mut(node);
+ }
+ } else {
+ visit_mut::visit_type_mut(self, ty);
+ }
+ }
+
+ // `Self::Assoc` -> `<Receiver>::Assoc`
+ fn visit_type_path_mut(&mut self, ty: &mut TypePath) {
+ if ty.qself.is_none() {
+ self.self_to_qself(&mut ty.qself, &mut ty.path);
+ }
+ visit_mut::visit_type_path_mut(self, ty);
+ }
+
+ // `Self::method` -> `<Receiver>::method`
+ fn visit_expr_path_mut(&mut self, expr: &mut ExprPath) {
+ if expr.qself.is_none() {
+ self.self_to_qself(&mut expr.qself, &mut expr.path);
+ }
+ visit_mut::visit_expr_path_mut(self, expr);
+ }
+
+ fn visit_expr_struct_mut(&mut self, expr: &mut ExprStruct) {
+ self.self_to_expr_path(&mut expr.path);
+ visit_mut::visit_expr_struct_mut(self, expr);
+ }
+
+ fn visit_pat_path_mut(&mut self, pat: &mut PatPath) {
+ if pat.qself.is_none() {
+ self.self_to_qself(&mut pat.qself, &mut pat.path);
+ }
+ visit_mut::visit_pat_path_mut(self, pat);
+ }
+
+ fn visit_pat_struct_mut(&mut self, pat: &mut PatStruct) {
+ self.self_to_expr_path(&mut pat.path);
+ visit_mut::visit_pat_struct_mut(self, pat);
+ }
+
+ fn visit_pat_tuple_struct_mut(&mut self, pat: &mut PatTupleStruct) {
+ self.self_to_expr_path(&mut pat.path);
+ visit_mut::visit_pat_tuple_struct_mut(self, pat);
+ }
+
+ fn visit_path_mut(&mut self, path: &mut Path) {
+ if path.segments.len() == 1 {
+ // Replace `self`, but not `self::function`.
+ prepend_underscore_to_self(&mut path.segments[0].ident);
+ }
+ for segment in &mut path.segments {
+ self.visit_path_arguments_mut(&mut segment.arguments);
+ }
+ }
+
+ fn visit_item_mut(&mut self, item: &mut Item) {
+ match item {
+ // Visit `macro_rules!` because locally defined macros can refer to `self`.
+ Item::Macro(item) if item.mac.path.is_ident("macro_rules") => {
+ self.visit_macro_mut(&mut item.mac);
+ }
+ // Otherwise, do not recurse into nested items.
+ _ => {}
+ }
+ }
+
+ fn visit_macro_mut(&mut self, mac: &mut Macro) {
+ // We can't tell in general whether `self` inside a macro invocation
+ // refers to the self in the argument list or a different self
+ // introduced within the macro. Heuristic: if the macro input contains
+ // `fn`, then `self` is more likely to refer to something other than the
+ // outer function's self argument.
+ if !contains_fn(mac.tokens.clone()) {
+ self.visit_token_stream(&mut mac.tokens);
+ }
+ }
+}
+
+fn contains_fn(tokens: TokenStream) -> bool {
+ tokens.into_iter().any(|tt| match tt {
+ TokenTree::Ident(ident) => ident == "fn",
+ TokenTree::Group(group) => contains_fn(group.stream()),
+ _ => false,
+ })
+}
+
+pub(crate) fn prepend_underscore_to_self(ident: &mut Ident) -> bool {
+ let modified = ident == "self";
+ if modified {
+ *ident = Ident::new("__self", ident.span());
+ }
+ modified
+}
diff --git a/third_party/rust/pin-project-lite/.cargo-checksum.json b/third_party/rust/pin-project-lite/.cargo-checksum.json
new file mode 100644
index 0000000000..249c55e4be
--- /dev/null
+++ b/third_party/rust/pin-project-lite/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"0da6eac8d8957a8aea735942d2e6e226b5cb178a363fe77b87c23272f2e63b1c","Cargo.toml":"b0b0099d5e8af1ffbe68c0b4e367a00602dbf1acab35f8c956129918b17a5425","LICENSE-APACHE":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"609412221520fc16f47e76131927e4dd11aef38f7c69d92a1116130654f0ee90","src/lib.rs":"7b76a04ae98aa1e9ee85b9a2e1f054384b39df74cdfb375ff46649af8ec4b5b3","tests/README.md":"71fc84264ec08d2b7f1c74c1ba5140a376121b72145cc630b616e6f2536aeafa","tests/auxiliary/mod.rs":"7e263e987e09b77e384f734384a00a71c5b70230bb1b5376446ef003a8da9372","tests/compiletest.rs":"f764ff03c73c8a21c35ee30cf851b9266b2987e88d646d9bd086fc71944eb945","tests/drop_order.rs":"2cb31a8cd5cf4d9a4ba9faf25f99f0e85f9bd7b4778649f843d9c617c6af43fc","tests/expand/default/enum.expanded.rs":"c4db8e05cfe6eab3be39301abf77689f79fdaff52605350a2aee464b2756180e","tests/expand/default/enum.rs":"493d5752c4baa87ed4c48bd41b8e5e263fd5e3f43c4f9195818ef6d26951f63e","tests/expand/default/struct.expanded.rs":"c158632984eaf6ab8ae60b76ff2bf32b20ba10a3cbc4237c9a6ea28c614cdb01","tests/expand/default/struct.rs":"5a6e57d9b6d00cfd4e1e69f37ce0c9d5165a21230d0363f0791665b1015870ce","tests/expand/multifields/enum.expanded.rs":"8bba6a5a2279469bf94c486a6efb2f8c9ed965b716d66ac0660662e11ca0bddb","tests/expand/multifields/enum.rs":"9c79270a7d6d1d42cf8194b579d79e7d44a3fd003243742f0a568ecf0a4f3be3","tests/expand/multifields/struct.expanded.rs":"46ac58981d4ee4eba61b879ba62b313ceac59f9a223ae4984450f72a9173cbd2","tests/expand/multifields/struct.rs":"17f0447d522d48f14d516808bd66baacebdf3ac38188df72f649702a893cda68","tests/expand/naming/enum-all.expanded.rs":"c4db8e05cfe6eab3be39301abf77689f79fdaff52605350a2aee464b2756180e","tests/expand/naming/enum-all.rs":"493d5752c4baa87ed4c48bd41b8e5e263fd5e3f43c4f9195818ef6d26951f63e","tests/expand/naming/enum-mut.expanded.rs":"ce1a12428d3906c8d98516b3afdcbbbda64776e2f0c039e90f3de8f734ab1878","tests/expand/naming/enum-mut.rs":"c1ff4ade049ebbceb2acb99dbc1af5db14de3ba9710ea1ff1b64348766a9e080","tests/expand/naming/enum-none.expanded.rs":"cf8ea074b8079af453a2f98e2217704e96174433e4ac0e07577f9242ad3d5de2","tests/expand/naming/enum-none.rs":"ff22be4ecf4168e2bc68ab249a0ed809a37e3b8e840ef8977d24209ef28ac839","tests/expand/naming/enum-ref.expanded.rs":"277e9642e49f4dc312ea09b4d9f8012994662f565529865102be0fe1657c2b13","tests/expand/naming/enum-ref.rs":"394cbd5d872449e9226cd0834ce7117c395a582567584218dabbef4eb2c1fbac","tests/expand/naming/struct-all.expanded.rs":"807c74c57928e068725fa8272a1d1c671401ed213ce8abf1a405a35b1fb47673","tests/expand/naming/struct-all.rs":"c13c0aacee85b8fca58f85d2d75d2e3907b3e7642f8710ed8c8e54d6015881cc","tests/expand/naming/struct-mut.expanded.rs":"f08b34f7d49ad45ae0a1ae8b64995d63e7e4eed2910a912f6c622a0b8e410b89","tests/expand/naming/struct-mut.rs":"9a7752a6d30e0b7033f3577a72676676900a642cdaf59f942179d1f2a8ba2bb0","tests/expand/naming/struct-none.expanded.rs":"c158632984eaf6ab8ae60b76ff2bf32b20ba10a3cbc4237c9a6ea28c614cdb01","tests/expand/naming/struct-none.rs":"5a6e57d9b6d00cfd4e1e69f37ce0c9d5165a21230d0363f0791665b1015870ce","tests/expand/naming/struct-ref.expanded.rs":"dabc3fda847ab2f4e4ca0ec6f6dc4da43f8de087117dcafb3c15780cebc7af45","tests/expand/naming/struct-ref.rs":"33c4fd344b65650dee44087ada31d4b5acd9d122123360fb7d41718c46699574","tests/expand/pinned_drop/enum.expanded.rs":"56d709a0cfc0c951fe303bf2b034e7fae4fc5271b9a11ade9c6a9c20c89471b3","tests/expand/pinned_drop/enum.rs":"d7e087b6852338fabe7edf39529c8f893a426b4d0c6aba2d2a6be0d95f739cdc","tests/expand/pinned_drop/struct.expanded.rs":"c9b26224339f126ce5f0d36cd8d6c6e84970bf39b94dc11bc42743ad5bdba6be","tests/expand/pinned_drop/struct.rs":"164a25e12b9898c093b5dee2c47a40dd549e6f49ba1c6bb22f4e4c4b98fe76b2","tests/expand/pub/enum.expanded.rs":"56c81c0535f8fb9b83662fc3753f7c07b96eb12392669bb1ae23ffc82b7c4a2c","tests/expand/pub/enum.rs":"5b60dd354a489b0326f5c4f1026b89d1471ddbb45906bc3046a65425c4e5e160","tests/expand/pub/struct.expanded.rs":"525c52bf7185493046618ee0dc1b18bdc0c0a56383f5c7b11c98738211d024a7","tests/expand/pub/struct.rs":"15b7940ce0ad1d5d133dde1870319f2f96a000bfcf29508b8cce1a62876cbd80","tests/expandtest.rs":"898df948c7ee82df0e0823cbde16ccc2b9dba455475665e6d2c7c0a84493e9fb","tests/include/basic.rs":"9e399b682bc74c899d26924c2cab52a911f7392e29300defb6521e561fafafe4","tests/lint.rs":"513ffda15a1e8e64076e8a1b7db709d5de8eebaf7952839974056e99afedde82","tests/proper_unpin.rs":"57a9e8c9029ba7920ec23670b66758916e067c9cecf4d3f8b0035bec25cdb570","tests/test.rs":"8d0ee300af17535dc7fd488433630911ddc3147a3e3ccf0b9dce9f0ccdb10dc3","tests/ui/pin_project/conflict-drop.rs":"55e6809b5f59dd81e32c2c89b742c0c76db6b099a1d2621e5b882c0d20f92837","tests/ui/pin_project/conflict-drop.stderr":"d22314903c031c1dad5fba81b8819fd9a1459ed4f750534032eaa3296db9e4ac","tests/ui/pin_project/conflict-unpin.rs":"51b3b6720fa581b63167d6ac941a1ea1bf739b09954931b2bc2f7abe2d934f26","tests/ui/pin_project/conflict-unpin.stderr":"4ca72632a5926cc70cb489311f6ac2e16b13fb5508cc2afb3b873071b37f3ba4","tests/ui/pin_project/invalid-bounds.rs":"f86f23d377df015182f2f5dae6464a4f98c37f2198e0646f721fedc4017cb82c","tests/ui/pin_project/invalid-bounds.stderr":"12009b6b91820cf199b0b1663d70ddb03c01c4645f0937a6812abe2e0112101c","tests/ui/pin_project/invalid.rs":"7304bd4a5bac1419382742432cfa8af83535d7be8cfad52c661410e0e9e8207a","tests/ui/pin_project/invalid.stderr":"c690c368166c588501f7af306915a5ad131e3d4c5e6c519387f27dc7daaf9e84","tests/ui/pin_project/overlapping_lifetime_names.rs":"36c849a4570c8c0c32ca6c01aa75afbe1136ef73d45f17eb66175e1936678722","tests/ui/pin_project/overlapping_lifetime_names.stderr":"93646dd1a0a9b5106a189d2dbf11ad6010f91ba6adc545fe9fb350d05e5565b9","tests/ui/pin_project/overlapping_unpin_struct.rs":"9a126182d1fe15a30ac60bb223b376aad747d11293d3cf512ad2dce546e3725c","tests/ui/pin_project/overlapping_unpin_struct.stderr":"a7297c94c18c582eba24f801a69dc9ee25f28e58b9c15493ae89aa62bfae045a","tests/ui/pin_project/packed.rs":"2ede405a0d101eb843ea83c2836cc8399da54c105776f2c795f3138e03a1e5ef","tests/ui/pin_project/packed.stderr":"7601fac825e3715b4cc8024bd489c35edbb98baa270a3ac1d591fc683afc5c56","tests/ui/pin_project/unpin_sneaky.rs":"12e97a387ce1af6ee6a567687674aab70e96962a48f2433c39976d0b3e2c3341","tests/ui/pin_project/unpin_sneaky.stderr":"972e313b129ff58d05c1de4ace8f41da18e3813abeda8173cf5e9fdfdbea2251","tests/ui/pin_project/unsupported.rs":"14defa90e736f314bbbc219973929b77bdd22e5f7e4c4c88403db764f4d167d6","tests/ui/pin_project/unsupported.stderr":"2602db59fed6be1ac66e573b2a44e88b7d9ed18674d04fa62f97ee7ad21eaa30","tests/ui/pinned_drop/call-drop-inner.rs":"032260da1fc0e649d97167a8a4ac47eea915000efebdfdc490f050b6f9351027","tests/ui/pinned_drop/call-drop-inner.stderr":"18e4d2be8a25ea7092c91e311cbdd5fae20dee494a168caa01abe01527ed07ce","tests/ui/pinned_drop/conditional-drop-impl.rs":"0b28c74213cee83e7b27223d7d37f903f79abd3dddcc0f969e14047674908085","tests/ui/pinned_drop/conditional-drop-impl.stderr":"a0e102a8746c1d078348d7447d1bd8073afe537fb18c199ec020f0bfd63cfd07"},"package":"e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"} \ No newline at end of file
diff --git a/third_party/rust/pin-project-lite/CHANGELOG.md b/third_party/rust/pin-project-lite/CHANGELOG.md
new file mode 100644
index 0000000000..127e467989
--- /dev/null
+++ b/third_party/rust/pin-project-lite/CHANGELOG.md
@@ -0,0 +1,222 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+This project adheres to [Semantic Versioning](https://semver.org).
+
+<!--
+Note: In this file, do not use the hard wrap in the middle of a sentence for compatibility with GitHub comment style markdown rendering.
+-->
+
+## [Unreleased]
+
+## [0.2.9] - 2022-04-26
+
+- Improve compile time of `pin_project!` calls. (#71, thanks @nnethercote)
+
+## [0.2.8] - 2021-12-31
+
+- Fix handling of trailing commas in `PinnedDrop` impl. ([#64](https://github.com/taiki-e/pin-project-lite/pull/64), thanks @Michael-J-Ward)
+
+## [0.2.7] - 2021-06-26
+
+- [Support custom Drop implementation.](https://github.com/taiki-e/pin-project-lite/pull/25) See [#25](https://github.com/taiki-e/pin-project-lite/pull/25) for details.
+
+## [0.2.6] - 2021-03-04
+
+- Support item attributes in any order. ([#57](https://github.com/taiki-e/pin-project-lite/pull/57), thanks @SabrinaJewson)
+
+## [0.2.5] - 2021-03-02
+
+- [Prepare for removal of `safe_packed_borrows` lint.](https://github.com/taiki-e/pin-project-lite/pull/55) See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+## [0.2.4] - 2021-01-11
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- Add `project_replace`. ([#43](https://github.com/taiki-e/pin-project-lite/pull/43), thanks @Marwes)
+
+## [0.2.3] - 2021-01-09
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Suppress `clippy::unknown_clippy_lints` lint in generated code.](https://github.com/taiki-e/pin-project-lite/pull/47)
+
+## [0.2.2] - 2021-01-09
+
+**Note:** This release has been yanked.** See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Suppress `clippy::ref_option_ref` lint in generated code.](https://github.com/taiki-e/pin-project-lite/pull/45)
+
+## [0.2.1] - 2021-01-05
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- Exclude unneeded files from crates.io.
+
+## [0.2.0] - 2020-11-13
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [`pin_project!` macro now supports enums.](https://github.com/taiki-e/pin-project-lite/pull/28)
+
+ To use `pin_project!` on enums, you need to name the projection type returned from the method.
+
+ ```rust
+ use pin_project_lite::pin_project;
+ use std::pin::Pin;
+
+ pin_project! {
+ #[project = EnumProj]
+ enum Enum<T, U> {
+ Variant { #[pin] pinned: T, unpinned: U },
+ }
+ }
+
+ impl<T, U> Enum<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ match self.project() {
+ EnumProj::Variant { pinned, unpinned } => {
+ let _: Pin<&mut T> = pinned;
+ let _: &mut U = unpinned;
+ }
+ }
+ }
+ }
+ ```
+
+- [Support naming the projection types.](https://github.com/taiki-e/pin-project-lite/pull/28)
+
+ By passing an attribute with the same name as the method, you can name the projection type returned from the method:
+
+ ```rust
+ use pin_project_lite::pin_project;
+ use std::pin::Pin;
+
+ pin_project! {
+ #[project = StructProj]
+ struct Struct<T> {
+ #[pin]
+ field: T,
+ }
+ }
+
+ fn func<T>(x: Pin<&mut Struct<T>>) {
+ let StructProj { field } = x.project();
+ let _: Pin<&mut T> = field;
+ }
+ ```
+
+## [0.1.12] - 2021-03-02
+
+- [Prepare for removal of `safe_packed_borrows` lint.](https://github.com/taiki-e/pin-project-lite/pull/55) See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+## [0.1.11] - 2020-10-20
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- Suppress `clippy::redundant_pub_crate` lint in generated code.
+
+- Documentation improvements.
+
+## [0.1.10] - 2020-10-01
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- Suppress `drop_bounds` lint, which will be added to rustc in the future. See [taiki-e/pin-project#272](https://github.com/taiki-e/pin-project/issues/272) for more details.
+
+## [0.1.9] - 2020-09-29
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Fix trailing comma support in generics.](https://github.com/taiki-e/pin-project-lite/pull/32)
+
+## [0.1.8] - 2020-09-26
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Fix compatibility of generated code with `forbid(future_incompatible)`.](https://github.com/taiki-e/pin-project-lite/pull/30)
+
+ 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.1.7] - 2020-06-04
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Support `?Sized` bounds in where clauses.](https://github.com/taiki-e/pin-project-lite/pull/22)
+
+- [Fix lifetime inference error when an associated type is used in fields.](https://github.com/taiki-e/pin-project-lite/pull/20)
+
+- Suppress `clippy::used_underscore_binding` lint in generated code.
+
+- Documentation improvements.
+
+## [0.1.6] - 2020-05-31
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Support lifetime bounds in where clauses.](https://github.com/taiki-e/pin-project-lite/pull/18)
+
+- Documentation improvements.
+
+## [0.1.5] - 2020-05-07
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Support overwriting the name of `core` crate.](https://github.com/taiki-e/pin-project-lite/pull/14)
+
+## [0.1.4] - 2020-01-20
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Support ?Sized bounds in generic parameters.](https://github.com/taiki-e/pin-project-lite/pull/9)
+
+## [0.1.3] - 2020-01-20
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [Support lifetime bounds in generic parameters.](https://github.com/taiki-e/pin-project-lite/pull/7)
+
+## [0.1.2] - 2020-01-05
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- Support recognizing default generic parameters. ([#6](https://github.com/taiki-e/pin-project-lite/pull/6), thanks @kennytm)
+
+## [0.1.1] - 2019-11-15
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+- [`pin_project!` macro now determines the visibility of the projection type/method is based on the original type.](https://github.com/taiki-e/pin-project-lite/pull/5)
+
+## [0.1.0] - 2019-10-22
+
+**Note:** This release has been yanked. See [#55](https://github.com/taiki-e/pin-project-lite/pull/55) for details.
+
+Initial release
+
+[Unreleased]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.9...HEAD
+[0.2.9]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.8...v0.2.9
+[0.2.8]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.7...v0.2.8
+[0.2.7]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.6...v0.2.7
+[0.2.6]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.5...v0.2.6
+[0.2.5]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.4...v0.2.5
+[0.2.4]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.3...v0.2.4
+[0.2.3]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.2...v0.2.3
+[0.2.2]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.1...v0.2.2
+[0.2.1]: https://github.com/taiki-e/pin-project-lite/compare/v0.2.0...v0.2.1
+[0.2.0]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.11...v0.2.0
+[0.1.12]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.11...v0.1.12
+[0.1.11]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.10...v0.1.11
+[0.1.10]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.9...v0.1.10
+[0.1.9]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.8...v0.1.9
+[0.1.8]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.7...v0.1.8
+[0.1.7]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.6...v0.1.7
+[0.1.6]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.5...v0.1.6
+[0.1.5]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.4...v0.1.5
+[0.1.4]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.3...v0.1.4
+[0.1.3]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.2...v0.1.3
+[0.1.2]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.1...v0.1.2
+[0.1.1]: https://github.com/taiki-e/pin-project-lite/compare/v0.1.0...v0.1.1
+[0.1.0]: https://github.com/taiki-e/pin-project-lite/releases/tag/v0.1.0
diff --git a/third_party/rust/pin-project-lite/Cargo.toml b/third_party/rust/pin-project-lite/Cargo.toml
new file mode 100644
index 0000000000..8a9436d877
--- /dev/null
+++ b/third_party/rust/pin-project-lite/Cargo.toml
@@ -0,0 +1,45 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+rust-version = "1.37"
+name = "pin-project-lite"
+version = "0.2.9"
+exclude = [
+ "/.*",
+ "/tools",
+]
+description = """
+A lightweight version of pin-project written with declarative macros.
+"""
+keywords = [
+ "pin",
+ "macros",
+]
+categories = [
+ "no-std",
+ "rust-patterns",
+]
+license = "Apache-2.0 OR MIT"
+repository = "https://github.com/taiki-e/pin-project-lite"
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]
+
+[dev-dependencies.rustversion]
+version = "1"
+
+[dev-dependencies.static_assertions]
+version = "1"
+
+[dev-dependencies.trybuild]
+version = "1.0.49"
diff --git a/third_party/rust/pin-project-lite/LICENSE-APACHE b/third_party/rust/pin-project-lite/LICENSE-APACHE
new file mode 100644
index 0000000000..f433b1a53f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/LICENSE-APACHE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/third_party/rust/pin-project-lite/LICENSE-MIT b/third_party/rust/pin-project-lite/LICENSE-MIT
new file mode 100644
index 0000000000..31aa79387f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/LICENSE-MIT
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/third_party/rust/pin-project-lite/README.md b/third_party/rust/pin-project-lite/README.md
new file mode 100644
index 0000000000..78adb7e364
--- /dev/null
+++ b/third_party/rust/pin-project-lite/README.md
@@ -0,0 +1,125 @@
+# pin-project-lite
+
+[![crates.io](https://img.shields.io/crates/v/pin-project-lite?style=flat-square&logo=rust)](https://crates.io/crates/pin-project-lite)
+[![docs.rs](https://img.shields.io/badge/docs.rs-pin--project--lite-blue?style=flat-square)](https://docs.rs/pin-project-lite)
+[![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)](#license)
+[![rustc](https://img.shields.io/badge/rustc-1.37+-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)
+[![build status](https://img.shields.io/github/workflow/status/taiki-e/pin-project-lite/CI/main?style=flat-square&logo=github)](https://github.com/taiki-e/pin-project-lite/actions)
+
+A lightweight version of [pin-project] written with declarative macros.
+
+## Usage
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+pin-project-lite = "0.2"
+```
+
+*Compiler support: requires rustc 1.37+*
+
+## Examples
+
+[`pin_project!`] macro creates a projection type covering all the fields of
+struct.
+
+```rust
+use std::pin::Pin;
+
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+impl<T, U> Struct<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ let this = self.project();
+ let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+ let _: &mut U = this.unpinned; // Normal reference to the field
+ }
+}
+```
+
+To use [`pin_project!`] on enums, you need to name the projection type
+returned from the method.
+
+```rust
+use std::pin::Pin;
+
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ enum Enum<T, U> {
+ Variant { #[pin] pinned: T, unpinned: U },
+ }
+}
+
+impl<T, U> Enum<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ match self.project() {
+ EnumProj::Variant { pinned, unpinned } => {
+ let _: Pin<&mut T> = pinned;
+ let _: &mut U = unpinned;
+ }
+ }
+ }
+}
+```
+
+## [pin-project] vs pin-project-lite
+
+Here are some similarities and differences compared to [pin-project].
+
+### Similar: Safety
+
+pin-project-lite guarantees safety in much the same way as [pin-project].
+Both are completely safe unless you write other unsafe code.
+
+### Different: Minimal design
+
+This library does not tackle as expansive of a range of use cases as
+[pin-project] does. If your use case is not already covered, please use
+[pin-project].
+
+### Different: No proc-macro related dependencies
+
+This is the **only** reason to use this crate. However, **if you already
+have proc-macro related dependencies in your crate's dependency graph, there
+is no benefit from using this crate.** (Note: There is almost no difference
+in the amount of code generated between [pin-project] and pin-project-lite.)
+
+### Different: No useful error messages
+
+This macro does not handle any invalid input. So error messages are not to
+be useful in most cases. If you do need useful error messages, then upon
+error you can pass the same input to [pin-project] to receive a helpful
+description of the compile error.
+
+### Different: No support for custom Unpin implementation
+
+pin-project supports this by [`UnsafeUnpin`][unsafe-unpin] and [`!Unpin`][not-unpin].
+
+### Different: No support for tuple structs and tuple variants
+
+pin-project supports this.
+
+[`pin_project!`]: https://docs.rs/pin-project-lite/0.2/pin_project_lite/macro.pin_project.html
+[not-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin
+[pin-project]: https://github.com/taiki-e/pin-project
+[unsafe-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unsafeunpin
+
+## License
+
+Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
+[MIT license](LICENSE-MIT) at your option.
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall
+be dual licensed as above, without any additional terms or conditions.
diff --git a/third_party/rust/pin-project-lite/src/lib.rs b/third_party/rust/pin-project-lite/src/lib.rs
new file mode 100644
index 0000000000..f5ecc990d6
--- /dev/null
+++ b/third_party/rust/pin-project-lite/src/lib.rs
@@ -0,0 +1,1559 @@
+//! A lightweight version of [pin-project] written with declarative macros.
+//!
+//! # Examples
+//!
+//! [`pin_project!`] macro creates a projection type covering all the fields of struct.
+//!
+//! ```rust
+//! use std::pin::Pin;
+//!
+//! use pin_project_lite::pin_project;
+//!
+//! pin_project! {
+//! struct Struct<T, U> {
+//! #[pin]
+//! pinned: T,
+//! unpinned: U,
+//! }
+//! }
+//!
+//! impl<T, U> Struct<T, U> {
+//! fn method(self: Pin<&mut Self>) {
+//! let this = self.project();
+//! let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+//! let _: &mut U = this.unpinned; // Normal reference to the field
+//! }
+//! }
+//! ```
+//!
+//! To use [`pin_project!`] on enums, you need to name the projection type
+//! returned from the method.
+//!
+//! ```rust
+//! use std::pin::Pin;
+//!
+//! use pin_project_lite::pin_project;
+//!
+//! pin_project! {
+//! #[project = EnumProj]
+//! enum Enum<T, U> {
+//! Variant { #[pin] pinned: T, unpinned: U },
+//! }
+//! }
+//!
+//! impl<T, U> Enum<T, U> {
+//! fn method(self: Pin<&mut Self>) {
+//! match self.project() {
+//! EnumProj::Variant { pinned, unpinned } => {
+//! let _: Pin<&mut T> = pinned;
+//! let _: &mut U = unpinned;
+//! }
+//! }
+//! }
+//! }
+//! ```
+//!
+//! # [pin-project] vs pin-project-lite
+//!
+//! Here are some similarities and differences compared to [pin-project].
+//!
+//! ## Similar: Safety
+//!
+//! pin-project-lite guarantees safety in much the same way as [pin-project].
+//! Both are completely safe unless you write other unsafe code.
+//!
+//! ## Different: Minimal design
+//!
+//! This library does not tackle as expansive of a range of use cases as
+//! [pin-project] does. If your use case is not already covered, please use
+//! [pin-project].
+//!
+//! ## Different: No proc-macro related dependencies
+//!
+//! This is the **only** reason to use this crate. However, **if you already
+//! have proc-macro related dependencies in your crate's dependency graph, there
+//! is no benefit from using this crate.** (Note: There is almost no difference
+//! in the amount of code generated between [pin-project] and pin-project-lite.)
+//!
+//! ## Different: No useful error messages
+//!
+//! This macro does not handle any invalid input. So error messages are not to
+//! be useful in most cases. If you do need useful error messages, then upon
+//! error you can pass the same input to [pin-project] to receive a helpful
+//! description of the compile error.
+//!
+//! ## Different: No support for custom Unpin implementation
+//!
+//! pin-project supports this by [`UnsafeUnpin`][unsafe-unpin] and [`!Unpin`][not-unpin].
+//!
+//! ## Different: No support for tuple structs and tuple variants
+//!
+//! pin-project supports this.
+//!
+//! [not-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin
+//! [pin-project]: https://github.com/taiki-e/pin-project
+//! [unsafe-unpin]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unsafeunpin
+
+#![no_std]
+#![doc(test(
+ no_crate_inject,
+ attr(
+ deny(warnings, rust_2018_idioms, single_use_lifetimes),
+ allow(dead_code, unused_variables)
+ )
+))]
+#![warn(rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
+#![warn(clippy::default_trait_access, clippy::wildcard_imports)]
+
+/// A macro that creates a projection type covering all the fields of struct.
+///
+/// This macro creates a projection type according to the following rules:
+///
+/// - For the field that uses `#[pin]` attribute, makes the pinned reference to the field.
+/// - For the other fields, makes the unpinned reference to the field.
+///
+/// And the following methods are implemented on the original type:
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// # type Projection<'a> = &'a ();
+/// # type ProjectionRef<'a> = &'a ();
+/// # trait Dox {
+/// fn project(self: Pin<&mut Self>) -> Projection<'_>;
+/// fn project_ref(self: Pin<&Self>) -> ProjectionRef<'_>;
+/// # }
+/// ```
+///
+/// By passing an attribute with the same name as the method to the macro,
+/// you can name the projection type returned from the method. This allows you
+/// to use pattern matching on the projected types.
+///
+/// ```rust
+/// # use pin_project_lite::pin_project;
+/// # use std::pin::Pin;
+/// pin_project! {
+/// #[project = EnumProj]
+/// enum Enum<T> {
+/// Variant { #[pin] field: T },
+/// }
+/// }
+///
+/// impl<T> Enum<T> {
+/// fn method(self: Pin<&mut Self>) {
+/// let this: EnumProj<'_, T> = self.project();
+/// match this {
+/// EnumProj::Variant { field } => {
+/// let _: Pin<&mut T> = field;
+/// }
+/// }
+/// }
+/// }
+/// ```
+///
+/// By passing the `#[project_replace = MyProjReplace]` attribute you may create an additional
+/// method which allows the contents of `Pin<&mut Self>` to be replaced while simultaneously moving
+/// out all unpinned fields in `Self`.
+///
+/// ```rust
+/// # use std::pin::Pin;
+/// # type MyProjReplace = ();
+/// # trait Dox {
+/// fn project_replace(self: Pin<&mut Self>, replacement: Self) -> MyProjReplace;
+/// # }
+/// ```
+///
+/// Also, note that the projection types returned by `project` and `project_ref` have
+/// an additional lifetime at the beginning of generics.
+///
+/// ```text
+/// let this: EnumProj<'_, T> = self.project();
+/// ^^
+/// ```
+///
+/// The visibility of the projected types and projection methods is based on the
+/// original type. However, if the visibility of the original type is `pub`, the
+/// visibility of the projected types and the projection methods is downgraded
+/// to `pub(crate)`.
+///
+/// # Safety
+///
+/// `pin_project!` macro guarantees safety in much the same way as [pin-project] crate.
+/// Both are completely safe unless you write other unsafe code.
+///
+/// See [pin-project] crate for more details.
+///
+/// # Examples
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project_lite::pin_project;
+///
+/// pin_project! {
+/// struct Struct<T, U> {
+/// #[pin]
+/// pinned: T,
+/// unpinned: U,
+/// }
+/// }
+///
+/// impl<T, U> Struct<T, U> {
+/// fn method(self: Pin<&mut Self>) {
+/// let this = self.project();
+/// let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+/// let _: &mut U = this.unpinned; // Normal reference to the field
+/// }
+/// }
+/// ```
+///
+/// To use `pin_project!` on enums, you need to name the projection type
+/// returned from the method.
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project_lite::pin_project;
+///
+/// pin_project! {
+/// #[project = EnumProj]
+/// enum Enum<T> {
+/// Struct {
+/// #[pin]
+/// field: T,
+/// },
+/// Unit,
+/// }
+/// }
+///
+/// impl<T> Enum<T> {
+/// fn method(self: Pin<&mut Self>) {
+/// match self.project() {
+/// EnumProj::Struct { field } => {
+/// let _: Pin<&mut T> = field;
+/// }
+/// EnumProj::Unit => {}
+/// }
+/// }
+/// }
+/// ```
+///
+/// If you want to call the `project()` method multiple times or later use the
+/// original [`Pin`] type, it needs to use [`.as_mut()`][`Pin::as_mut`] to avoid
+/// consuming the [`Pin`].
+///
+/// ```rust
+/// use std::pin::Pin;
+///
+/// use pin_project_lite::pin_project;
+///
+/// pin_project! {
+/// struct Struct<T> {
+/// #[pin]
+/// field: T,
+/// }
+/// }
+///
+/// impl<T> Struct<T> {
+/// fn call_project_twice(mut self: Pin<&mut Self>) {
+/// // `project` consumes `self`, so reborrow the `Pin<&mut Self>` via `as_mut`.
+/// self.as_mut().project();
+/// self.as_mut().project();
+/// }
+/// }
+/// ```
+///
+/// # `!Unpin`
+///
+/// If you want to ensure that [`Unpin`] is not implemented, use `#[pin]`
+/// attribute for a [`PhantomPinned`] field.
+///
+/// ```rust
+/// use std::marker::PhantomPinned;
+///
+/// use pin_project_lite::pin_project;
+///
+/// pin_project! {
+/// struct Struct<T> {
+/// field: T,
+/// #[pin] // <------ This `#[pin]` is required to make `Struct` to `!Unpin`.
+/// _pin: PhantomPinned,
+/// }
+/// }
+/// ```
+///
+/// Note that using [`PhantomPinned`] without `#[pin]` attribute has no effect.
+///
+/// [`PhantomPinned`]: core::marker::PhantomPinned
+/// [`Pin::as_mut`]: core::pin::Pin::as_mut
+/// [`Pin`]: core::pin::Pin
+/// [pin-project]: https://github.com/taiki-e/pin-project
+#[macro_export]
+macro_rules! pin_project {
+ ($($tt:tt)*) => {
+ $crate::__pin_project_internal! {
+ [][][][]
+ $($tt)*
+ }
+ };
+}
+
+// limitations:
+// - no support for tuple structs and tuple variant (wontfix).
+// - no support for multiple trait/lifetime bounds.
+// - no support for `Self` in where clauses. (wontfix)
+// - no support for overlapping lifetime names. (wontfix)
+// - no interoperability with other field attributes.
+// - no useful error messages. (wontfix)
+// etc...
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_expand {
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$proj_vis:vis]
+ [$(#[$attrs:meta])* $vis:vis $struct_ty_ident:ident $ident:ident]
+ [$($def_generics:tt)*]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $($body_data:tt)*
+ }
+ $(impl $($pinned_drop:tt)*)?
+ ) => {
+ $crate::__pin_project_reconstruct! {
+ [$(#[$attrs])* $vis $struct_ty_ident $ident]
+ [$($def_generics)*] [$($impl_generics)*]
+ [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $($body_data)*
+ }
+ }
+
+ $crate::__pin_project_make_proj_ty! {
+ [$($proj_mut_ident)?]
+ [$proj_vis $struct_ty_ident $ident]
+ [__pin_project_make_proj_field_mut]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $($body_data)*
+ }
+ }
+ $crate::__pin_project_make_proj_ty! {
+ [$($proj_ref_ident)?]
+ [$proj_vis $struct_ty_ident $ident]
+ [__pin_project_make_proj_field_ref]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $($body_data)*
+ }
+ }
+ $crate::__pin_project_make_proj_replace_ty! {
+ [$($proj_replace_ident)?]
+ [$proj_vis $struct_ty_ident]
+ [__pin_project_make_proj_field_replace]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $($body_data)*
+ }
+ }
+
+ $crate::__pin_project_constant! {
+ [$(#[$attrs])* $vis $struct_ty_ident $ident]
+ [$($proj_mut_ident)?] [$($proj_ref_ident)?] [$($proj_replace_ident)?]
+ [$proj_vis]
+ [$($def_generics)*] [$($impl_generics)*]
+ [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $($body_data)*
+ }
+ $(impl $($pinned_drop)*)?
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_constant {
+ (
+ [$(#[$attrs:meta])* $vis:vis struct $ident:ident]
+ [$($proj_mut_ident:ident)?] [$($proj_ref_ident:ident)?] [$($proj_replace_ident:ident)?]
+ [$proj_vis:vis]
+ [$($def_generics:tt)*]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident: $field_ty:ty
+ ),+ $(,)?
+ }
+ $(impl $($pinned_drop:tt)*)?
+ ) => {
+ #[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
+ #[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
+ // This lint warns of `clippy::*` generated by external macros.
+ // We allow this lint for compatibility with older compilers.
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
+ #[allow(clippy::used_underscore_binding)]
+ const _: () = {
+ $crate::__pin_project_make_proj_ty! {
+ [$($proj_mut_ident)? Projection]
+ [$proj_vis struct $ident]
+ [__pin_project_make_proj_field_mut]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $(
+ $(#[$pin])?
+ $field_vis $field: $field_ty
+ ),+
+ }
+ }
+ $crate::__pin_project_make_proj_ty! {
+ [$($proj_ref_ident)? ProjectionRef]
+ [$proj_vis struct $ident]
+ [__pin_project_make_proj_field_ref]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ {
+ $(
+ $(#[$pin])?
+ $field_vis $field: $field_ty
+ ),+
+ }
+ }
+
+ impl <$($impl_generics)*> $ident <$($ty_generics)*>
+ $(where
+ $($where_clause)*)?
+ {
+ $crate::__pin_project_struct_make_proj_method! {
+ [$($proj_mut_ident)? Projection]
+ [$proj_vis]
+ [project get_unchecked_mut mut]
+ [$($ty_generics)*]
+ {
+ $(
+ $(#[$pin])?
+ $field_vis $field
+ ),+
+ }
+ }
+ $crate::__pin_project_struct_make_proj_method! {
+ [$($proj_ref_ident)? ProjectionRef]
+ [$proj_vis]
+ [project_ref get_ref]
+ [$($ty_generics)*]
+ {
+ $(
+ $(#[$pin])?
+ $field_vis $field
+ ),+
+ }
+ }
+ $crate::__pin_project_struct_make_proj_replace_method! {
+ [$($proj_replace_ident)?]
+ [$proj_vis]
+ [ProjectionReplace]
+ [$($ty_generics)*]
+ {
+ $(
+ $(#[$pin])?
+ $field_vis $field
+ ),+
+ }
+ }
+ }
+
+ $crate::__pin_project_make_unpin_impl! {
+ [$vis $ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ $(
+ $field: $crate::__pin_project_make_unpin_bound!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ }
+
+ $crate::__pin_project_make_drop_impl! {
+ [$ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ $(impl $($pinned_drop)*)?
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)] struct.
+ //
+ // Taking a reference to a packed field is UB, and applying
+ // `#[forbid(unaligned_references)]` makes sure that doing this is a hard error.
+ //
+ // If the struct ends up having #[repr(packed)] applied somehow,
+ // this will generate an (unfriendly) error message. Under all reasonable
+ // circumstances, we'll detect the #[repr(packed)] attribute, and generate
+ // a much nicer error above.
+ //
+ // See https://github.com/taiki-e/pin-project/pull/34 for more details.
+ //
+ // Note:
+ // - Lint-based tricks aren't perfect, but they're much better than nothing:
+ // https://github.com/taiki-e/pin-project-lite/issues/26
+ //
+ // - Enable both unaligned_references and safe_packed_borrows lints
+ // because unaligned_references lint does not exist in older compilers:
+ // https://github.com/taiki-e/pin-project-lite/pull/55
+ // https://github.com/rust-lang/rust/pull/82525
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed <$($impl_generics)*> (this: &$ident <$($ty_generics)*>)
+ $(where
+ $($where_clause)*)?
+ {
+ $(
+ let _ = &this.$field;
+ )+
+ }
+ };
+ };
+ (
+ [$(#[$attrs:meta])* $vis:vis enum $ident:ident]
+ [$($proj_mut_ident:ident)?] [$($proj_ref_ident:ident)?] [$($proj_replace_ident:ident)?]
+ [$proj_vis:vis]
+ [$($def_generics:tt)*]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$variant_attrs:meta])*
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident: $field_ty:ty
+ ),+ $(,)?
+ })?
+ ),+ $(,)?
+ }
+ $(impl $($pinned_drop:tt)*)?
+ ) => {
+ #[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
+ // This lint warns of `clippy::*` generated by external macros.
+ // We allow this lint for compatibility with older compilers.
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::used_underscore_binding)]
+ const _: () = {
+ impl <$($impl_generics)*> $ident <$($ty_generics)*>
+ $(where
+ $($where_clause)*)?
+ {
+ $crate::__pin_project_enum_make_proj_method! {
+ [$($proj_mut_ident)?]
+ [$proj_vis]
+ [project get_unchecked_mut mut]
+ [$($ty_generics)*]
+ {
+ $(
+ $variant $({
+ $(
+ $(#[$pin])?
+ $field
+ ),+
+ })?
+ ),+
+ }
+ }
+ $crate::__pin_project_enum_make_proj_method! {
+ [$($proj_ref_ident)?]
+ [$proj_vis]
+ [project_ref get_ref]
+ [$($ty_generics)*]
+ {
+ $(
+ $variant $({
+ $(
+ $(#[$pin])?
+ $field
+ ),+
+ })?
+ ),+
+ }
+ }
+ $crate::__pin_project_enum_make_proj_replace_method! {
+ [$($proj_replace_ident)?]
+ [$proj_vis]
+ [$($ty_generics)*]
+ {
+ $(
+ $variant $({
+ $(
+ $(#[$pin])?
+ $field
+ ),+
+ })?
+ ),+
+ }
+ }
+ }
+
+ $crate::__pin_project_make_unpin_impl! {
+ [$vis $ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ $(
+ $variant: ($(
+ $(
+ $crate::__pin_project_make_unpin_bound!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ )?)
+ ),+
+ }
+
+ $crate::__pin_project_make_drop_impl! {
+ [$ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ $(impl $($pinned_drop)*)?
+ }
+
+ // We don't need to check for '#[repr(packed)]',
+ // since it does not apply to enums.
+ };
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_reconstruct {
+ (
+ [$(#[$attrs:meta])* $vis:vis struct $ident:ident]
+ [$($def_generics:tt)*] [$($impl_generics:tt)*]
+ [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident: $field_ty:ty
+ ),+ $(,)?
+ }
+ ) => {
+ $(#[$attrs])*
+ $vis struct $ident $($def_generics)*
+ $(where
+ $($where_clause)*)?
+ {
+ $(
+ $field_vis $field: $field_ty
+ ),+
+ }
+ };
+ (
+ [$(#[$attrs:meta])* $vis:vis enum $ident:ident]
+ [$($def_generics:tt)*] [$($impl_generics:tt)*]
+ [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$variant_attrs:meta])*
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident: $field_ty:ty
+ ),+ $(,)?
+ })?
+ ),+ $(,)?
+ }
+ ) => {
+ $(#[$attrs])*
+ $vis enum $ident $($def_generics)*
+ $(where
+ $($where_clause)*)?
+ {
+ $(
+ $(#[$variant_attrs])*
+ $variant $({
+ $(
+ $field: $field_ty
+ ),+
+ })?
+ ),+
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_ty {
+ ([] $($field:tt)*) => {};
+ (
+ [$proj_ty_ident:ident $default_ident:ident]
+ [$proj_vis:vis struct $ident:ident]
+ $($field:tt)*
+ ) => {};
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis struct $ident:ident]
+ [$__pin_project_make_proj_field:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident: $field_ty:ty
+ ),+ $(,)?
+ }
+ ) => {
+ $crate::__pin_project_make_proj_ty_body! {
+ [$proj_ty_ident]
+ [$proj_vis struct $ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ [
+ $(
+ $field_vis $field: $crate::$__pin_project_make_proj_field!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ ]
+ }
+ };
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis enum $ident:ident]
+ [$__pin_project_make_proj_field:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$variant_attrs:meta])*
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident: $field_ty:ty
+ ),+ $(,)?
+ })?
+ ),+ $(,)?
+ }
+ ) => {
+ $crate::__pin_project_make_proj_ty_body! {
+ [$proj_ty_ident]
+ [$proj_vis enum $ident]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ [
+ $(
+ $variant $({
+ $(
+ $field: $crate::$__pin_project_make_proj_field!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ })?
+ ),+
+ ]
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_ty_body {
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis $struct_ty_ident:ident $ident:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ [$($body_data:tt)+]
+ ) => {
+ #[allow(dead_code)] // This lint warns unused fields/variants.
+ #[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
+ // This lint warns of `clippy::*` generated by external macros.
+ // We allow this lint for compatibility with older compilers.
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
+ #[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
+ #[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`. (only needed for project_ref)
+ #[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
+ $proj_vis $struct_ty_ident $proj_ty_ident <'__pin, $($impl_generics)*>
+ where
+ $ident <$($ty_generics)*>: '__pin
+ $(, $($where_clause)*)?
+ {
+ $($body_data)+
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_replace_ty {
+ ([] $($field:tt)*) => {};
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis struct]
+ [$__pin_project_make_proj_field:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident: $field_ty:ty
+ ),+ $(,)?
+ }
+ ) => {
+ $crate::__pin_project_make_proj_replace_ty_body! {
+ [$proj_ty_ident]
+ [$proj_vis struct]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ [
+ $(
+ $field_vis $field: $crate::$__pin_project_make_proj_field!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ ]
+ }
+ };
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis enum]
+ [$__pin_project_make_proj_field:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ {
+ $(
+ $(#[$variant_attrs:meta])*
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident: $field_ty:ty
+ ),+ $(,)?
+ })?
+ ),+ $(,)?
+ }
+ ) => {
+ $crate::__pin_project_make_proj_replace_ty_body! {
+ [$proj_ty_ident]
+ [$proj_vis enum]
+ [$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
+ [
+ $(
+ $variant $({
+ $(
+ $field: $crate::$__pin_project_make_proj_field!(
+ $(#[$pin])? $field_ty
+ )
+ ),+
+ })?
+ ),+
+ ]
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_replace_ty_body {
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis $struct_ty_ident:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ [$($body_data:tt)+]
+ ) => {
+ #[allow(dead_code)] // This lint warns unused fields/variants.
+ #[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
+ #[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
+ #[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
+ #[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
+ $proj_vis $struct_ty_ident $proj_ty_ident <$($impl_generics)*>
+ where
+ $($($where_clause)*)?
+ {
+ $($body_data)+
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_replace_block {
+ (
+ [$($proj_path:tt)+]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident
+ ),+
+ }
+ ) => {
+ let result = $($proj_path)* {
+ $(
+ $field: $crate::__pin_project_make_replace_field_proj!(
+ $(#[$pin])? $field
+ )
+ ),+
+ };
+
+ {
+ ( $(
+ $crate::__pin_project_make_unsafe_drop_in_place_guard!(
+ $(#[$pin])? $field
+ ),
+ )* );
+ }
+
+ result
+ };
+ ([$($proj_path:tt)+]) => { $($proj_path)* };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_struct_make_proj_method {
+ ([] $($variant:tt)*) => {};
+ (
+ [$proj_ty_ident:ident $_ignored_default_arg:ident]
+ [$proj_vis:vis]
+ [$method_ident:ident $get_method:ident $($mut:ident)?]
+ [$($ty_generics:tt)*]
+ $($variant:tt)*
+ ) => {
+ $crate::__pin_project_struct_make_proj_method! {
+ [$proj_ty_ident]
+ [$proj_vis]
+ [$method_ident $get_method $($mut)?]
+ [$($ty_generics)*]
+ $($variant)*
+ }
+ };
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis]
+ [$method_ident:ident $get_method:ident $($mut:ident)?]
+ [$($ty_generics:tt)*]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident
+ ),+
+ }
+ ) => {
+ $proj_vis fn $method_ident<'__pin>(
+ self: $crate::__private::Pin<&'__pin $($mut)? Self>,
+ ) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
+ unsafe {
+ let Self { $($field),* } = self.$get_method();
+ $proj_ty_ident {
+ $(
+ $field: $crate::__pin_project_make_unsafe_field_proj!(
+ $(#[$pin])? $field
+ )
+ ),+
+ }
+ }
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_struct_make_proj_replace_method {
+ ([] $($field:tt)*) => {};
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis]
+ [$_proj_ty_ident:ident]
+ [$($ty_generics:tt)*]
+ {
+ $(
+ $(#[$pin:ident])?
+ $field_vis:vis $field:ident
+ ),+
+ }
+ ) => {
+ $proj_vis fn project_replace(
+ self: $crate::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> $proj_ty_ident <$($ty_generics)*> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+
+ // Destructors will run in reverse order, so next create a guard to overwrite
+ // `self` with the replacement value without calling destructors.
+ let __guard = $crate::__private::UnsafeOverwriteGuard::new(__self_ptr, replacement);
+
+ let Self { $($field),* } = &mut *__self_ptr;
+
+ $crate::__pin_project_make_proj_replace_block! {
+ [$proj_ty_ident]
+ {
+ $(
+ $(#[$pin])?
+ $field
+ ),+
+ }
+ }
+ }
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_enum_make_proj_method {
+ ([] $($variant:tt)*) => {};
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis]
+ [$method_ident:ident $get_method:ident $($mut:ident)?]
+ [$($ty_generics:tt)*]
+ {
+ $(
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident
+ ),+
+ })?
+ ),+
+ }
+ ) => {
+ $proj_vis fn $method_ident<'__pin>(
+ self: $crate::__private::Pin<&'__pin $($mut)? Self>,
+ ) -> $proj_ty_ident <'__pin, $($ty_generics)*> {
+ unsafe {
+ match self.$get_method() {
+ $(
+ Self::$variant $({
+ $($field),+
+ })? => {
+ $proj_ty_ident::$variant $({
+ $(
+ $field: $crate::__pin_project_make_unsafe_field_proj!(
+ $(#[$pin])? $field
+ )
+ ),+
+ })?
+ }
+ ),+
+ }
+ }
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_enum_make_proj_replace_method {
+ ([] $($field:tt)*) => {};
+ (
+ [$proj_ty_ident:ident]
+ [$proj_vis:vis]
+ [$($ty_generics:tt)*]
+ {
+ $(
+ $variant:ident $({
+ $(
+ $(#[$pin:ident])?
+ $field:ident
+ ),+
+ })?
+ ),+
+ }
+ ) => {
+ $proj_vis fn project_replace(
+ self: $crate::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> $proj_ty_ident <$($ty_generics)*> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+
+ // Destructors will run in reverse order, so next create a guard to overwrite
+ // `self` with the replacement value without calling destructors.
+ let __guard = $crate::__private::UnsafeOverwriteGuard::new(__self_ptr, replacement);
+
+ match &mut *__self_ptr {
+ $(
+ Self::$variant $({
+ $($field),+
+ })? => {
+ $crate::__pin_project_make_proj_replace_block! {
+ [$proj_ty_ident :: $variant]
+ $({
+ $(
+ $(#[$pin])?
+ $field
+ ),+
+ })?
+ }
+ }
+ ),+
+ }
+ }
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_unpin_impl {
+ (
+ [$vis:vis $ident:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ $($field:tt)*
+ ) => {
+ // Automatically create the appropriate conditional `Unpin` implementation.
+ //
+ // Basically this is equivalent to the following code:
+ // ```rust
+ // impl<T, U> Unpin for Struct<T, U> where T: Unpin {}
+ // ```
+ //
+ // However, if struct is public and there is a private type field,
+ // this would cause an E0446 (private type in public interface).
+ //
+ // When RFC 2145 is implemented (rust-lang/rust#48054),
+ // this will become a lint, rather then a hard error.
+ //
+ // As a workaround for this, we generate a new struct, containing all of the pinned
+ // fields from our #[pin_project] type. This struct is declared within
+ // a function, which makes it impossible to be named by user code.
+ // This guarantees that it will use the default auto-trait impl for Unpin -
+ // that is, it will implement Unpin iff all of its fields implement Unpin.
+ // This type can be safely declared as 'public', satisfying the privacy
+ // checker without actually allowing user code to access it.
+ //
+ // This allows users to apply the #[pin_project] attribute to types
+ // regardless of the privacy of the types of their fields.
+ //
+ // See also https://github.com/taiki-e/pin-project/pull/53.
+ #[allow(non_snake_case)]
+ $vis struct __Origin <'__pin, $($impl_generics)*>
+ $(where
+ $($where_clause)*)?
+ {
+ __dummy_lifetime: $crate::__private::PhantomData<&'__pin ()>,
+ $($field)*
+ }
+ impl <'__pin, $($impl_generics)*> $crate::__private::Unpin for $ident <$($ty_generics)*>
+ where
+ __Origin <'__pin, $($ty_generics)*>: $crate::__private::Unpin
+ $(, $($where_clause)*)?
+ {
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_drop_impl {
+ (
+ [$_ident:ident]
+ [$($_impl_generics:tt)*] [$($_ty_generics:tt)*] [$(where $($_where_clause:tt)*)?]
+ impl $(<
+ $( $lifetime:lifetime $(: $lifetime_bound:lifetime)? ),* $(,)?
+ $( $generics:ident
+ $(: $generics_bound:path)?
+ $(: ?$generics_unsized_bound:path)?
+ $(: $generics_lifetime_bound:lifetime)?
+ ),*
+ >)? PinnedDrop for $self_ty:ty
+ $(where
+ $( $where_clause_ty:ty
+ $(: $where_clause_bound:path)?
+ $(: ?$where_clause_unsized_bound:path)?
+ $(: $where_clause_lifetime_bound:lifetime)?
+ ),* $(,)?
+ )?
+ {
+ fn drop($($arg:ident)+: Pin<&mut Self>) {
+ $($tt:tt)*
+ }
+ }
+ ) => {
+ impl $(<
+ $( $lifetime $(: $lifetime_bound)? ,)*
+ $( $generics
+ $(: $generics_bound)?
+ $(: ?$generics_unsized_bound)?
+ $(: $generics_lifetime_bound)?
+ ),*
+ >)? $crate::__private::Drop for $self_ty
+ $(where
+ $( $where_clause_ty
+ $(: $where_clause_bound)?
+ $(: ?$where_clause_unsized_bound)?
+ $(: $where_clause_lifetime_bound)?
+ ),*
+ )?
+ {
+ fn drop(&mut self) {
+ // Implementing `__DropInner::__drop_inner` is safe, but calling it is not safe.
+ // This is because destructors can be called multiple times in safe code and
+ // [double dropping is unsound](https://github.com/rust-lang/rust/pull/62360).
+ //
+ // `__drop_inner` is defined as a safe method, but this is fine since
+ // `__drop_inner` is not accessible by the users and we call `__drop_inner` only
+ // once.
+ //
+ // Users can implement [`Drop`] safely using `pin_project!` and can drop a
+ // type that implements `PinnedDrop` using the [`drop`] function safely.
+ fn __drop_inner $(<
+ $( $lifetime $(: $lifetime_bound)? ,)*
+ $( $generics
+ $(: $generics_bound)?
+ $(: ?$generics_unsized_bound)?
+ $(: $generics_lifetime_bound)?
+ ),*
+ >)? (
+ $($arg)+: $crate::__private::Pin<&mut $self_ty>,
+ )
+ $(where
+ $( $where_clause_ty
+ $(: $where_clause_bound)?
+ $(: ?$where_clause_unsized_bound)?
+ $(: $where_clause_lifetime_bound)?
+ ),*
+ )?
+ {
+ // A dummy `__drop_inner` function to prevent users call outer `__drop_inner`.
+ fn __drop_inner() {}
+ $($tt)*
+ }
+
+ // Safety - we're in 'drop', so we know that 'self' will
+ // never move again.
+ let pinned_self: $crate::__private::Pin<&mut Self>
+ = unsafe { $crate::__private::Pin::new_unchecked(self) };
+ // We call `__drop_inner` only once. Since `__DropInner::__drop_inner`
+ // is not accessible by the users, it is never called again.
+ __drop_inner(pinned_self);
+ }
+ }
+ };
+ (
+ [$ident:ident]
+ [$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
+ ) => {
+ // Ensure that struct does not implement `Drop`.
+ //
+ // There are two possible cases:
+ // 1. The user type does not implement Drop. In this case,
+ // the first blanked impl will not apply to it. This code
+ // will compile, as there is only one impl of MustNotImplDrop for the user type
+ // 2. The user type does impl Drop. This will make the blanket impl applicable,
+ // which will then conflict with the explicit MustNotImplDrop impl below.
+ // This will result in a compilation error, which is exactly what we want.
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: $crate::__private::Drop> MustNotImplDrop for T {}
+ impl <$($impl_generics)*> MustNotImplDrop for $ident <$($ty_generics)*>
+ $(where
+ $($where_clause)*)?
+ {
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_unpin_bound {
+ (#[pin] $field_ty:ty) => {
+ $field_ty
+ };
+ ($field_ty:ty) => {
+ $crate::__private::AlwaysUnpin<$field_ty>
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_unsafe_field_proj {
+ (#[pin] $field:ident) => {
+ $crate::__private::Pin::new_unchecked($field)
+ };
+ ($field:ident) => {
+ $field
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_replace_field_proj {
+ (#[pin] $field:ident) => {
+ $crate::__private::PhantomData
+ };
+ ($field:ident) => {
+ $crate::__private::ptr::read($field)
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_unsafe_drop_in_place_guard {
+ (#[pin] $field:ident) => {
+ $crate::__private::UnsafeDropInPlaceGuard::new($field)
+ };
+ ($field:ident) => {
+ ()
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_field_mut {
+ (#[pin] $field_ty:ty) => {
+ $crate::__private::Pin<&'__pin mut ($field_ty)>
+ };
+ ($field_ty:ty) => {
+ &'__pin mut ($field_ty)
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_field_ref {
+ (#[pin] $field_ty:ty) => {
+ $crate::__private::Pin<&'__pin ($field_ty)>
+ };
+ ($field_ty:ty) => {
+ &'__pin ($field_ty)
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_make_proj_field_replace {
+ (#[pin] $field_ty:ty) => {
+ $crate::__private::PhantomData<$field_ty>
+ };
+ ($field_ty:ty) => {
+ $field_ty
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_internal {
+ // parsing proj_mut_ident
+ (
+ []
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+
+ #[project = $proj_mut_ident:ident]
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_internal! {
+ [$proj_mut_ident]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [$($attrs)*]
+ $($tt)*
+ }
+ };
+ // parsing proj_ref_ident
+ (
+ [$($proj_mut_ident:ident)?]
+ []
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+
+ #[project_ref = $proj_ref_ident:ident]
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_internal! {
+ [$($proj_mut_ident)?]
+ [$proj_ref_ident]
+ [$($proj_replace_ident)?]
+ [$($attrs)*]
+ $($tt)*
+ }
+ };
+ // parsing proj_replace_ident
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ []
+ [$($attrs:tt)*]
+
+ #[project_replace = $proj_replace_ident:ident]
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_internal! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$proj_replace_ident]
+ [$($attrs)*]
+ $($tt)*
+ }
+ };
+ // this is actually part of a recursive step that picks off a single non-`pin_project_lite` attribute
+ // there could be more to parse
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+
+ #[$($attr:tt)*]
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_internal! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [$($attrs)* #[$($attr)*]]
+ $($tt)*
+ }
+ };
+ // now determine visibility
+ // if public, downgrade
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+ pub $struct_ty_ident:ident $ident:ident
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_parse_generics! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [$($attrs)*]
+ [pub $struct_ty_ident $ident pub(crate)]
+ $($tt)*
+ }
+ };
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+ $vis:vis $struct_ty_ident:ident $ident:ident
+ $($tt:tt)*
+ ) => {
+ $crate::__pin_project_parse_generics! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [$($attrs)*]
+ [$vis $struct_ty_ident $ident $vis]
+ $($tt)*
+ }
+ };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! __pin_project_parse_generics {
+ (
+ [$($proj_mut_ident:ident)?]
+ [$($proj_ref_ident:ident)?]
+ [$($proj_replace_ident:ident)?]
+ [$($attrs:tt)*]
+ [$vis:vis $struct_ty_ident:ident $ident:ident $proj_ty_vis:vis]
+ $(<
+ $( $lifetime:lifetime $(: $lifetime_bound:lifetime)? ),* $(,)?
+ $( $generics:ident
+ $(: $generics_bound:path)?
+ $(: ?$generics_unsized_bound:path)?
+ $(: $generics_lifetime_bound:lifetime)?
+ $(= $generics_default:ty)?
+ ),* $(,)?
+ >)?
+ $(where
+ $( $where_clause_ty:ty
+ $(: $where_clause_bound:path)?
+ $(: ?$where_clause_unsized_bound:path)?
+ $(: $where_clause_lifetime_bound:lifetime)?
+ ),* $(,)?
+ )?
+ {
+ $($body_data:tt)*
+ }
+ $(impl $($pinned_drop:tt)*)?
+ ) => {
+ $crate::__pin_project_expand! {
+ [$($proj_mut_ident)?]
+ [$($proj_ref_ident)?]
+ [$($proj_replace_ident)?]
+ [$proj_ty_vis]
+ [$($attrs)* $vis $struct_ty_ident $ident]
+ [$(<
+ $( $lifetime $(: $lifetime_bound)? ,)*
+ $( $generics
+ $(: $generics_bound)?
+ $(: ?$generics_unsized_bound)?
+ $(: $generics_lifetime_bound)?
+ $(= $generics_default)?
+ ),*
+ >)?]
+ [$(
+ $( $lifetime $(: $lifetime_bound)? ,)*
+ $( $generics
+ $(: $generics_bound)?
+ $(: ?$generics_unsized_bound)?
+ $(: $generics_lifetime_bound)?
+ ),*
+ )?]
+ [$( $( $lifetime ,)* $( $generics ),* )?]
+ [$(where $( $where_clause_ty
+ $(: $where_clause_bound)?
+ $(: ?$where_clause_unsized_bound)?
+ $(: $where_clause_lifetime_bound)?
+ ),* )?]
+ {
+ $($body_data)*
+ }
+ $(impl $($pinned_drop)*)?
+ }
+ };
+}
+
+#[doc(hidden)]
+pub mod __private {
+ use core::mem::ManuallyDrop;
+ #[doc(hidden)]
+ pub use core::{
+ marker::{PhantomData, Unpin},
+ ops::Drop,
+ pin::Pin,
+ ptr,
+ };
+
+ // This is an internal helper struct used by `pin_project!`.
+ #[doc(hidden)]
+ pub struct AlwaysUnpin<T: ?Sized>(PhantomData<T>);
+
+ impl<T: ?Sized> Unpin for AlwaysUnpin<T> {}
+
+ // This is an internal helper used to ensure a value is dropped.
+ #[doc(hidden)]
+ pub struct UnsafeDropInPlaceGuard<T: ?Sized>(*mut T);
+
+ impl<T: ?Sized> UnsafeDropInPlaceGuard<T> {
+ #[doc(hidden)]
+ pub unsafe fn new(ptr: *mut T) -> Self {
+ Self(ptr)
+ }
+ }
+
+ impl<T: ?Sized> Drop for UnsafeDropInPlaceGuard<T> {
+ fn drop(&mut self) {
+ unsafe {
+ ptr::drop_in_place(self.0);
+ }
+ }
+ }
+
+ // This is an internal helper used to ensure a value is overwritten without
+ // its destructor being called.
+ #[doc(hidden)]
+ pub struct UnsafeOverwriteGuard<T> {
+ target: *mut T,
+ value: ManuallyDrop<T>,
+ }
+
+ impl<T> UnsafeOverwriteGuard<T> {
+ #[doc(hidden)]
+ pub unsafe fn new(target: *mut T, value: T) -> Self {
+ Self { target, value: ManuallyDrop::new(value) }
+ }
+ }
+
+ impl<T> Drop for UnsafeOverwriteGuard<T> {
+ fn drop(&mut self) {
+ unsafe {
+ ptr::write(self.target, ptr::read(&*self.value));
+ }
+ }
+ }
+}
diff --git a/third_party/rust/pin-project-lite/tests/README.md b/third_party/rust/pin-project-lite/tests/README.md
new file mode 100644
index 0000000000..47216165df
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/README.md
@@ -0,0 +1,46 @@
+# Tests
+
+Many of the tests in this repository are based on [pin-project's tests](https://github.com/taiki-e/pin-project/tree/HEAD/tests).
+
+To run all tests, run the following command:
+
+```sh
+cargo +nightly test --all
+```
+
+## UI tests (`ui`, `compiletest.rs`)
+
+This checks errors detected by the macro or the Rust compiler in the resulting
+expanded code.
+
+To run this test, run the following command:
+
+```sh
+cargo +nightly test --test compiletest
+```
+
+Locally, this test updates the files in the `ui` directory if there are
+changes to the generated code. If there are any changes to the files in the
+`ui` directory after running the test, please commit them.
+
+See also [`trybuild` documentation](https://docs.rs/trybuild).
+
+## Expansion tests (`expand`, `expandtest.rs`)
+
+Similar to ui tests, but instead of checking the compiler output, this checks
+the code generated by macros.
+
+See pin-project's [examples](https://github.com/taiki-e/pin-project/tree/HEAD/examples)
+for descriptions of what the generated code does, and why it needs to be generated.
+
+To run this test, run the following command:
+
+```sh
+cargo +nightly test --test expandtest
+```
+
+Locally, this test updates the files in the `expand` directory if there are
+changes to the generated code. If there are any changes to the files in the
+`expand` directory after running the test, please commit them.
+
+See also [`macrotest` documentation](https://docs.rs/macrotest).
diff --git a/third_party/rust/pin-project-lite/tests/auxiliary/mod.rs b/third_party/rust/pin-project-lite/tests/auxiliary/mod.rs
new file mode 100644
index 0000000000..1457099160
--- /dev/null
+++ b/third_party/rust/pin-project-lite/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/third_party/rust/pin-project-lite/tests/compiletest.rs b/third_party/rust/pin-project-lite/tests/compiletest.rs
new file mode 100644
index 0000000000..70d2358943
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/compiletest.rs
@@ -0,0 +1,15 @@
+#![cfg(not(miri))]
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+use std::env;
+
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+fn ui() {
+ if env::var_os("CI").is_none() {
+ env::set_var("TRYBUILD", "overwrite");
+ }
+
+ let t = trybuild::TestCases::new();
+ t.compile_fail("tests/ui/**/*.rs");
+}
diff --git a/third_party/rust/pin-project-lite/tests/drop_order.rs b/third_party/rust/pin-project-lite/tests/drop_order.rs
new file mode 100644
index 0000000000..6e5deaf154
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/drop_order.rs
@@ -0,0 +1,169 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+// Refs: https://doc.rust-lang.org/reference/destructors.html
+
+use std::{cell::Cell, panic, pin::Pin, thread};
+
+use pin_project_lite::pin_project;
+
+struct D<'a>(&'a Cell<usize>, usize);
+
+impl Drop for D<'_> {
+ fn drop(&mut self) {
+ if !thread::panicking() {
+ let old = self.0.replace(self.1);
+ assert_eq!(old, self.1 - 1);
+ }
+ }
+}
+
+pin_project! {
+#[project = StructPinnedProj]
+#[project_ref = StructPinnedProjRef]
+#[project_replace = StructPinnedProjReplace]
+struct StructPinned<'a> {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+}
+}
+
+pin_project! {
+#[project = StructUnpinnedProj]
+#[project_ref = StructUnpinnedProjRef]
+#[project_replace = StructUnpinnedProjReplace]
+struct StructUnpinned<'a> {
+ f1: D<'a>,
+ f2: D<'a>,
+}
+}
+
+pin_project! {
+#[project_replace = EnumProjReplace]
+enum Enum<'a> {
+ #[allow(dead_code)] // false positive that fixed in Rust 1.38
+ StructPinned {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+ },
+ #[allow(dead_code)] // false positive that fixed in Rust 1.38
+ StructUnpinned {
+ f1: D<'a>,
+ f2: D<'a>,
+ },
+}
+}
+
+#[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 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) });
+ }
+}
+
+// https://github.com/rust-lang/rust/issues/47949
+// https://github.com/taiki-e/pin-project/pull/194#discussion_r419098111
+#[allow(clippy::many_single_char_names)]
+#[test]
+fn project_replace_panic() {
+ pin_project! {
+ #[project_replace = SProjReplace]
+ struct S<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+ }
+
+ struct D<'a>(&'a mut bool, bool);
+ impl Drop for D<'_> {
+ fn drop(&mut self) {
+ *self.0 = true;
+ if self.1 {
+ panic!();
+ }
+ }
+ }
+
+ let (mut a, mut b, mut c, mut d) = (false, false, false, false);
+ let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
+ let mut x = S { pinned: D(&mut a, true), unpinned: D(&mut b, false) };
+ let _y = Pin::new(&mut x)
+ .project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
+ // Previous `x.pinned` was dropped and panicked when `project_replace` is
+ // called, so this is unreachable.
+ unreachable!();
+ }));
+ assert!(res.is_err());
+ assert!(a);
+ assert!(b);
+ assert!(c);
+ assert!(d);
+
+ let (mut a, mut b, mut c, mut d) = (false, false, false, false);
+ let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
+ let mut x = S { pinned: D(&mut a, false), unpinned: D(&mut b, true) };
+ {
+ let _y = Pin::new(&mut x)
+ .project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
+ // `_y` (previous `x.unpinned`) live to the end of this scope, so
+ // this is not unreachable.
+ // unreachable!();
+ }
+ unreachable!();
+ }));
+ assert!(res.is_err());
+ assert!(a);
+ assert!(b);
+ assert!(c);
+ assert!(d);
+}
diff --git a/third_party/rust/pin-project-lite/tests/expand/default/enum.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/default/enum.expanded.rs
new file mode 100644
index 0000000000..eae0aac85e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/default/enum.expanded.rs
@@ -0,0 +1,127 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjReplace<T, U> {
+ Struct {
+ pinned: ::pin_project_lite::__private::PhantomData<T>,
+ unpinned: U,
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ fn project_replace(
+ self: ::pin_project_lite::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> EnumProjReplace<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned, unpinned } => {
+ let result = EnumProjReplace::Struct {
+ pinned: ::pin_project_lite::__private::PhantomData,
+ unpinned: ::pin_project_lite::__private::ptr::read(unpinned),
+ };
+ {
+ (
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ (),
+ );
+ }
+ result
+ }
+ Self::Unit => EnumProjReplace::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/default/enum.rs b/third_party/rust/pin-project-lite/tests/expand/default/enum.rs
new file mode 100644
index 0000000000..90d6860a81
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/default/enum.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[project_replace = EnumProjReplace]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/default/struct.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/default/struct.expanded.rs
new file mode 100644
index 0000000000..8ab318cfb8
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/default/struct.expanded.rs
@@ -0,0 +1,84 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Projection {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjectionRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/default/struct.rs b/third_party/rust/pin-project-lite/tests/expand/default/struct.rs
new file mode 100644
index 0000000000..e5447c70a6
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/default/struct.rs
@@ -0,0 +1,11 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/multifields/enum.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/multifields/enum.expanded.rs
new file mode 100644
index 0000000000..fca0febcda
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/multifields/enum.expanded.rs
@@ -0,0 +1,88 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct {
+ pinned1: T,
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjReplace<T, U> {
+ Struct {
+ pinned1: ::pin_project_lite::__private::PhantomData<T>,
+ pinned2: ::pin_project_lite::__private::PhantomData<T>,
+ unpinned1: U,
+ unpinned2: U,
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project_replace(
+ self: ::pin_project_lite::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> EnumProjReplace<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct {
+ pinned1,
+ pinned2,
+ unpinned1,
+ unpinned2,
+ } => {
+ let result = EnumProjReplace::Struct {
+ pinned1: ::pin_project_lite::__private::PhantomData,
+ pinned2: ::pin_project_lite::__private::PhantomData,
+ unpinned1: ::pin_project_lite::__private::ptr::read(unpinned1),
+ unpinned2: ::pin_project_lite::__private::ptr::read(unpinned2),
+ };
+ {
+ (
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
+ (),
+ (),
+ );
+ }
+ result
+ }
+ Self::Unit => EnumProjReplace::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (
+ T,
+ T,
+ ::pin_project_lite::__private::AlwaysUnpin<U>,
+ ::pin_project_lite::__private::AlwaysUnpin<U>,
+ ),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/multifields/enum.rs b/third_party/rust/pin-project-lite/tests/expand/multifields/enum.rs
new file mode 100644
index 0000000000..c713362ad6
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/multifields/enum.rs
@@ -0,0 +1,18 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+#[project_replace = EnumProjReplace]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned1: T,
+ #[pin]
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+ },
+ Unit,
+}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/multifields/struct.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/multifields/struct.expanded.rs
new file mode 100644
index 0000000000..4320f68438
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/multifields/struct.expanded.rs
@@ -0,0 +1,152 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned1: T,
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProjReplace<T, U> {
+ pinned1: ::pin_project_lite::__private::PhantomData<T>,
+ pinned2: ::pin_project_lite::__private::PhantomData<T>,
+ unpinned1: U,
+ unpinned2: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned1: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ pinned2: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned1: &'__pin mut (U),
+ unpinned2: &'__pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned1: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ pinned2: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned1: &'__pin (U),
+ unpinned2: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self {
+ pinned1,
+ pinned2,
+ unpinned1,
+ unpinned2,
+ } = self.get_unchecked_mut();
+ Projection {
+ pinned1: ::pin_project_lite::__private::Pin::new_unchecked(pinned1),
+ pinned2: ::pin_project_lite::__private::Pin::new_unchecked(pinned2),
+ unpinned1: unpinned1,
+ unpinned2: unpinned2,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self {
+ pinned1,
+ pinned2,
+ unpinned1,
+ unpinned2,
+ } = self.get_ref();
+ ProjectionRef {
+ pinned1: ::pin_project_lite::__private::Pin::new_unchecked(pinned1),
+ pinned2: ::pin_project_lite::__private::Pin::new_unchecked(pinned2),
+ unpinned1: unpinned1,
+ unpinned2: unpinned2,
+ }
+ }
+ }
+ fn project_replace(
+ self: ::pin_project_lite::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> StructProjReplace<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
+ let Self {
+ pinned1,
+ pinned2,
+ unpinned1,
+ unpinned2,
+ } = &mut *__self_ptr;
+ let result = StructProjReplace {
+ pinned1: ::pin_project_lite::__private::PhantomData,
+ pinned2: ::pin_project_lite::__private::PhantomData,
+ unpinned1: ::pin_project_lite::__private::ptr::read(unpinned1),
+ unpinned2: ::pin_project_lite::__private::ptr::read(unpinned2),
+ };
+ {
+ (
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
+ (),
+ (),
+ );
+ }
+ result
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned1: T,
+ pinned2: T,
+ unpinned1: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ unpinned2: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned1;
+ let _ = &this.pinned2;
+ let _ = &this.unpinned1;
+ let _ = &this.unpinned2;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/multifields/struct.rs b/third_party/rust/pin-project-lite/tests/expand/multifields/struct.rs
new file mode 100644
index 0000000000..a1d45d168e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/multifields/struct.rs
@@ -0,0 +1,15 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+#[project_replace = StructProjReplace]
+struct Struct<T, U> {
+ #[pin]
+ pinned1: T,
+ #[pin]
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.expanded.rs
new file mode 100644
index 0000000000..eae0aac85e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.expanded.rs
@@ -0,0 +1,127 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjReplace<T, U> {
+ Struct {
+ pinned: ::pin_project_lite::__private::PhantomData<T>,
+ unpinned: U,
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ fn project_replace(
+ self: ::pin_project_lite::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> EnumProjReplace<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned, unpinned } => {
+ let result = EnumProjReplace::Struct {
+ pinned: ::pin_project_lite::__private::PhantomData,
+ unpinned: ::pin_project_lite::__private::ptr::read(unpinned),
+ };
+ {
+ (
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ (),
+ );
+ }
+ result
+ }
+ Self::Unit => EnumProjReplace::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.rs
new file mode 100644
index 0000000000..90d6860a81
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-all.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[project_replace = EnumProjReplace]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.expanded.rs
new file mode 100644
index 0000000000..7c4d6afbf9
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.expanded.rs
@@ -0,0 +1,57 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.rs
new file mode 100644
index 0000000000..69beecd1d9
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-mut.rs
@@ -0,0 +1,15 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.expanded.rs
new file mode 100644
index 0000000000..28ce97da7b
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.expanded.rs
@@ -0,0 +1,26 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {}
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.rs
new file mode 100644
index 0000000000..b2e3f9d76a
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-none.rs
@@ -0,0 +1,14 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.expanded.rs
new file mode 100644
index 0000000000..a1a013bda4
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.expanded.rs
@@ -0,0 +1,57 @@
+use pin_project_lite::pin_project;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.rs b/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.rs
new file mode 100644
index 0000000000..480d592d68
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/enum-ref.rs
@@ -0,0 +1,15 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project_ref = EnumProjRef]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.expanded.rs
new file mode 100644
index 0000000000..b91c24eb2a
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.expanded.rs
@@ -0,0 +1,117 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProj<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProjRef<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProjReplace<T, U> {
+ pinned: ::pin_project_lite::__private::PhantomData<T>,
+ unpinned: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> StructProj<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ StructProj {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> StructProjRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ StructProjRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_replace(
+ self: ::pin_project_lite::__private::Pin<&mut Self>,
+ replacement: Self,
+ ) -> StructProjReplace<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
+ let Self { pinned, unpinned } = &mut *__self_ptr;
+ let result = StructProjReplace {
+ pinned: ::pin_project_lite::__private::PhantomData,
+ unpinned: ::pin_project_lite::__private::ptr::read(unpinned),
+ };
+ {
+ (
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
+ (),
+ );
+ }
+ result
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.rs
new file mode 100644
index 0000000000..cb087530fe
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-all.rs
@@ -0,0 +1,14 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = StructProj]
+ #[project_ref = StructProjRef]
+ #[project_replace = StructProjReplace]
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.expanded.rs
new file mode 100644
index 0000000000..aaa41cd080
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.expanded.rs
@@ -0,0 +1,84 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProj<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> StructProj<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ StructProj {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjectionRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.rs
new file mode 100644
index 0000000000..59db44530a
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-mut.rs
@@ -0,0 +1,12 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = StructProj]
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.expanded.rs
new file mode 100644
index 0000000000..8ab318cfb8
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.expanded.rs
@@ -0,0 +1,84 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Projection {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjectionRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.rs
new file mode 100644
index 0000000000..e5447c70a6
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-none.rs
@@ -0,0 +1,11 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.expanded.rs
new file mode 100644
index 0000000000..3d97ab8fae
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.expanded.rs
@@ -0,0 +1,84 @@
+use pin_project_lite::pin_project;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+struct StructProjRef<'__pin, T, U>
+where
+ Struct<T, U>: '__pin,
+{
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Projection {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> StructProjRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ StructProjRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.rs b/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.rs
new file mode 100644
index 0000000000..6821af8274
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/naming/struct-ref.rs
@@ -0,0 +1,12 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project_ref = StructProjRef]
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.expanded.rs
new file mode 100644
index 0000000000..665ff63386
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.expanded.rs
@@ -0,0 +1,95 @@
+use pin_project_lite::pin_project;
+use std::pin::Pin;
+enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ impl<T, U> ::pin_project_lite::__private::Drop for Enum<T, U> {
+ fn drop(&mut self) {
+ fn __drop_inner<T, U>(this: ::pin_project_lite::__private::Pin<&mut Enum<T, U>>) {
+ fn __drop_inner() {}
+ let _ = this;
+ }
+ let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> =
+ unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
+ __drop_inner(pinned_self);
+ }
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.rs b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.rs
new file mode 100644
index 0000000000..1855cb7a16
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/enum.rs
@@ -0,0 +1,22 @@
+use pin_project_lite::pin_project;
+use std::pin::Pin;
+
+pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+ impl<T, U> PinnedDrop for Enum<T, U> {
+ fn drop(this: Pin<&mut Self>) {
+ let _ = this;
+ }
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.expanded.rs
new file mode 100644
index 0000000000..5b82b7a19c
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.expanded.rs
@@ -0,0 +1,92 @@
+use pin_project_lite::pin_project;
+use std::pin::Pin;
+struct Struct<T, U> {
+ pinned: T,
+ unpinned: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Projection {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjectionRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ impl<T, U> ::pin_project_lite::__private::Drop for Struct<T, U> {
+ fn drop(&mut self) {
+ fn __drop_inner<T, U>(this: ::pin_project_lite::__private::Pin<&mut Struct<T, U>>) {
+ fn __drop_inner() {}
+ let _ = this;
+ }
+ let pinned_self: ::pin_project_lite::__private::Pin<&mut Self> =
+ unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
+ __drop_inner(pinned_self);
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.rs b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.rs
new file mode 100644
index 0000000000..0cc7567690
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pinned_drop/struct.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+use std::pin::Pin;
+
+pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+ impl<T, U> PinnedDrop for Struct<T, U> {
+ fn drop(this: Pin<&mut Self>) {
+ let _ = this;
+ }
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pub/enum.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/pub/enum.expanded.rs
new file mode 100644
index 0000000000..6f190cba08
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pub/enum.expanded.rs
@@ -0,0 +1,87 @@
+use pin_project_lite::pin_project;
+pub enum Enum<T, U> {
+ Struct { pinned: T, unpinned: U },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+pub(crate) enum EnumProj<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ unpinned: &'__pin mut (U),
+ },
+ Unit,
+}
+#[allow(dead_code)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::mut_mut)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::ref_option_ref)]
+#[allow(clippy::type_repetition_in_bounds)]
+pub(crate) enum EnumProjRef<'__pin, T, U>
+where
+ Enum<T, U>: '__pin,
+{
+ Struct {
+ pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ unpinned: &'__pin (U),
+ },
+ Unit,
+}
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ impl<T, U> Enum<T, U> {
+ pub(crate) fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> EnumProj<'__pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => EnumProj::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ pub(crate) fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> EnumProjRef<'__pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => EnumProjRef::Struct {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ },
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ pub struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
+ Unit: (),
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Enum<T, U> {}
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pub/enum.rs b/third_party/rust/pin-project-lite/tests/expand/pub/enum.rs
new file mode 100644
index 0000000000..d3968afdf2
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pub/enum.rs
@@ -0,0 +1,16 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pub/struct.expanded.rs b/third_party/rust/pin-project-lite/tests/expand/pub/struct.expanded.rs
new file mode 100644
index 0000000000..7b5826d149
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pub/struct.expanded.rs
@@ -0,0 +1,84 @@
+use pin_project_lite::pin_project;
+pub struct Struct<T, U> {
+ pub pinned: T,
+ pub unpinned: U,
+}
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ pub(crate) struct Projection<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pub pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
+ pub unpinned: &'__pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(single_use_lifetimes)]
+ #[allow(clippy::unknown_clippy_lints)]
+ #[allow(clippy::mut_mut)]
+ #[allow(clippy::redundant_pub_crate)]
+ #[allow(clippy::ref_option_ref)]
+ #[allow(clippy::type_repetition_in_bounds)]
+ pub(crate) struct ProjectionRef<'__pin, T, U>
+ where
+ Struct<T, U>: '__pin,
+ {
+ pub pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
+ pub unpinned: &'__pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ pub(crate) fn project<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
+ ) -> Projection<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Projection {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ pub(crate) fn project_ref<'__pin>(
+ self: ::pin_project_lite::__private::Pin<&'__pin Self>,
+ ) -> ProjectionRef<'__pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjectionRef {
+ pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
+ unpinned: unpinned,
+ }
+ }
+ }
+ }
+ #[allow(non_snake_case)]
+ pub struct __Origin<'__pin, T, U> {
+ __dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
+ pinned: T,
+ unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
+ }
+ impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
+ __Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
+ {
+ }
+ trait MustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {}
+ impl<T, U> MustNotImplDrop for Struct<T, U> {}
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expand/pub/struct.rs b/third_party/rust/pin-project-lite/tests/expand/pub/struct.rs
new file mode 100644
index 0000000000..6659096909
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expand/pub/struct.rs
@@ -0,0 +1,11 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/expandtest.rs b/third_party/rust/pin-project-lite/tests/expandtest.rs
new file mode 100644
index 0000000000..3f0d5c1121
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/expandtest.rs
@@ -0,0 +1,43 @@
+#![cfg(not(miri))]
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+use std::{
+ env,
+ process::{Command, ExitStatus, Stdio},
+};
+
+const PATH: &str = "tests/expand/**/*.rs";
+
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+fn expandtest() {
+ let is_ci = env::var_os("CI").is_some();
+ let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into());
+ if !has_command(&[cargo, "expand"]) || !has_command(&[cargo, "fmt"]) {
+ if is_ci {
+ panic!("expandtest requires rustfmt and cargo-expand");
+ }
+ return;
+ }
+
+ let args = &["--all-features"];
+ if is_ci {
+ macrotest::expand_without_refresh_args(PATH, args);
+ } else {
+ env::set_var("MACROTEST", "overwrite");
+ macrotest::expand_args(PATH, args);
+ }
+}
+
+fn has_command(command: &[&str]) -> bool {
+ Command::new(command[0])
+ .args(&command[1..])
+ .arg("--version")
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .as_ref()
+ .map(ExitStatus::success)
+ .unwrap_or(false)
+}
diff --git a/third_party/rust/pin-project-lite/tests/include/basic.rs b/third_party/rust/pin-project-lite/tests/include/basic.rs
new file mode 100644
index 0000000000..25121f210b
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/include/basic.rs
@@ -0,0 +1,35 @@
+// default pin_project! is completely safe.
+
+::pin_project_lite::pin_project! {
+ #[derive(Debug)]
+ pub struct DefaultStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+}
+
+::pin_project_lite::pin_project! {
+ #[project = DefaultStructProj]
+ #[project_ref = DefaultStructProjRef]
+ #[derive(Debug)]
+ pub struct DefaultStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+}
+
+::pin_project_lite::pin_project! {
+ #[project = DefaultEnumProj]
+ #[project_ref = DefaultEnumProjRef]
+ #[derive(Debug)]
+ pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+}
diff --git a/third_party/rust/pin-project-lite/tests/lint.rs b/third_party/rust/pin-project-lite/tests/lint.rs
new file mode 100644
index 0000000000..852f940bcf
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/lint.rs
@@ -0,0 +1,263 @@
+// Check interoperability with rustc and clippy lints.
+
+#![forbid(unsafe_code)]
+// for old compilers
+#![allow(unknown_lints)]
+#![warn(nonstandard_style, rust_2018_idioms, 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, rust_2021_compatibility)]
+// lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below.
+// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms
+// unsafe_op_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn.
+// non_exhaustive_omitted_patterns: unstable
+// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features
+// unused_crate_dependencies, must_not_suspend: unrelated
+// unsafe_code: checked in forbid_unsafe module
+#![warn(
+ box_pointers,
+ deprecated_in_future,
+ fuzzy_provenance_casts,
+ lossy_provenance_casts,
+ macro_use_extern_crate,
+ meta_variable_misuse,
+ missing_abi,
+ missing_copy_implementations,
+ missing_debug_implementations,
+ missing_docs,
+ non_ascii_idents,
+ noop_method_call,
+ single_use_lifetimes,
+ trivial_casts,
+ trivial_numeric_casts,
+ unreachable_pub,
+ unused_import_braces,
+ unused_lifetimes,
+ unused_qualifications,
+ unused_results,
+ variant_size_differences
+)]
+#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)]
+#![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
+#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums, clippy::single_char_lifetime_names)] // TODO
+
+pub mod basic {
+ include!("include/basic.rs");
+}
+
+pub mod box_pointers {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct {
+ #[pin]
+ pub p: Box<isize>,
+ pub u: Box<isize>,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum {
+ Struct {
+ #[pin]
+ p: Box<isize>,
+ u: Box<isize>,
+ },
+ Unit,
+ }
+ }
+}
+
+pub mod explicit_outlives_requirements {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U>
+ where
+ T: ?Sized,
+ U: ?Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Unit,
+ }
+ }
+}
+
+pub mod variant_size_differences {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[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
+ pub enum Enum {
+ V1 { f: u8 },
+ V2 { f: [u8; 1024] },
+ }
+ }
+}
+
+pub mod clippy_mut_mut {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct<'a, T, U> {
+ #[pin]
+ pub pinned: &'a mut T,
+ pub unpinned: &'a mut U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum<'a, T, U> {
+ Struct {
+ #[pin]
+ pinned: &'a mut T,
+ unpinned: &'a mut U,
+ },
+ Unit,
+ }
+ }
+}
+
+#[allow(unreachable_pub)]
+mod clippy_redundant_pub_crate {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+ }
+}
+
+#[allow(clippy::use_self)]
+pub mod clippy_type_repetition_in_bounds {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct<T, U>
+ where
+ Struct<T, U>: Sized,
+ {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum<T, U>
+ where
+ Enum<T, U>: Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Unit,
+ }
+ }
+}
+
+pub mod clippy_used_underscore_binding {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ #[derive(Debug)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub _pinned: T,
+ pub _unpinned: U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Debug)]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ _pinned: T,
+ _unpinned: U,
+ },
+ }
+ }
+}
+
+pub mod clippy_ref_option_ref {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ pub struct Struct<'a> {
+ #[pin]
+ pub _pinned: Option<&'a ()>,
+ pub _unpinned: Option<&'a ()>,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ pub enum Enum<'a> {
+ Struct {
+ #[pin]
+ _pinned: Option<&'a ()>,
+ _unpinned: Option<&'a ()>,
+ },
+ }
+ }
+}
diff --git a/third_party/rust/pin-project-lite/tests/proper_unpin.rs b/third_party/rust/pin-project-lite/tests/proper_unpin.rs
new file mode 100644
index 0000000000..668e975ba9
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/proper_unpin.rs
@@ -0,0 +1,67 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+pub mod default {
+ use std::marker::PhantomPinned;
+
+ use pin_project_lite::pin_project;
+
+ struct Inner<T> {
+ f: T,
+ }
+
+ assert_unpin!(Inner<()>);
+ assert_not_unpin!(Inner<PhantomPinned>);
+
+ pin_project! {
+ struct Struct<T, U> {
+ #[pin]
+ f1: Inner<T>,
+ f2: U,
+ }
+ }
+
+ assert_unpin!(Struct<(), ()>);
+ assert_unpin!(Struct<(), PhantomPinned>);
+ assert_not_unpin!(Struct<PhantomPinned, ()>);
+ assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>);
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<T, U> {
+ V1 {
+ #[pin]
+ f1: Inner<T>,
+ f2: U,
+ },
+ }
+ }
+
+ assert_unpin!(Enum<(), ()>);
+ assert_unpin!(Enum<(), PhantomPinned>);
+ assert_not_unpin!(Enum<PhantomPinned, ()>);
+ assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>);
+
+ pin_project! {
+ struct TrivialBounds {
+ #[pin]
+ f: PhantomPinned,
+ }
+ }
+
+ assert_not_unpin!(TrivialBounds);
+
+ pin_project! {
+ struct PinRef<'a, T, U> {
+ #[pin]
+ f1: &'a mut Inner<T>,
+ f2: U,
+ }
+ }
+
+ assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>);
+}
diff --git a/third_party/rust/pin-project-lite/tests/test.rs b/third_party/rust/pin-project-lite/tests/test.rs
new file mode 100644
index 0000000000..ed9b75c42c
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/test.rs
@@ -0,0 +1,695 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+use core::{
+ marker::{PhantomData, PhantomPinned},
+ pin::Pin,
+};
+
+use pin_project_lite::pin_project;
+
+#[test]
+fn projection() {
+ pin_project! {
+ #[project = StructProj]
+ #[project_ref = StructProjRef]
+ #[project_replace = StructProjReplace]
+ #[derive(Default)]
+ struct Struct<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+ }
+ }
+
+ let mut s = Struct { f1: 1, f2: 2 };
+ let mut s_orig = Pin::new(&mut s);
+ let s = s_orig.as_mut().project();
+
+ let _: Pin<&mut i32> = s.f1;
+ assert_eq!(*s.f1, 1);
+ let _: &mut i32 = s.f2;
+ assert_eq!(*s.f2, 2);
+
+ assert_eq!(s_orig.as_ref().f1, 1);
+ assert_eq!(s_orig.as_ref().f2, 2);
+
+ let mut s = Struct { f1: 1, f2: 2 };
+ let mut s = Pin::new(&mut s);
+ {
+ let StructProj { f1, f2 } = s.as_mut().project();
+ let _: Pin<&mut i32> = f1;
+ let _: &mut i32 = f2;
+ }
+ {
+ let StructProjRef { f1, f2 } = s.as_ref().project_ref();
+ let _: Pin<&i32> = f1;
+ let _: &i32 = f2;
+ }
+
+ {
+ let StructProjReplace { f1: PhantomData, f2 } =
+ s.as_mut().project_replace(Struct::default());
+ assert_eq!(f2, 2);
+ let StructProj { f1, f2 } = s.project();
+ assert_eq!(*f1, 0);
+ assert_eq!(*f2, 0);
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[project_replace = EnumProjReplace]
+ #[derive(Eq, PartialEq, Debug)]
+ enum Enum<C, D> {
+ Struct {
+ #[pin]
+ f1: C,
+ f2: D,
+ },
+ Unit,
+ }
+ }
+
+ let mut e = Enum::Struct { f1: 1, f2: 2 };
+ let mut e = Pin::new(&mut e);
+
+ match e.as_mut().project() {
+ EnumProj::Struct { f1, f2 } => {
+ let _: Pin<&mut i32> = f1;
+ assert_eq!(*f1, 1);
+ let _: &mut i32 = f2;
+ assert_eq!(*f2, 2);
+ }
+ EnumProj::Unit => unreachable!(),
+ }
+
+ assert_eq!(&*e, &Enum::Struct { f1: 1, f2: 2 });
+
+ if let EnumProj::Struct { f1, f2 } = e.as_mut().project() {
+ let _: Pin<&mut i32> = f1;
+ assert_eq!(*f1, 1);
+ let _: &mut i32 = f2;
+ assert_eq!(*f2, 2);
+ }
+
+ if let EnumProjReplace::Struct { f1: PhantomData, f2 } = e.as_mut().project_replace(Enum::Unit)
+ {
+ assert_eq!(f2, 2);
+ }
+}
+
+#[test]
+fn enum_project_set() {
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ #[derive(Eq, PartialEq, Debug)]
+ enum Enum {
+ V1 { #[pin] f: u8 },
+ V2 { f: bool },
+ }
+ }
+
+ let mut e = Enum::V1 { f: 25 };
+ let mut e_orig = Pin::new(&mut e);
+ let e_proj = e_orig.as_mut().project();
+
+ match e_proj {
+ EnumProj::V1 { f } => {
+ let new_e = Enum::V2 { f: f.as_ref().get_ref() == &25 };
+ e_orig.set(new_e);
+ }
+ EnumProj::V2 { .. } => unreachable!(),
+ }
+
+ assert_eq!(e, Enum::V2 { f: true });
+}
+
+#[test]
+fn where_clause() {
+ pin_project! {
+ struct Struct<T>
+ where
+ T: Copy,
+ {
+ f: T,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<T>
+ where
+ T: Copy,
+ {
+ V { f: T },
+ }
+ }
+}
+
+#[test]
+fn where_clause_and_associated_type_field() {
+ pin_project! {
+ struct Struct1<I>
+ where
+ I: Iterator,
+ {
+ #[pin]
+ f1: I,
+ f2: I::Item,
+ }
+ }
+
+ pin_project! {
+ struct Struct2<I, J>
+ where
+ I: Iterator<Item = J>,
+ {
+ #[pin]
+ f1: I,
+ f2: J,
+ }
+ }
+
+ pin_project! {
+ pub struct Struct3<T>
+ where
+ T: 'static,
+ {
+ f: T,
+ }
+ }
+
+ trait Static: 'static {}
+
+ impl<T> Static for Struct3<T> {}
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<I>
+ where
+ I: Iterator,
+ {
+ V1 { #[pin] f: I },
+ V2 { f: I::Item },
+ }
+ }
+}
+
+#[test]
+fn derive_copy() {
+ pin_project! {
+ #[derive(Clone, Copy)]
+ struct Struct<T> {
+ f: T,
+ }
+ }
+
+ fn is_copy<T: Copy>() {}
+
+ is_copy::<Struct<u8>>();
+}
+
+#[test]
+fn move_out() {
+ struct NotCopy;
+
+ pin_project! {
+ struct Struct {
+ f: NotCopy,
+ }
+ }
+
+ let x = Struct { f: NotCopy };
+ let _val: NotCopy = x.f;
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum {
+ V { f: NotCopy },
+ }
+ }
+
+ let x = Enum::V { f: NotCopy };
+ #[allow(clippy::infallible_destructuring_match)]
+ let _val: NotCopy = match x {
+ Enum::V { f } => f,
+ };
+}
+
+#[test]
+fn trait_bounds_on_type_generics() {
+ pin_project! {
+ pub struct Struct1<'a, T: ?Sized> {
+ f: &'a mut T,
+ }
+ }
+
+ pin_project! {
+ pub struct Struct2<'a, T: ::core::fmt::Debug> {
+ f: &'a mut T,
+ }
+ }
+
+ pin_project! {
+ pub struct Struct3<'a, T: core::fmt::Debug> {
+ f: &'a mut T,
+ }
+ }
+
+ // pin_project! {
+ // pub struct Struct4<'a, T: core::fmt::Debug + core::fmt::Display> {
+ // f: &'a mut T,
+ // }
+ // }
+
+ // pin_project! {
+ // pub struct Struct5<'a, T: core::fmt::Debug + ?Sized> {
+ // f: &'a mut T,
+ // }
+ // }
+
+ pin_project! {
+ pub struct Struct6<'a, T: core::fmt::Debug = [u8; 16]> {
+ f: &'a mut T,
+ }
+ }
+
+ let _: Struct6<'_> = Struct6 { f: &mut [0_u8; 16] };
+
+ pin_project! {
+ pub struct Struct7<T: 'static> {
+ f: T,
+ }
+ }
+
+ trait Static: 'static {}
+
+ impl<T> Static for Struct7<T> {}
+
+ pin_project! {
+ pub struct Struct8<'a, 'b: 'a> {
+ f1: &'a u8,
+ f2: &'b u8,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<'a, T: ?Sized> {
+ V { f: &'a mut T },
+ }
+ }
+}
+
+#[test]
+fn private_type_in_public_type() {
+ pin_project! {
+ pub struct PublicStruct<T> {
+ #[pin]
+ inner: PrivateStruct<T>,
+ }
+ }
+
+ struct PrivateStruct<T>(T);
+}
+
+#[allow(clippy::needless_lifetimes)]
+#[test]
+fn lifetime_project() {
+ pin_project! {
+ struct Struct1<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+ }
+
+ pin_project! {
+ struct Struct2<'a, T, U> {
+ #[pin]
+ pinned: &'a T,
+ unpinned: U,
+ }
+ }
+
+ pin_project! {
+ #[project = EnumProj]
+ #[project_ref = EnumProjRef]
+ enum Enum<T, U> {
+ V {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ }
+ }
+
+ impl<T, U> Struct1<T, U> {
+ fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
+ self.project_ref().pinned
+ }
+ 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> {
+ fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a &'b T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut &'b T> {
+ self.project().pinned
+ }
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&&'b T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut &'b 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::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
+ match self.project() {
+ EnumProj::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
+ match self.project_ref() {
+ EnumProjRef::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
+ match self.project() {
+ EnumProj::V { pinned, .. } => pinned,
+ }
+ }
+ }
+}
+
+mod visibility {
+ use pin_project_lite::pin_project;
+
+ pin_project! {
+ pub(crate) struct S {
+ pub f: u8,
+ }
+ }
+}
+
+#[test]
+fn visibility() {
+ let mut x = visibility::S { f: 0 };
+ let x = Pin::new(&mut x);
+ let y = x.as_ref().project_ref();
+ let _: &u8 = y.f;
+ let y = x.project();
+ let _: &mut u8 = y.f;
+}
+
+#[test]
+fn trivial_bounds() {
+ pin_project! {
+ pub struct NoGenerics {
+ #[pin]
+ f: PhantomPinned,
+ }
+ }
+
+ assert_not_unpin!(NoGenerics);
+}
+
+#[test]
+fn dst() {
+ pin_project! {
+ pub struct Struct1<T: ?Sized> {
+ f: T,
+ }
+ }
+
+ let mut x = Struct1 { f: 0_u8 };
+ let x: Pin<&mut Struct1<dyn core::fmt::Debug>> = Pin::new(&mut x as _);
+ let _: &mut (dyn core::fmt::Debug) = x.project().f;
+
+ pin_project! {
+ pub struct Struct2<T: ?Sized> {
+ #[pin]
+ f: T,
+ }
+ }
+
+ let mut x = Struct2 { f: 0_u8 };
+ let x: Pin<&mut Struct2<dyn core::fmt::Debug + Unpin>> = Pin::new(&mut x as _);
+ let _: Pin<&mut (dyn core::fmt::Debug + Unpin)> = x.project().f;
+
+ pin_project! {
+ struct Struct3<T>
+ where
+ T: ?Sized,
+ {
+ f: T,
+ }
+ }
+
+ pin_project! {
+ struct Struct4<T>
+ where
+ T: ?Sized,
+ {
+ #[pin]
+ f: T,
+ }
+ }
+
+ pin_project! {
+ struct Struct11<'a, T: ?Sized, U: ?Sized> {
+ f1: &'a mut T,
+ f2: U,
+ }
+ }
+}
+
+#[test]
+fn dyn_type() {
+ pin_project! {
+ struct Struct1 {
+ f: dyn core::fmt::Debug,
+ }
+ }
+
+ pin_project! {
+ struct Struct2 {
+ #[pin]
+ f: dyn core::fmt::Debug,
+ }
+ }
+
+ pin_project! {
+ struct Struct3 {
+ f: dyn core::fmt::Debug + Send,
+ }
+ }
+
+ pin_project! {
+ struct Struct4 {
+ #[pin]
+ f: dyn core::fmt::Debug + Send,
+ }
+ }
+}
+
+#[test]
+fn no_infer_outlives() {
+ trait Trait<X> {
+ type Y;
+ }
+
+ struct Struct1<A>(A);
+
+ impl<X, T> Trait<X> for Struct1<T> {
+ type Y = Option<T>;
+ }
+
+ pin_project! {
+ struct Struct2<A, B> {
+ _f: <Struct1<A> as Trait<B>>::Y,
+ }
+ }
+}
+
+// https://github.com/taiki-e/pin-project-lite/issues/31
+#[test]
+fn trailing_comma() {
+ pub trait T {}
+
+ pin_project! {
+ pub struct S1<
+ A: T,
+ B: T,
+ > {
+ f: (A, B),
+ }
+ }
+
+ pin_project! {
+ pub struct S2<
+ A,
+ B,
+ >
+ where
+ A: T,
+ B: T,
+ {
+ f: (A, B),
+ }
+ }
+
+ pin_project! {
+ #[allow(explicit_outlives_requirements)]
+ pub struct S3<
+ 'a,
+ A: 'a,
+ B: 'a,
+ > {
+ f: &'a (A, B),
+ }
+ }
+
+ // pin_project! {
+ // pub struct S4<
+ // 'a,
+ // 'b: 'a, // <-----
+ // > {
+ // f: &'a &'b (),
+ // }
+ // }
+}
+
+#[test]
+fn attrs() {
+ pin_project! {
+ /// dox1
+ #[derive(Clone)]
+ #[project = StructProj]
+ #[project_ref = StructProjRef]
+ /// dox2
+ #[derive(Debug)]
+ /// dox3
+ struct Struct {
+ // TODO
+ // /// dox4
+ f: ()
+ }
+ }
+
+ pin_project! {
+ #[project = Enum1Proj]
+ #[project_ref = Enum1ProjRef]
+ enum Enum1 {
+ #[cfg(not(any()))]
+ V {
+ f: ()
+ },
+ }
+ }
+
+ pin_project! {
+ /// dox1
+ #[derive(Clone)]
+ #[project = Enum2Proj]
+ #[project_ref = Enum2ProjRef]
+ /// dox2
+ #[derive(Debug)]
+ /// dox3
+ enum Enum2 {
+ /// dox4
+ V1 {
+ // TODO
+ // /// dox5
+ f: ()
+ },
+ /// dox6
+ V2,
+ }
+ }
+}
+
+#[test]
+fn pinned_drop() {
+ pin_project! {
+ pub struct Struct1<'a> {
+ was_dropped: &'a mut bool,
+ #[pin]
+ field: u8,
+ }
+ impl PinnedDrop for Struct1<'_> {
+ fn drop(this: Pin<&mut Self>) {
+ **this.project().was_dropped = true;
+ }
+ }
+ }
+
+ let mut was_dropped = false;
+ drop(Struct1 { was_dropped: &mut was_dropped, field: 42 });
+ assert!(was_dropped);
+
+ pin_project! {
+ pub struct Struct2<'a> {
+ was_dropped: &'a mut bool,
+ #[pin]
+ field: u8,
+ }
+ impl PinnedDrop for Struct2<'_> {
+ fn drop(mut this: Pin<&mut Self>) {
+ **this.as_mut().project().was_dropped = true;
+ }
+ }
+ }
+
+ trait Service<Request> {
+ type Error;
+ }
+
+ pin_project! {
+ struct Struct3<'a, T, Request>
+ where
+ T: Service<Request>,
+ T::Error: std::error::Error,
+ {
+ was_dropped: &'a mut bool,
+ #[pin]
+ field: T,
+ req: Request,
+ }
+
+ impl<T, Request> PinnedDrop for Struct3<'_, T, Request>
+ where
+ T: Service<Request>,
+ T::Error: std::error::Error,
+ {
+ fn drop(mut this: Pin<&mut Self>) {
+ **this.as_mut().project().was_dropped = true;
+ }
+ }
+ }
+}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.rs
new file mode 100644
index 0000000000..870059d62f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.rs
@@ -0,0 +1,15 @@
+use pin_project_lite::pin_project;
+
+pin_project! { //~ ERROR E0119
+ struct Foo<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+ }
+}
+
+impl<T, U> Drop for Foo<T, U> {
+ fn drop(&mut self) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.stderr
new file mode 100644
index 0000000000..66872bd4bd
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-drop.stderr
@@ -0,0 +1,16 @@
+error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type `Foo<_, _>`
+ --> tests/ui/pin_project/conflict-drop.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR E0119
+4 | | struct Foo<T, U> {
+5 | | #[pin]
+6 | | future: T,
+7 | | field: U,
+8 | | }
+9 | | }
+ | | ^
+ | | |
+ | |_first implementation here
+ | conflicting implementation for `Foo<_, _>`
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.rs
new file mode 100644
index 0000000000..f702f064de
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.rs
@@ -0,0 +1,40 @@
+use pin_project_lite::pin_project;
+
+// The same implementation.
+
+pin_project! { //~ ERROR E0119
+ struct Foo<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+ }
+}
+
+// conflicting implementations
+impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
+
+// The implementation that under different conditions.
+
+pin_project! { //~ ERROR E0119
+ struct Bar<T, U> {
+ #[pin]
+ future: T,
+ field: U,
+ }
+}
+
+// conflicting implementations
+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,
+ }
+}
+
+// conflicting implementations
+impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.stderr
new file mode 100644
index 0000000000..bd30fafdd3
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/conflict-unpin.stderr
@@ -0,0 +1,50 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:5:1
+ |
+5 | / pin_project! { //~ ERROR E0119
+6 | | struct Foo<T, U> {
+7 | | #[pin]
+8 | | future: T,
+9 | | field: U,
+10 | | }
+11 | | }
+ | |_^ conflicting implementation for `Foo<_, _>`
+...
+14 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
+ | --------------------------------------------- first implementation here
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:18:1
+ |
+18 | / pin_project! { //~ ERROR E0119
+19 | | struct Bar<T, U> {
+20 | | #[pin]
+21 | | future: T,
+22 | | field: U,
+23 | | }
+24 | | }
+ | |_^ conflicting implementation for `Bar<_, _>`
+...
+27 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
+ | ------------------------------ first implementation here
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:29:1
+ |
+29 | / pin_project! { //~ ERROR E0119
+30 | | struct Baz<T, U> {
+31 | | #[pin]
+32 | | future: T,
+33 | | field: U,
+34 | | }
+35 | | }
+ | |_^ conflicting implementation for `Baz<_, _>`
+...
+38 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+ | -------------------------------------------- first implementation here
+ |
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.rs
new file mode 100644
index 0000000000..64b397a37e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.rs
@@ -0,0 +1,93 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized`
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause1<T>
+ where
+ T: 'static : Sized //~ ERROR no rules expected the token `:`
+ {
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause2<T>
+ where
+ T: 'static : ?Sized //~ ERROR no rules expected the token `:`
+ {
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause3<T>
+ where
+ T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+ {
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause4<T>
+ where
+ T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+ {
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause5<T>
+ where
+ T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:`
+ {
+ field: T,
+ }
+}
+
+pin_project! {
+ struct WhereClause6<T>
+ where
+ T: ?Sized : Sized //~ ERROR no rules expected the token `Sized`
+ {
+ field: T,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.stderr
new file mode 100644
index 0000000000..40e79bf928
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid-bounds.stderr
@@ -0,0 +1,428 @@
+error: no rules expected the token `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:4:33
+ |
+4 | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:`
+ | ^ no rules expected this token in macro call
+
+error: no rules expected the token `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:10:33
+ |
+10 | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:`
+ | ^ no rules expected this token in macro call
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:15:1
+ |
+15 | / pin_project! {
+16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+17 | | field: T,
+18 | | }
+19 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:15:1
+ |
+15 | / pin_project! {
+16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+17 | | field: T,
+18 | | }
+19 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, `=`, or `>`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:15:1
+ |
+15 | / pin_project! {
+16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+17 | | field: T,
+18 | | }
+19 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:15:1
+ |
+15 | / pin_project! {
+16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+17 | | field: T,
+18 | | }
+19 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:21:1
+ |
+21 | / pin_project! {
+22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+23 | | field: T,
+24 | | }
+25 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:21:1
+ |
+21 | / pin_project! {
+22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+23 | | field: T,
+24 | | }
+25 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, `=`, or `>`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:21:1
+ |
+21 | / pin_project! {
+22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+23 | | field: T,
+24 | | }
+25 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:21:1
+ |
+21 | / pin_project! {
+22 | | struct Generics4<T: ?Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+23 | | field: T,
+24 | | }
+25 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:27:1
+ |
+27 | / pin_project! {
+28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+29 | | field: T,
+30 | | }
+31 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:27:1
+ |
+27 | / pin_project! {
+28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+29 | | field: T,
+30 | | }
+31 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, `=`, or `>`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:27:1
+ |
+27 | / pin_project! {
+28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+29 | | field: T,
+30 | | }
+31 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, `=`, or `>`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:27:1
+ |
+27 | / pin_project! {
+28 | | struct Generics5<T: Sized : ?Sized> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
+29 | | field: T,
+30 | | }
+31 | | }
+ | | ^
+ | | |
+ | | expected one of `+`, `,`, `=`, or `>`
+ | |_unexpected token
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `Sized`
+ --> tests/ui/pin_project/invalid-bounds.rs:34:34
+ |
+34 | struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized`
+ | ^^^^^ no rules expected this token in macro call
+
+error: no rules expected the token `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:42:20
+ |
+42 | T: 'static : Sized //~ ERROR no rules expected the token `:`
+ | ^ no rules expected this token in macro call
+
+error: no rules expected the token `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:51:20
+ |
+51 | T: 'static : ?Sized //~ ERROR no rules expected the token `:`
+ | ^ no rules expected this token in macro call
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:57:1
+ |
+57 | / pin_project! {
+58 | | struct WhereClause3<T>
+59 | | where
+60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+63 | | }
+64 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, or `{`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:57:1
+ |
+57 | / pin_project! {
+58 | | struct WhereClause3<T>
+59 | | where
+60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+63 | | }
+64 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, or `{`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:57:1
+ |
+57 | / pin_project! {
+58 | | struct WhereClause3<T>
+59 | | where
+60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+63 | | }
+64 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:57:1
+ |
+57 | / pin_project! {
+58 | | struct WhereClause3<T>
+59 | | where
+60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+63 | | }
+64 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:66:1
+ |
+66 | / pin_project! {
+67 | | struct WhereClause4<T>
+68 | | where
+69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+72 | | }
+73 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, or `{`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:66:1
+ |
+66 | / pin_project! {
+67 | | struct WhereClause4<T>
+68 | | where
+69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+72 | | }
+73 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, or `{`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:66:1
+ |
+66 | / pin_project! {
+67 | | struct WhereClause4<T>
+68 | | where
+69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+72 | | }
+73 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:66:1
+ |
+66 | / pin_project! {
+67 | | struct WhereClause4<T>
+68 | | where
+69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+72 | | }
+73 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:75:1
+ |
+75 | / pin_project! {
+76 | | struct WhereClause5<T>
+77 | | where
+78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+81 | | }
+82 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected one of `+`, `,`, or `{`, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:75:1
+ |
+75 | / pin_project! {
+76 | | struct WhereClause5<T>
+77 | | where
+78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+81 | | }
+82 | | }
+ | | ^
+ | | |
+ | |_expected one of `+`, `,`, or `{`
+ | unexpected token
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:75:1
+ |
+75 | / pin_project! {
+76 | | struct WhereClause5<T>
+77 | | where
+78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+81 | | }
+82 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected `{` after struct name, found `:`
+ --> tests/ui/pin_project/invalid-bounds.rs:75:1
+ |
+75 | / pin_project! {
+76 | | struct WhereClause5<T>
+77 | | where
+78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:`
+... |
+81 | | }
+82 | | }
+ | | ^
+ | | |
+ | |_expected `{` after struct name
+ | in this macro invocation
+ |
+ = note: this error originates in the macro `$crate::__pin_project_parse_generics` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `Sized`
+ --> tests/ui/pin_project/invalid-bounds.rs:87:21
+ |
+87 | T: ?Sized : Sized //~ ERROR no rules expected the token `Sized`
+ | ^^^^^ no rules expected this token in macro call
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.rs
new file mode 100644
index 0000000000..e0ea61d4f7
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.rs
@@ -0,0 +1,25 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct A<T> {
+ #[pin()] //~ ERROR no rules expected the token `(`
+ pinned: T,
+ }
+}
+
+pin_project! {
+ #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ struct B<T> {
+ pinned: T,
+ }
+}
+
+pin_project! {
+ struct C<T> {
+ #[pin]
+ #[pin] //~ ERROR no rules expected the token `#`
+ pinned: T,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.stderr
new file mode 100644
index 0000000000..623a886722
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/invalid.stderr
@@ -0,0 +1,59 @@
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:3:1
+ |
+3 | / pin_project! {
+4 | | struct A<T> {
+5 | | #[pin()] //~ ERROR no rules expected the token `(`
+6 | | pinned: T,
+7 | | }
+8 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:3:1
+ |
+3 | / pin_project! {
+4 | | struct A<T> {
+5 | | #[pin()] //~ ERROR no rules expected the token `(`
+6 | | pinned: T,
+7 | | }
+8 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:17:1
+ |
+17 | / pin_project! {
+18 | | struct C<T> {
+19 | | #[pin]
+20 | | #[pin] //~ ERROR no rules expected the token `#`
+21 | | pinned: T,
+22 | | }
+23 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:17:1
+ |
+17 | / pin_project! {
+18 | | struct C<T> {
+19 | | #[pin]
+20 | | #[pin] //~ ERROR no rules expected the token `#`
+21 | | pinned: T,
+22 | | }
+23 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: cannot find attribute `pin` in this scope
+ --> tests/ui/pin_project/invalid.rs:11:7
+ |
+11 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ | ^^^
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.rs
new file mode 100644
index 0000000000..117c18d74c
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.rs
@@ -0,0 +1,10 @@
+use pin_project_lite::pin_project;
+
+pin_project! { //~ ERROR E0263,E0496
+ pub struct Foo<'__pin, T> {
+ #[pin]
+ field: &'__pin mut T,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.stderr
new file mode 100644
index 0000000000..35074d0753
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_lifetime_names.stderr
@@ -0,0 +1,75 @@
+error[E0263]: lifetime name `'__pin` declared twice in the same scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ^^^^^^ declared twice
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_- previous declaration here
+
+error[E0263]: lifetime name `'__pin` declared twice in the same scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ^^^^^^ declared twice
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_- previous declaration here
+
+error[E0263]: lifetime name `'__pin` declared twice in the same scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ^^^^^^ declared twice
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_- previous declaration here
+
+error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ------ first declared here
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_^ lifetime `'__pin` already in scope
+ |
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ------ first declared here
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_^ lifetime `'__pin` already in scope
+ |
+ = note: this error originates in the macro `$crate::__pin_project_struct_make_proj_method` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0263]: lifetime name `'__pin` declared twice in the same scope
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
+ |
+3 | / pin_project! { //~ ERROR E0263,E0496
+4 | | pub struct Foo<'__pin, T> {
+ | | ^^^^^^ declared twice
+5 | | #[pin]
+6 | | field: &'__pin mut T,
+7 | | }
+8 | | }
+ | |_- previous declaration here
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.rs
new file mode 100644
index 0000000000..25131d17d1
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.rs
@@ -0,0 +1,20 @@
+use std::marker::PhantomPinned;
+
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Foo<T> {
+ #[pin]
+ inner: T,
+ }
+}
+
+struct __Origin {}
+
+impl Unpin for __Origin {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.stderr
new file mode 100644
index 0000000000..303e7cbb58
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -0,0 +1,33 @@
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:19:5
+ |
+19 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Origin<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `_::__Origin<'_, PhantomPinned>`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
+ |
+5 | / pin_project! {
+6 | | struct Foo<T> {
+7 | | #[pin]
+8 | | inner: T,
+9 | | }
+10 | | }
+ | |_^
+note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
+ |
+5 | / pin_project! {
+6 | | struct Foo<T> {
+7 | | #[pin]
+8 | | inner: T,
+9 | | }
+10 | | }
+ | |_^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:16:16
+ |
+16 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+ = note: this error originates in the macro `$crate::__pin_project_make_unpin_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.rs
new file mode 100644
index 0000000000..50afb118c8
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.rs
@@ -0,0 +1,21 @@
+#![allow(unaligned_references)]
+
+use pin_project_lite::pin_project;
+
+pin_project! { //~ ERROR reference to packed field is unaligned
+ #[repr(packed, C)]
+ struct Packed {
+ #[pin]
+ field: u16,
+ }
+}
+
+pin_project! { //~ ERROR reference to packed field is unaligned
+ #[repr(packed(2))]
+ struct PackedN {
+ #[pin]
+ field: u32,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.stderr
new file mode 100644
index 0000000000..81fb4f1fcc
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/packed.stderr
@@ -0,0 +1,57 @@
+error: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:5:1
+ |
+5 | / pin_project! { //~ ERROR reference to packed field is unaligned
+6 | | #[repr(packed, C)]
+7 | | struct Packed {
+8 | | #[pin]
+9 | | field: u16,
+10 | | }
+11 | | }
+ | |_^
+ |
+note: the lint level is defined here
+ --> tests/ui/pin_project/packed.rs:5:1
+ |
+5 | / pin_project! { //~ ERROR reference to packed field is unaligned
+6 | | #[repr(packed, C)]
+7 | | struct Packed {
+8 | | #[pin]
+9 | | field: u16,
+10 | | }
+11 | | }
+ | |_^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
+ = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed.rs:13:1
+ |
+13 | / pin_project! { //~ ERROR reference to packed field is unaligned
+14 | | #[repr(packed(2))]
+15 | | struct PackedN {
+16 | | #[pin]
+17 | | field: u32,
+18 | | }
+19 | | }
+ | |_^
+ |
+note: the lint level is defined here
+ --> tests/ui/pin_project/packed.rs:13:1
+ |
+13 | / pin_project! { //~ ERROR reference to packed field is unaligned
+14 | | #[repr(packed(2))]
+15 | | struct PackedN {
+16 | | #[pin]
+17 | | field: u32,
+18 | | }
+19 | | }
+ | |_^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
+ = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.rs
new file mode 100644
index 0000000000..984cc2a219
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.rs
@@ -0,0 +1,12 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Foo {
+ #[pin]
+ inner: u8,
+ }
+}
+
+impl Unpin for __Origin {} //~ ERROR E0412,E0321
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.stderr
new file mode 100644
index 0000000000..4eb6eff96f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/unpin_sneaky.stderr
@@ -0,0 +1,11 @@
+error[E0412]: cannot find type `__Origin` in this scope
+ --> tests/ui/pin_project/unpin_sneaky.rs:10:16
+ |
+10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321
+ | ^^^^^^^^ not found in this scope
+
+error[E0321]: cross-crate traits with a default impl, like `Unpin`, can only be implemented for a struct/enum type, not `[type error]`
+ --> tests/ui/pin_project/unpin_sneaky.rs:10:1
+ |
+10 | impl Unpin for __Origin {} //~ ERROR E0412,E0321
+ | ^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.rs b/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.rs
new file mode 100644
index 0000000000..2f80836275
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.rs
@@ -0,0 +1,27 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ struct Struct1 {} //~ ERROR no rules expected the token `}`
+}
+
+pin_project! {
+ struct Struct2(); //~ ERROR no rules expected the token `(`
+}
+
+pin_project! {
+ struct Struct3; //~ ERROR no rules expected the token `;`
+}
+
+pin_project! {
+ enum Enum { //~ ERROR no rules expected the token `enum`
+ A(u8)
+ }
+}
+
+pin_project! {
+ union Union { //~ ERROR no rules expected the token `union`
+ x: u8,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.stderr b/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.stderr
new file mode 100644
index 0000000000..a7d215a43e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pin_project/unsupported.stderr
@@ -0,0 +1,79 @@
+error: no rules expected the token `}`
+ --> tests/ui/pin_project/unsupported.rs:3:1
+ |
+3 | / pin_project! {
+4 | | struct Struct1 {} //~ ERROR no rules expected the token `}`
+5 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `}`
+ --> tests/ui/pin_project/unsupported.rs:3:1
+ |
+3 | / pin_project! {
+4 | | struct Struct1 {} //~ ERROR no rules expected the token `}`
+5 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `(`
+ --> tests/ui/pin_project/unsupported.rs:8:19
+ |
+8 | struct Struct2(); //~ ERROR no rules expected the token `(`
+ | ^ no rules expected this token in macro call
+
+error: no rules expected the token `;`
+ --> tests/ui/pin_project/unsupported.rs:12:19
+ |
+12 | struct Struct3; //~ ERROR no rules expected the token `;`
+ | ^ no rules expected this token in macro call
+
+error: no rules expected the token `enum`
+ --> tests/ui/pin_project/unsupported.rs:15:1
+ |
+15 | / pin_project! {
+16 | | enum Enum { //~ ERROR no rules expected the token `enum`
+17 | | A(u8)
+18 | | }
+19 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `enum`
+ --> tests/ui/pin_project/unsupported.rs:15:1
+ |
+15 | / pin_project! {
+16 | | enum Enum { //~ ERROR no rules expected the token `enum`
+17 | | A(u8)
+18 | | }
+19 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `union`
+ --> tests/ui/pin_project/unsupported.rs:21:1
+ |
+21 | / pin_project! {
+22 | | union Union { //~ ERROR no rules expected the token `union`
+23 | | x: u8,
+24 | | }
+25 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: no rules expected the token `union`
+ --> tests/ui/pin_project/unsupported.rs:21:1
+ |
+21 | / pin_project! {
+22 | | union Union { //~ ERROR no rules expected the token `union`
+23 | | x: u8,
+24 | | }
+25 | | }
+ | |_^ no rules expected this token in macro call
+ |
+ = note: this error originates in the macro `$crate::__pin_project_expand` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs
new file mode 100644
index 0000000000..609b3bebad
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.rs
@@ -0,0 +1,17 @@
+use pin_project_lite::pin_project;
+
+pin_project! {
+ pub struct S {
+ #[pin]
+ field: u8,
+ }
+ impl PinnedDrop for S {
+ fn drop(this: Pin<&mut Self>) {
+ __drop_inner(this);
+ }
+ }
+}
+
+fn main() {
+ let _x = S { field: 0 };
+}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr
new file mode 100644
index 0000000000..597f67c84f
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/call-drop-inner.stderr
@@ -0,0 +1,22 @@
+error[E0061]: this function takes 0 arguments but 1 argument was supplied
+ --> tests/ui/pinned_drop/call-drop-inner.rs:10:13
+ |
+10 | __drop_inner(this);
+ | ^^^^^^^^^^^^ ---- argument unexpected
+ |
+note: function defined here
+ --> tests/ui/pinned_drop/call-drop-inner.rs:3:1
+ |
+3 | / pin_project! {
+4 | | pub struct S {
+5 | | #[pin]
+6 | | field: u8,
+... |
+12 | | }
+13 | | }
+ | |_^
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: remove the extra argument
+ |
+10 | __drop_inner();
+ | ~~~~~~~~~~~~~~
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs
new file mode 100644
index 0000000000..68b01b265e
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.rs
@@ -0,0 +1,26 @@
+use pin_project_lite::pin_project;
+
+// In `Drop` impl, the implementor must specify the same requirement as type definition.
+
+struct DropImpl<T> {
+ f: T,
+}
+
+impl<T: Unpin> Drop for DropImpl<T> {
+ //~^ ERROR E0367
+ fn drop(&mut self) {}
+}
+
+pin_project! {
+ //~^ ERROR E0367
+ struct PinnedDropImpl<T> {
+ #[pin]
+ f: T,
+ }
+
+ impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
+ fn drop(_this: Pin<&mut Self>) {}
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr
new file mode 100644
index 0000000000..d70009c97a
--- /dev/null
+++ b/third_party/rust/pin-project-lite/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -0,0 +1,38 @@
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:9:9
+ |
+9 | impl<T: Unpin> Drop for DropImpl<T> {
+ | ^^^^^
+ |
+note: the implementor must specify the same requirement
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:5:1
+ |
+5 | / struct DropImpl<T> {
+6 | | f: T,
+7 | | }
+ | |_^
+
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
+ |
+14 | / pin_project! {
+15 | | //~^ ERROR E0367
+16 | | struct PinnedDropImpl<T> {
+17 | | #[pin]
+... |
+23 | | }
+24 | | }
+ | |_^
+ |
+note: the implementor must specify the same requirement
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
+ |
+14 | / pin_project! {
+15 | | //~^ ERROR E0367
+16 | | struct PinnedDropImpl<T> {
+17 | | #[pin]
+... |
+23 | | }
+24 | | }
+ | |_^
+ = note: this error originates in the macro `$crate::__pin_project_make_drop_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/.cargo-checksum.json b/third_party/rust/pin-project/.cargo-checksum.json
new file mode 100644
index 0000000000..6c1292f80c
--- /dev/null
+++ b/third_party/rust/pin-project/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"783cd583703d44ea56ecaa85e6f9f6e938080cd6a272561a099ee5a763027074","Cargo.lock":"d8948b712a1218489a7fe3eb33fd81c1397d386149ec9cde56a194de10a20b99","Cargo.toml":"05d6890953de010750b9221eafa34caea69c4cc8b29105fea9242a45b943af3e","LICENSE-APACHE":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"8d2f9e35ee904ede6e124593e89456fff866a6e11408ae4733443009cf6e6710","examples/README.md":"e04e4ad8c5518aaa839b1255f9aee47877ae223053f32d83db797f607b9422b6","examples/enum-default-expanded.rs":"92414c9b48f3e280ba10994a426629da799d125d764d1b3857676b21cb42dbbd","examples/enum-default.rs":"01e1d285ffbb87aa70950c0ec184b395f7faf0667a1fc874b4de509e3e3c8d5c","examples/not_unpin-expanded.rs":"19e944c6159b6a57a19a653adb7a30d27ddc098351bd311a91ada586eb8e6ee7","examples/not_unpin.rs":"3e43439c521089f7f58a411fb823827433c7476a0b41aecd26a6ce5f0c99e405","examples/pinned_drop-expanded.rs":"6b2bb25bcb3404d1b03276be4ae3f6c768a98b5e6675a33b24bf57bff9a9cfaa","examples/pinned_drop.rs":"8913e9b0b7851d470c3f15e40930af16c79f5ee8b4a947cac8235361b427db30","examples/project_replace-expanded.rs":"0b5adc4f83b3b56febc1a721f334b5bea26ec4aea407f35f4cce5cdde76ddd30","examples/project_replace.rs":"352d10d7a2db3de0101faedd04d69c24b9bb5021c768199a379c233886a3881c","examples/struct-default-expanded.rs":"2e290064aa48e001625f3badce5fda7e2fa7a8ce613cbe1788892b1230885895","examples/struct-default.rs":"eb60ea5412e83ac9eba96794b31772afe0798bef304b26bff65b6845638bb729","examples/unsafe_unpin-expanded.rs":"71d13e6bb284642d81520fce7adf5c1e9510451295c1806a3703dae481e64ee3","examples/unsafe_unpin.rs":"7da585f423999dcbe03289a72b14a29fed41a45a774de1af2fe93cb20aa8d426","src/lib.rs":"049843fe33b262b66552a40c4f152ac3a436e7fcef5fda9f30e026f7a966e3f3","tests/README.md":"2b6cf365e06fae7dc3260504351177855d675452cc61e398a9998d5a317ae0dc","tests/auxiliary/mod.rs":"7e263e987e09b77e384f734384a00a71c5b70230bb1b5376446ef003a8da9372","tests/cfg.rs":"de3ad3baf0715163d7b941bc988d67219e9c4dfb4c9068f1c60f5214649fa6ee","tests/compiletest.rs":"60214ea535a2b671c66ea8207abe88aae10fc5cebd6b495d417af860680f2296","tests/drop_order.rs":"d87cce198587f1c2a4167b347e199496b177ced30769c51c2bea175a8d7f4445","tests/expand/default/enum.expanded.rs":"50c7e610491ad216d8dce5fac5d60aef55ea70c15c5ad92abfe738660169a004","tests/expand/default/enum.rs":"e23fac8939fd21c96afaf4b10613a1b8fbfff655f76128902c2cbe8577c13d08","tests/expand/default/struct.expanded.rs":"aa4367f0197526e83a033bd20e2ff4a339ea405a3294e6f5e4d529201d722101","tests/expand/default/struct.rs":"a0c95b1441b93b3ef346a47dc1e3d8113a6e1df90e577464d3f12a4e50654c4f","tests/expand/default/tuple_struct.expanded.rs":"68418316d12f8888f3f6880a44d7886deea00918fa8c552c0b4e16506828aaae","tests/expand/default/tuple_struct.rs":"1132f9700ef58079666f25173076a009c23c4f5e0ad80af80687a2e5958db6e9","tests/expand/multifields/enum.expanded.rs":"8b394bc3a0433d85fcb62a40c7bff874e3e74ef507af3ffe94ac8d4b0dfb4cfb","tests/expand/multifields/enum.rs":"a909ee4c44aef0d6959d46343a2927033acb665f6051f37e088367778af90c78","tests/expand/multifields/struct.expanded.rs":"8198207194fc36e71a785d0f2b4ce93ac55fd9921405e5c8fa25bb5869862989","tests/expand/multifields/struct.rs":"9f99e89352d212e3d4ed9cd6be2741ea13658267de6b557bdc8302c4902c72a9","tests/expand/multifields/tuple_struct.expanded.rs":"4ee5c4d077ef91cf1b59ca67140b39e81f92b7b4b8a5838deb6a686da776288e","tests/expand/multifields/tuple_struct.rs":"9ec0b313d829717bf7d3484428136a3012a996dbd97d3ecc8a7b0ba682e5db0b","tests/expand/naming/enum-all.expanded.rs":"c12c08a4af1e5df0c2f05999691d9d5d09eb49edf1e2dab568b14c6f91cca058","tests/expand/naming/enum-all.rs":"c46d8ff27879a26afb31d71df8ab69a871b2fd509ba90668cffaadafb7a54940","tests/expand/naming/enum-mut.expanded.rs":"9d53f0ab50f48fea30d0cf5f2a68afaf84bcbd82f4ffc5b69cc656bada8acaaa","tests/expand/naming/enum-mut.rs":"9df4e0e1fd8bec8ab471ef419be312c8e15158c7017e964a8337c3108f6c601b","tests/expand/naming/enum-none.expanded.rs":"28c0667e91a8c65fdc4fe1d80fb67398f95f47af19066e7a34ea8eb799497200","tests/expand/naming/enum-none.rs":"487f9469127b9375f53d6242062455eac38ccdaa30c168ed2ea755ad7287f02f","tests/expand/naming/enum-own.expanded.rs":"e4431665130719a66c9daf23a6c0d2e22c32800612c62995d86689bfe2773e4a","tests/expand/naming/enum-own.rs":"5bb51375842f2956cceb685511cc34a099665439310f01a5cc02a1d4264897a6","tests/expand/naming/enum-ref.expanded.rs":"54c79ddfb5b753dea46d9a22294bb8fc16a592c1a807a56839e742795ecfb3fb","tests/expand/naming/enum-ref.rs":"3764e8471702f968e79f633a1a471974b7a726bcc09ce4443e0bce65194f8930","tests/expand/naming/struct-all.expanded.rs":"eb459b2c8c20c8cdb0dadff0cd47e71346c9cba327aa273c144ae118c1282408","tests/expand/naming/struct-all.rs":"a8d70a576ff5325b848d14dc8083d0967e1b3b4486fd061281484b95adade136","tests/expand/naming/struct-mut.expanded.rs":"eeeb20800f623b9d4d59678845f52c74e722fa95da3b8bb8c89def5316c390ca","tests/expand/naming/struct-mut.rs":"e793dc13594ba2836881ab2580a73d73c40299af94e24a442f704e76552ce7fb","tests/expand/naming/struct-none.expanded.rs":"aa4367f0197526e83a033bd20e2ff4a339ea405a3294e6f5e4d529201d722101","tests/expand/naming/struct-none.rs":"a0c95b1441b93b3ef346a47dc1e3d8113a6e1df90e577464d3f12a4e50654c4f","tests/expand/naming/struct-own.expanded.rs":"a20e65caf57c542384debdc056da827df93f4f62e81feb5e955378653ed135ac","tests/expand/naming/struct-own.rs":"caa714f00757980ef60640a90cba289886293320524395a753b876e3050018e1","tests/expand/naming/struct-ref.expanded.rs":"b8f5167ac189cc035f3b5b04431f43db6254991a41633eb022be9cbb72dc6054","tests/expand/naming/struct-ref.rs":"f0ce9bb2ebb0c501cce8eaa24c2657a87e58109d5bde8319e7b5d3c0bae4ad86","tests/expand/naming/tuple_struct-all.expanded.rs":"59819a99da177ee249736f76047a949077054b9fe386cdbaf27f04bb683206ec","tests/expand/naming/tuple_struct-all.rs":"a77e3d5d2409f9016bb8df7ca0387fa512d3383833c9591e64435b689d3710c7","tests/expand/naming/tuple_struct-mut.expanded.rs":"60953c678fb9e67749f3c9a7b1d67657f997ee31f1fa1e8fb5763e2810fa75f3","tests/expand/naming/tuple_struct-mut.rs":"06b87b86b6bed07ddfb96067772e9aaf9c1db2d3f871e248658593bd22c4a17c","tests/expand/naming/tuple_struct-none.expanded.rs":"68418316d12f8888f3f6880a44d7886deea00918fa8c552c0b4e16506828aaae","tests/expand/naming/tuple_struct-none.rs":"1132f9700ef58079666f25173076a009c23c4f5e0ad80af80687a2e5958db6e9","tests/expand/naming/tuple_struct-own.expanded.rs":"0450ce1b6e835e5081e87db1a1660d18ba48e887c50abd871221cb82d02e7c3f","tests/expand/naming/tuple_struct-own.rs":"89ccd509482a95e74733c767b34f5d6bc8d4128cedc911834aa28aef08e7dc8e","tests/expand/naming/tuple_struct-ref.expanded.rs":"dc23f3df735453670783dc22dcdf251d5b612c9e3e4e0e0c7b73c3797f2f84d0","tests/expand/naming/tuple_struct-ref.rs":"2718b96b3e2e6cdef7f8293719d8914e3fd81e92d272b90f019863fa19584a29","tests/expand/not_unpin/enum.expanded.rs":"0ed7206eb4f1f3beafe8009755221fe701fac4935e4554a68fd8e020c1479921","tests/expand/not_unpin/enum.rs":"60134857b6c3c2aca42e9eb2b4c6dbb9149701f115d0de30a2477395ce54fdfa","tests/expand/not_unpin/struct.expanded.rs":"3909a87394f2cd75aad16fb2d347d22e03b42474cf0143329028ded9d0177269","tests/expand/not_unpin/struct.rs":"bf7468f2b42284897648e2545cf0da92a576a748cd5b75893b85f03eb2a52ba4","tests/expand/not_unpin/tuple_struct.expanded.rs":"5c5ae5082d79457985e72e4eaf950e7704e725f10ad5b1199b5b2224104a931d","tests/expand/not_unpin/tuple_struct.rs":"a3e2c2c484699087a570b1b247ce21bc40203fad889e7c0e9737d03c7ca4bd4e","tests/expand/pinned_drop/enum.expanded.rs":"176b6e68fde40bca4f4451ee061b0405f7ced5f64f5f413cf5582dd7e423cf7c","tests/expand/pinned_drop/enum.rs":"66f98ea8a567dcdeb58838df68fcba3594aea8a959826ff54fb4493fe06c4086","tests/expand/pinned_drop/struct.expanded.rs":"2cf4b445e9b710566931817420224d48c18439feffa519db3aaf27055b75ea81","tests/expand/pinned_drop/struct.rs":"44321ea6b494149e416d413185c2d23ed9d96982d1c4f378381b18e969abc16b","tests/expand/pinned_drop/tuple_struct.expanded.rs":"33b414104988e70be0748e84fd1eb243ef8f2d577fe91e5ee407ab08792f2ad8","tests/expand/pinned_drop/tuple_struct.rs":"e0532400f0bf77be198928c120e9efd9fd1b5d34f5fc9c902eb3b778c412a83d","tests/expand/project_replace/enum.expanded.rs":"5b1d2aea1266e36ba9936460c85401b01f3dffc7d5322523e3fee82cdba764c0","tests/expand/project_replace/enum.rs":"ce2f5ddff8efd37b1b0028172fde7ee7fba4eff7622c8747cd61591d81c0f503","tests/expand/project_replace/struct.expanded.rs":"87e9382ad678c131d2708199e4ba4d9a914f19b72638ce026b5d306d930d9fbf","tests/expand/project_replace/struct.rs":"f8c2915e03b557b9f11a6ea63c971cfb19b09e3a9916ab304f0ce62626e35895","tests/expand/project_replace/tuple_struct.expanded.rs":"8e78020602b8cb911e7fbb99829629aad5fc1f41cc9b37c511783d28a5963981","tests/expand/project_replace/tuple_struct.rs":"8ca1cd1d5feadb23999d8f4e7307f91d1932fff7e8d38889d3889d6ba4d43430","tests/expand/pub/enum.expanded.rs":"7d5a811fa0141b319f2feb05de1a697a155dc12751dc214099b44460e5d24bf5","tests/expand/pub/enum.rs":"64ca05d529227157ba4cdce1c526d67d15f06108fd71f5955749d236c002471f","tests/expand/pub/struct.expanded.rs":"5ffb94d61fa6074ee1a48c095579a1255ed5ed4276e63399b25c61fe3552306c","tests/expand/pub/struct.rs":"379b8c4c01a3fc2aa3f020578a6dd836d455f4c48604e1dad91f631146b9e6ec","tests/expand/pub/tuple_struct.expanded.rs":"1a0de6c572a6db1c69fefa939335087ed9c0526045e5b09b7608364e20e3329b","tests/expand/pub/tuple_struct.rs":"77cc812220e956a2255ef129dec3b16d6973b7e8b1bc02a6f65bd9fa56040564","tests/expand/unsafe_unpin/enum.expanded.rs":"4470e2d664e4a11f3590d5cfe98437567b14ce82b2e82d652b1d2342452d459b","tests/expand/unsafe_unpin/enum.rs":"00fad3fed0f7d2d0eae56020726818ab91895d6eaed7c4c7cc5d497b5efa7cfd","tests/expand/unsafe_unpin/struct.expanded.rs":"5d5c4de9205a5fff126e2c12bd0808871605f177f6d6f54001f8a6a7d8a41b92","tests/expand/unsafe_unpin/struct.rs":"a41bed68966abb874f31ad02a860e15a2714e2e459ef73475a908e71141e96f0","tests/expand/unsafe_unpin/tuple_struct.expanded.rs":"a803bbe3090a20e0ccd5ebfa125d43b5a28fe48518556374694d9e956b3a7de7","tests/expand/unsafe_unpin/tuple_struct.rs":"bddd36be1795be2f445d7baec269ad8a5a2647b95af7f0b130331ab7a3c64baf","tests/expandtest.rs":"fe8b5e96e0fe9bc87de2e5f2c79fccb889a4eab98d90e88cd6886c94a1204ab9","tests/include/basic-safe-part.rs":"6fb5accb7476f85233ef919eedaff83c30015e186414589db6e44d614016ad3e","tests/include/basic.rs":"e030edc2573d8b365e9542e431f0c0af6d5ecf6fe9d84f13c7a8401f4c922895","tests/lint.rs":"d3cde49103f68d53d2e5c5de42263d9b8ff8920ac1b1ca24d73dd9016a93e213","tests/pin_project.rs":"f5a8c9e3964f360a0f93c549d79b0e1c4351790234bac3e3eaa59ff37a5a03c5","tests/pinned_drop.rs":"e9a41a4a2d286835a7be72f7c22edf33e1a34834121eb53e3f38af0c35ef0bb0","tests/proper_unpin.rs":"435b9c7243ab896c2546c1e402276e93ef38cd93de50cc7369f486fe22698a02","tests/repr_packed.rs":"f54a553a579dbce7f80f666f0228ec2dd2a80282ac5da5f715bb122e7e17712e","tests/ui/cfg/cfg_attr-resolve.rs":"bb924ea9ceb6579e80774ef7fee1bb99ae08efc7d909e8d1edff40c3c1adaa7f","tests/ui/cfg/cfg_attr-resolve.stderr":"720f806ac06d598753a6a90c95b942410413d8860f60a7251fbde3e1fa575934","tests/ui/cfg/cfg_attr-type-mismatch.rs":"25e8337f9fd5533799dd990df6e016d18e2a00468de3386aa7d45aa98e39a0f9","tests/ui/cfg/cfg_attr-type-mismatch.stderr":"79e2a14cc486d9c8665d89d41460ab1e1ea8edc87b01ea630affea012d067618","tests/ui/cfg/packed_sneaky-span-issue-1.rs":"768762cf1831b9b09868404d9d7fd394ed30fb4495bd8388034ee9bf3823d11b","tests/ui/cfg/packed_sneaky-span-issue-1.stderr":"235ad4c1c784e9116c480502e813a0f0254f3b0e624c89712bafa56d43eaa2c4","tests/ui/cfg/packed_sneaky-span-issue-2.rs":"229d91b2531ace7c1d644125b77ee044fc639e9b981aaede5fda6f5e38154a4d","tests/ui/cfg/packed_sneaky-span-issue-2.stderr":"dae8adcb5b6ac12be55da9f4d6d04c1a790907dc5ee23a16d86a2a370daf596a","tests/ui/cfg/packed_sneaky.rs":"785e77f597bfc0cdb7bebc040cf11b17b1e2aa727b0fc369b7fe073f8441cad0","tests/ui/cfg/packed_sneaky.stderr":"1674d0f108f91cc21f9009338bde1b343b65a68d81d6bb3b6aecd919846cc6e0","tests/ui/cfg/unsupported.rs":"45d6eddef59e67dfca3733450249632dd8135283cedafa663e7bfa2b232ca13e","tests/ui/cfg/unsupported.stderr":"72421d6c14eb7d4f7af7eea1e0701343df691985d1d58325e91412e749705d3f","tests/ui/not_unpin/conflict-unpin.rs":"5709b68bbf26c0b2b87ee7a0bbf83ae9e4f1bacd2266114114b4dcb8706d0080","tests/ui/not_unpin/conflict-unpin.stderr":"1229dde319ce4ab72609c5a906e3e002e75d8eefdbb99b610c8e00c759783c48","tests/ui/not_unpin/impl-unsafe-unpin.rs":"088374540354c4052a2daf2e97cdf49fc54287e0d943bf34bbb70298d62e8c9b","tests/ui/not_unpin/impl-unsafe-unpin.stderr":"0a60277d9c48dfbc8bf37a53d6060f0a00538954acc65929e20da9d104b52842","tests/ui/pin_project/add-attr-to-struct.rs":"975ab96e5660587eced2f4d2e133d331550ccc7db0e56fd3be6895fcfd1085a2","tests/ui/pin_project/add-attr-to-struct.stderr":"c3004aef263914c9abb43a5956058c5c0022bb9074b862b26753df3764d351fc","tests/ui/pin_project/add-pinned-field.rs":"791df5b427ba412fb25836569963e6a03ccacea9fcefa4bf3f789ee4de90762d","tests/ui/pin_project/add-pinned-field.stderr":"8478c41754c866c0662ba3d1162226f9e01c111935a0b3a9a8f976e7c9f3dbe5","tests/ui/pin_project/conflict-drop.rs":"c97bedbed751436994fec33003dca06761cc2cbf9fcc832c120321aa8fc0be7b","tests/ui/pin_project/conflict-drop.stderr":"830248bc54590be23c9ffa4e24ae4197fe72a8c2db0434064e191f9673654a67","tests/ui/pin_project/conflict-unpin.rs":"9e3b06ce53d97ebd79620d729b525fac1c87c67ed44b91d05dd4c3d48be455e3","tests/ui/pin_project/conflict-unpin.stderr":"521d31d9c2f4efe9cc0a6bf966a591e4e0da7ac6c9964c37acfb1c3b53e7b242","tests/ui/pin_project/impl-unsafe-unpin.rs":"d24d630abd82e08aea529d358bf998011ead0e939c82dca410160764fc24e06b","tests/ui/pin_project/impl-unsafe-unpin.stderr":"f2925cfa77514c4fdcd45184c39f7b1d2eb160f8b03cc59f7a9e7b9a9b867ced","tests/ui/pin_project/import_unnamed.rs":"09fb23d22c044321f9bf3a526d16d694916adb7b5defeb6a353cdaff46df7efb","tests/ui/pin_project/import_unnamed.stderr":"2358b70ea4b4c797816cf3b47920f72e0eb7ad0ff11d9d7e8f9f0faed27cbd93","tests/ui/pin_project/invalid.rs":"bbb60256e5b0b35950161935a569ae3e623e51486419170452c73c032f97ed1f","tests/ui/pin_project/invalid.stderr":"3c027a4ab513d477d4877b540a58d319159c4d20b69e643d475b0b54abac7e67","tests/ui/pin_project/overlapping_unpin_struct.rs":"3f459dda0c01e36f989a1413b2a43f4d95f9ae2524653b61f0561acff28ad9a6","tests/ui/pin_project/overlapping_unpin_struct.stderr":"80663b2f53656616e016d90cf617306671d5885a0fadb2215af9113388c3c4a6","tests/ui/pin_project/override-priv-mod.rs":"e33ac45fac3f366737364040ab967a75e6f8f3aa1c093d044380a1cc4a0096bd","tests/ui/pin_project/override-priv-mod.stderr":"a6da3ab8e3aeff94dfa27ca52be0ce00104ca319d0e70232dbd627b4dca81030","tests/ui/pin_project/packed-enum.rs":"7784ff49119daa5ae562f0fa84fdf4e65fe8abaf62ecff7d2ead184748e16b9b","tests/ui/pin_project/packed-enum.stderr":"3c710e899c68e5db4707405546c9c81b819ba6d3bdb83d3578e34c1254fbf1e3","tests/ui/pin_project/packed-name-value.rs":"64cbf4ef3c01709d302f91d98e92c980f2858b14ddaf047646c4de57707541b1","tests/ui/pin_project/packed-name-value.stderr":"f8beabf2de5cdd913903eed642d886841ad14a719f562769f525c79a5df2fc76","tests/ui/pin_project/packed.rs":"7a66b7c2ca8253cfd6774a339d74400966e85c73ef59f54ad66d9f1b02ea5db7","tests/ui/pin_project/packed.stderr":"2b9e7a0818e21f958536738035452d760b9fbd3784d2034b1732d2c8d4b85812","tests/ui/pin_project/packed_sneaky-1.rs":"390dd0ad59668f80a6e86baed1015c02a429cecc92388f18c8deffb500508415","tests/ui/pin_project/packed_sneaky-1.stderr":"f01979f02e3a0956fc191550cfe364ea11a14afb15cc252e63127ab72f99f640","tests/ui/pin_project/packed_sneaky-2.rs":"f1601aa4f642ed4aaaab2dd2e0328b7af145be9a3a7460ad36339b47b4d7ce14","tests/ui/pin_project/packed_sneaky-2.stderr":"5df9f0c90032016856c4797f07c8e8c172ed0ded2c7078c404f80b5be675d33a","tests/ui/pin_project/packed_sneaky-3.rs":"d9ee3366b5e3849f3ec0d0bd62d365cff0c6e8f0eb3434d70fb84e62a1976eb2","tests/ui/pin_project/packed_sneaky-3.stderr":"15dca7e5e4e9cf2635d19c1c66c5385b9c749607a3b8ca07f56194e63e662a22","tests/ui/pin_project/packed_sneaky-4.rs":"e8ba439007d3d290d7cd9cc080a4fb0e8a8bd16fe7660486287318b8067ad61e","tests/ui/pin_project/packed_sneaky-4.stderr":"5dd7ddef2b3c33585cd88f61155daf566d0ad69aa7eb223d2bafbf05ecf69727","tests/ui/pin_project/private_in_public-enum.rs":"79a6ac31dc36cdf4a72c464d4f2702570724b3d33fe22e5b6c05c69129ea4458","tests/ui/pin_project/private_in_public-enum.stderr":"d951fb2b9b80ff07848723439da190cb91f776fbef0e27db025dcd24186f80aa","tests/ui/pin_project/project_replace_unsized.rs":"7c35e6c8ebf8337b6abf6a7fa7106bd519cebbe32d3f33b8865fa251820e0e5a","tests/ui/pin_project/project_replace_unsized.stderr":"4ad5e9da11cd6db57e1fdce710e7aa410edf295d6d48c48ced827a4d04b1eac5","tests/ui/pin_project/project_replace_unsized_fn_params.rs":"db7c72e96119f245535627b887c1289b064dd657fbb524c0f6635287033b85e2","tests/ui/pin_project/project_replace_unsized_fn_params.stderr":"ec9ccd7fbe19de97e218e98a6968254092feeb33434f41093429f1f46bf1ec40","tests/ui/pin_project/remove-attr-from-field.rs":"9faac7ca8220c7069b1a7b2f43420efd3d73377f0ac0558ef67cd5664a9c54c1","tests/ui/pin_project/remove-attr-from-field.stderr":"bedbeba9a7fdb49ffcbe55ad1fc8893cba4e46a6415ccbdd4c68f1fa28854b19","tests/ui/pin_project/remove-attr-from-struct.rs":"f47a6cfbb5a4fa5bb233c0427be255110749621bed7cfa7a8f45e80451aa8615","tests/ui/pin_project/remove-attr-from-struct.stderr":"72813d275cc89198d1808d1dbc427d0e7c2d79eb45c8b9941297fbdf32ab2296","tests/ui/pin_project/safe_packed_borrows.rs":"313d671d4d6ad74afd4e3ef0eee62bc7c6d3fa9e28a26d09a9c2ba0ccb5eb902","tests/ui/pin_project/safe_packed_borrows.stderr":"f56c3357538b202de22e14366a3054407541496eb08a2df6bf11dadb93b5373a","tests/ui/pin_project/unaligned_references.rs":"a7e7949b01787e7584448f1f6b90a817473c02cb3c5bac2b725dbfa77de3d4b1","tests/ui/pin_project/unaligned_references.stderr":"e928dbc6ed3aa15d6be261b3c32ccec5585721c39285d0f55ddcc912fed92567","tests/ui/pin_project/unpin_sneaky.rs":"8d49b2dcb1695b4ae26669de58dd6dc73bd836f3cd836078d6be2a0ac2cc56f3","tests/ui/pin_project/unpin_sneaky.stderr":"b31b54cb2be5a9cecd50c4489847ec83bb401daa63c2f5b6ebd4080efc95bd67","tests/ui/pin_project/visibility.rs":"4345aa1fd270a99e631510097ab7fea51aa7cbe15e155cf19f406c63735e3daa","tests/ui/pin_project/visibility.stderr":"9d56584accaad71c65e38823b0200b8ee229c027558f4461168c869ac53655b2","tests/ui/pinned_drop/call-drop-inner.rs":"a155a5b4cf7434ad6c2c4f217beb37b57edae74c5ae809627a50ea8d6ab5da50","tests/ui/pinned_drop/call-drop-inner.stderr":"f991ee86c6e98bcb914f37ceacc0e2ca4f37306175949a90cdcd248088267ca3","tests/ui/pinned_drop/conditional-drop-impl.rs":"5d4c147d48d87a306fa875e033c4962ecd9d7666e6859da5b22a34fd552f0fc6","tests/ui/pinned_drop/conditional-drop-impl.stderr":"c6f29508d31ec2dc78139974fb37a7f0fc218bdc4361deba8882f42aa0bc3c25","tests/ui/pinned_drop/forget-pinned-drop-impl.rs":"9a6d08c98f1214d11aac8bbf67586130ad62d07d03f4ba6aae474fe30695b536","tests/ui/pinned_drop/forget-pinned-drop-impl.stderr":"d45a218e8107ad11a59a75f30bbb2a018e153ecdead28880b09cf63f3d64f98f","tests/ui/pinned_drop/invalid-self.rs":"9c7e431b0808204d6a3bf3541668655cb72c76e8ebe8f4a04518d0c6dcdd1bd5","tests/ui/pinned_drop/invalid-self.stderr":"a2004c3f04e13bbc17446e751acb1b3985f5a6bfeb846e1b8a661951e40adb12","tests/ui/pinned_drop/invalid.rs":"881a93cfdcaeeb807314a28eea41be26e5476835467237b63e9fe2cbad52e574","tests/ui/pinned_drop/invalid.stderr":"f66265c3d0d251df73b7f678b46ae07bb10fed05ff2c7178e14af63e4b3e986f","tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs":"cc406f6ffa1998896931d33cfdab79466a1494750b55519f5a8ad7fe13e08657","tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr":"7b9e301cf51d37a0cbd39228cbea3450b0ef68497f7d0d276694313b7f7045d7","tests/ui/pinned_drop/self.rs":"db7da7c136a16c34b0492dbaeed680cdf0a1bdeb186b2d4a1324dd11b43bbe2b","tests/ui/pinned_drop/self.stderr":"9ceb8aad5a81981330c1512702525b1f4fa4dbe53c40862db0518bb41dbe954f","tests/ui/pinned_drop/unsafe-call.rs":"2ecdfd7b658c0aeb85ff0feed8d6c1776a06166c287d3b8925f7fc4c699ee74a","tests/ui/pinned_drop/unsafe-call.stderr":"b92ae55c2752129fd1090539216171cd5fe4b1a693dfe1c770dc285a880cb121","tests/ui/unsafe_unpin/conflict-unpin.rs":"a22831379eb1f2d597d5f8088130f7c91add5ec69bade962d555d1b49145f56a","tests/ui/unsafe_unpin/conflict-unpin.stderr":"d5bd3f04d069d30491244e03e8520c05c71ec7bc3b9e2fdec8dc1c8e5a3d8d8f","tests/ui/unstable-features/README.md":"f9dcf95e9c68fe15345f493a3fb4f54726d36c76d1a5a1e2c9dfa25540d4b642","tests/ui/unstable-features/marker_trait_attr-feature-gate.rs":"35596063ddbc8a289182c3a18d98d595583e6a0b2b3324d3eec4f416de06ea4b","tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr":"9e22be3282c29e976ae39f48b6bd866ef6fb45694867800991d445dc1cecb8ca","tests/ui/unstable-features/marker_trait_attr.rs":"f2a5275a5b80249d2a0e7a4e9e7d3f573ffd5f2a183dfced314e91a7d7945007","tests/ui/unstable-features/marker_trait_attr.stderr":"fbfd1b4f4a4daed395da86d31c5f305eaa026d111df2cd2a62fa2ed66ebf7b67","tests/ui/unstable-features/negative_impls.rs":"b913f3d818cc4d91efe4b82dd08b72acff89b97d7e56a33d8106c93f1de6a81d","tests/ui/unstable-features/negative_impls.stderr":"8af35392f3db6ed3e326f03ea9e9050138b59ea559ab92760a3c12db208c2805","tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs":"dc6b854cc60ea03344f8ca3fa518a2bdc0b9aa69f2368162f4b6ad24d31bc4f0","tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr":"9d4e7b12b19fafb2eb0b924c924ce563d99f6b787ed7663b4a2e66e6e9d3e1b6","tests/ui/unstable-features/overlapping_marker_traits.rs":"8af0d8a5afe9dcaa02fa67b394d376f9933cc99361d68f64185769326700bf7c","tests/ui/unstable-features/overlapping_marker_traits.stderr":"ed49c06dcdc05160b9cf8bdc450b27d3bb981c96e271cda1fa977d205ef5b0c8","tests/ui/unstable-features/trivial_bounds-feature-gate.rs":"658aab9de2e52a54b9e4731faae6a87172b1b4b78f3853c9fd4b565066b74e64","tests/ui/unstable-features/trivial_bounds-feature-gate.stderr":"f95c11b531c1d2bc9d7a7d64d70bc62217608498ed468ed6cc6acd03d70205ca","tests/ui/unstable-features/trivial_bounds.rs":"b12e91f4f24b841bb83b4831849795999a2095b25ab62c8966948ed03da3d327","tests/ui/unstable-features/trivial_bounds.stderr":"96d4f84e3a14064a495a57e32fe31b1c3fc819253a95c83b2a2e5ae48bd4fdc3","tests/unsafe_unpin.rs":"5ec1a97b7a54fe1cdc72f8e2c71ea8101caa0426d286532946c324be4eabead8"},"package":"ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"} \ No newline at end of file
diff --git a/third_party/rust/pin-project/CHANGELOG.md b/third_party/rust/pin-project/CHANGELOG.md
new file mode 100644
index 0000000000..76e245fa05
--- /dev/null
+++ b/third_party/rust/pin-project/CHANGELOG.md
@@ -0,0 +1,758 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+This project adheres to [Semantic Versioning](https://semver.org).
+
+<!--
+Note: In this file, do not use the hard wrap in the middle of a sentence for compatibility with GitHub comment style markdown rendering.
+-->
+
+## [Unreleased]
+
+## [1.0.12] - 2022-08-15
+
+- Suppress `unused_tuple_struct_fields` lint in generated code.
+
+## [1.0.11] - 2022-07-02
+
+- [Suppress `dead_code` lint in generated code.](https://github.com/taiki-e/pin-project/pull/346)
+
+## [1.0.10] - 2021-12-31
+
+- Revert the increase of the minimal version of `syn` that was done in 1.0.9.
+
+## [1.0.9] - 2021-12-26
+
+- [Prevent abuse of private module.](https://github.com/taiki-e/pin-project/pull/336)
+
+- Update minimal version of `syn` to 1.0.84.
+
+## [1.0.8] - 2021-07-21
+
+- [Suppress `clippy::use_self` and `clippy::type_repetition_in_bounds` lints in generated code.](https://github.com/taiki-e/pin-project/pull/331)
+
+## [1.0.7] - 2021-04-16
+
+- [Fix compile error when using `self::` as prefix of path inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/326)
+
+## [1.0.6] - 2021-03-25
+
+- [Suppress `clippy::semicolon_if_nothing_returned` lint in generated code.](https://github.com/taiki-e/pin-project/pull/318)
+
+## [1.0.5] - 2021-02-03
+
+- [Suppress `deprecated` lint in generated code.](https://github.com/taiki-e/pin-project/pull/313)
+
+## [1.0.4] - 2021-01-09
+
+- [Suppress `clippy::ref_option_ref` lint in generated code.](https://github.com/taiki-e/pin-project/pull/308)
+
+## [1.0.3] - 2021-01-05
+
+- Exclude unneeded files from crates.io.
+
+## [1.0.2] - 2020-11-18
+
+- [Suppress `clippy::unknown_clippy_lints` lint in generated code.](https://github.com/taiki-e/pin-project/pull/303)
+
+## [1.0.1] - 2020-10-15
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/commit/ddcd88079ba2d82857c365f2a3543ad146ade54c).
+
+- [Fix warnings when `#[pin_project]` attribute used within `macro_rules!` macros.](https://github.com/taiki-e/pin-project/pull/298)
+
+## [1.0.0] - 2020-10-13
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/commit/ddcd88079ba2d82857c365f2a3543ad146ade54c).
+
+- [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
+
+ Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
+
+ ```diff
+ - #[pin_project]
+ + #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ - #[project]
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ - #[project]
+ match x.project() {
+ - Enum::Variant(_) => { /* ... */ }
+ + EnumProj::Variant(_) => { /* ... */ }
+ }
+ }
+ ```
+
+- [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
+
+- [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
+
+- [Raise the minimum supported Rust version of this crate from Rust 1.34 to Rust 1.37.](https://github.com/taiki-e/pin-project/pull/292)
+
+- Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, `clippy::implicit_return`, and `clippy::redundant_pub_crate` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277), [#284](https://github.com/taiki-e/pin-project/pull/284))
+
+- Diagnostic improvements.
+
+Changes since the 1.0.0-alpha.1 release:
+
+- [Fix drop order of pinned fields in `project_replace`.](https://github.com/taiki-e/pin-project/pull/287)
+
+- Update minimal version of `syn` to 1.0.44.
+
+## [1.0.0-alpha.1] - 2020-09-22
+
+- [Remove deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes.](https://github.com/taiki-e/pin-project/pull/265)
+
+ Name the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead:
+
+ ```diff
+ - #[pin_project]
+ + #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ - #[project]
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ - #[project]
+ match x.project() {
+ - Enum::Variant(_) => { /* ... */ }
+ + EnumProj::Variant(_) => { /* ... */ }
+ }
+ }
+ ```
+
+- [Remove deprecated `Replace` argument from `#[pin_project]` attribute.](https://github.com/taiki-e/pin-project/pull/266) Use `project_replace` argument instead.
+
+- [Optimize code generation when used on enums.](https://github.com/taiki-e/pin-project/pull/270)
+
+- Suppress `explicit_outlives_requirements`, `box_pointers`, `clippy::large_enum_variant`, `clippy::pattern_type_mismatch`, and `clippy::implicit_return` lints in generated code. ([#276](https://github.com/taiki-e/pin-project/pull/276), [#277](https://github.com/taiki-e/pin-project/pull/277))
+
+- Diagnostic improvements.
+
+See also [tracking issue for 1.0 release](https://github.com/taiki-e/pin-project/issues/264).
+
+## [0.4.30] - 2022-07-02
+
+- [Suppress `dead_code` lint in generated code.](https://github.com/taiki-e/pin-project/pull/347)
+
+## [0.4.29] - 2021-12-26
+
+- [Fix compile error with `syn` 1.0.84 and later.](https://github.com/taiki-e/pin-project/pull/335)
+
+## [0.4.28] - 2021-03-28
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix `unused_must_use` warning on unused borrows, which will be added to rustc in the future.](https://github.com/taiki-e/pin-project/pull/322) See [#322](https://github.com/taiki-e/pin-project/pull/322) for more details.
+
+ (Note: 1.0 does not have this problem.)
+
+## [0.4.27] - 2020-10-11
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- Update minimal version of `syn` to 1.0.44.
+
+## [0.4.26] - 2020-10-04
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix drop order of pinned fields in `project_replace`.](https://github.com/taiki-e/pin-project/pull/287)
+
+## [0.4.25] - 2020-10-01
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Suppress `drop_bounds` lint, which will be added to rustc in the future.](https://github.com/taiki-e/pin-project/pull/273) See [#272](https://github.com/taiki-e/pin-project/issues/272) for more details.
+
+ (Note: 1.0.0-alpha.1 already contains this change.)
+
+## [0.4.24] - 2020-09-26
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix compatibility of generated code with `forbid(future_incompatible)`.](https://github.com/taiki-e/pin-project/pull/282)
+
+ Note: This does not guarantee compatibility with `forbid(future_incompatible)` in the future.
+ If rustc adds a new lint, we may not be able to keep this.
+
+## [0.4.23] - 2020-07-27
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix compile error with `?Sized` type parameters.](https://github.com/taiki-e/pin-project/pull/263)
+
+## [0.4.22] - 2020-06-14
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- Documentation improvements.
+
+## [0.4.21] - 2020-06-13
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Deprecated `#[project]`, `#[project_ref]`, and `#[project_replace]` attributes due to some unfixable limitations.](https://github.com/taiki-e/pin-project/pull/244)
+
+ Consider naming the projected type by passing an argument with the same name as the method to the `#[pin_project]` attribute instead.
+
+ ```rust
+ #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ match x.project() {
+ EnumProj::Variant(y) => {
+ let _: Pin<&mut T> = y;
+ }
+ }
+ }
+ ```
+
+ See [#225](https://github.com/taiki-e/pin-project/pull/225) for more details.
+
+- [Support `Self` in fields and generics in type definitions.](https://github.com/taiki-e/pin-project/pull/245)
+
+- [Fix errors involving *"`self` value is a keyword only available in methods with `self` parameter"* in apparently correct code.](https://github.com/taiki-e/pin-project/pull/250)
+
+- Diagnostic improvements.
+
+## [0.4.20] - 2020-06-07
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [You can now use `project_replace` argument without Replace argument.](https://github.com/taiki-e/pin-project/pull/243)
+ This used to require you to specify both.
+
+ ```diff
+ - #[pin_project(Replace, project_replace = EnumProjOwn)]
+ + #[pin_project(project_replace = EnumProjOwn)]
+ enum Enum<T> {
+ Variant(#[pin] T)
+ }
+ ```
+
+- [Make `project_replace` argument an alias for `Replace` argument so that it can be used without a value.](https://github.com/taiki-e/pin-project/pull/243)
+
+ ```rust
+ #[pin_project(project_replace)]
+ enum Enum<T> {
+ Variant(#[pin] T)
+ }
+ ```
+
+ *The `Replace` argument will be deprecated in the future.*
+
+- [Suppress `unreachable_pub` lint in generated code.](https://github.com/taiki-e/pin-project/pull/240)
+
+## [0.4.19] - 2020-06-04
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Suppress `unused_results` lint in generated code.](https://github.com/taiki-e/pin-project/pull/239)
+
+## [0.4.18] - 2020-06-04
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Support `Self` in more syntax positions inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/230)
+
+- [Suppress `clippy::type_repetition_in_bounds` and `clippy::used_underscore_binding` lints in generated code.](https://github.com/taiki-e/pin-project/pull/233)
+
+- Documentation improvements.
+
+- Diagnostic improvements.
+
+## [0.4.17] - 2020-05-18
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Support naming the projection types.](https://github.com/taiki-e/pin-project/pull/202)
+
+ By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:
+
+ ```rust
+ #[pin_project(project = EnumProj)]
+ enum Enum<T> {
+ Variant(#[pin] T),
+ }
+
+ fn func<T>(x: Pin<&mut Enum<T>>) {
+ match x.project() {
+ EnumProj::Variant(y) => {
+ let _: Pin<&mut T> = y;
+ }
+ }
+ }
+ ```
+
+## [0.4.16] - 2020-05-11
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix an issue that users can call internal function generated by `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/223)
+
+## [0.4.15] - 2020-05-10
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [`#[project]` attribute can now handle all `project*` attributes in that scope with one wrapper attribute.](https://github.com/taiki-e/pin-project/pull/220)
+
+## [0.4.14] - 2020-05-09
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Add `!Unpin` option to `#[pin_project]` attribute for guarantee the type is `!Unpin`.](https://github.com/taiki-e/pin-project/pull/219)
+
+ ```rust
+ #[pin_project(!Unpin)]
+ struct Struct<T, U> {
+ field: T,
+ }
+ ```
+
+ This is equivalent to use `#[pin]` attribute for `PhantomPinned` field.
+
+ ```rust
+ #[pin_project]
+ struct Struct<T, U> {
+ field: T,
+ #[pin] // Note that using `PhantomPinned` without `#[pin]` attribute has no effect.
+ _pin: PhantomPinned,
+ }
+ ```
+
+ *[Note: This raises the minimum supported Rust version of this crate from Rust 1.33 to Rust 1.34.](https://github.com/taiki-e/pin-project/pull/219#pullrequestreview-408644187)*
+
+- [Fix an issue where duplicate `#[project]` attributes were ignored.](https://github.com/taiki-e/pin-project/pull/218)
+
+- [Suppress `single_use_lifetimes` lint in generated code.](https://github.com/taiki-e/pin-project/pull/217)
+
+- [Support overlapping lifetime names in HRTB.](https://github.com/taiki-e/pin-project/pull/217)
+
+- [Hide generated items from --document-private-items.](https://github.com/taiki-e/pin-project/pull/211) See [#211](https://github.com/taiki-e/pin-project/pull/211) for details.
+
+- Documentation improvements.
+
+## [0.4.13] - 2020-05-07
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix a regression in 0.4.11.](https://github.com/taiki-e/pin-project/pull/207)
+
+ Changes from [0.4.10](https://github.com/taiki-e/pin-project/releases/tag/v0.4.10) and [0.4.12](https://github.com/taiki-e/pin-project/releases/tag/v0.4.12):
+
+ - [Fix an issue that `#[project]` on non-statement expression does not work without unstable features.](https://github.com/taiki-e/pin-project/pull/197)
+
+ - [Support overwriting the name of core crate.](https://github.com/taiki-e/pin-project/pull/199)
+
+ - [Suppress `clippy::needless_pass_by_value` lint in generated code of `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/200)
+
+ - Documentation improvements.
+
+ - Diagnostic improvements.
+
+## [0.4.12] - 2020-05-07
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- A release to avoid [a regression in 0.4.11](https://github.com/taiki-e/pin-project/issues/206). No code changes from [0.4.10](https://github.com/taiki-e/pin-project/releases/tag/v0.4.10).
+
+## [0.4.11] - 2020-05-07
+
+**Note:** This release has been yanked. See [#206](https://github.com/taiki-e/pin-project/issues/206) for details.
+
+- [Fix an issue that `#[project]` on non-statement expression does not work without unstable features.](https://github.com/taiki-e/pin-project/pull/197)
+
+- [Support overwriting the name of core crate.](https://github.com/taiki-e/pin-project/pull/199)
+
+- [Suppress `clippy::needless_pass_by_value` lint in generated code of `#[pinned_drop]`.](https://github.com/taiki-e/pin-project/pull/200)
+
+- Documentation improvements.
+
+- Diagnostic improvements.
+
+## [0.4.10] - 2020-05-04
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Add `project_replace` method and `#[project_replace]` attribute.](https://github.com/taiki-e/pin-project/pull/194)
+ `project_replace` method is optional and can be enabled by passing the `Replace` argument to `#[pin_project]` attribute.
+ See [the documentation](https://docs.rs/pin-project/0.4/pin_project/attr.pin_project.html#project_replace) for more details.
+
+- [Support `Self` and `self` in more syntax positions inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/190)
+
+- [Hide all generated items except for projected types from calling code.](https://github.com/taiki-e/pin-project/pull/192) See [#192](https://github.com/taiki-e/pin-project/pull/192) for details.
+
+## [0.4.9] - 2020-04-14
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix lifetime inference error when associated types are used in fields.](https://github.com/taiki-e/pin-project/pull/188)
+
+- [Fix compile error with tuple structs with `where` clauses.](https://github.com/taiki-e/pin-project/pull/186)
+
+- [`#[project]` attribute can now be used for `if let` expressions.](https://github.com/taiki-e/pin-project/pull/181)
+
+## [0.4.8] - 2020-01-27
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Ensure that users cannot implement `PinnedDrop` without proper attribute argument.](https://github.com/taiki-e/pin-project/pull/180)
+
+- [Fix use of `Self` in expression position inside `#[pinned_drop]` impl.](https://github.com/taiki-e/pin-project/pull/177)
+
+## [0.4.7] - 2020-01-20
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix support for lifetime bounds.](https://github.com/taiki-e/pin-project/pull/176)
+
+## [0.4.6] - 2019-11-20
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix compile error when there is `Self` in the where clause.](https://github.com/taiki-e/pin-project/pull/169)
+
+## [0.4.5] - 2019-10-21
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix compile error with `dyn` types.](https://github.com/taiki-e/pin-project/pull/158)
+
+## [0.4.4] - 2019-10-17
+
+**Note:** This release has been yanked because it [failed to compile with syn 1.0.84 and later](https://github.com/taiki-e/pin-project/pull/335).
+
+- [Fix an issue where `PinnedDrop` implementations can call unsafe code without an unsafe block.](https://github.com/taiki-e/pin-project/pull/149)
+
+## [0.4.3] - 2019-10-15
+
+**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
+
+- [`#[pin_project]` can now interoperate with `#[cfg_attr()]`.](https://github.com/taiki-e/pin-project/pull/135)
+
+- [`#[pin_project]` can now interoperate with `#[cfg()]` on tuple structs and tuple variants.](https://github.com/taiki-e/pin-project/pull/135)
+
+- [Fix support for DSTs(Dynamically Sized Types) on `#[pin_project(UnsafeUnpin)]`](https://github.com/taiki-e/pin-project/pull/120)
+
+- Diagnostic improvements.
+
+## [0.4.2] - 2019-09-29
+
+**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
+
+- [Fix support for DSTs(Dynamically Sized Types).](https://github.com/taiki-e/pin-project/pull/113)
+
+## [0.4.1] - 2019-09-26
+
+**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
+
+- [Fix an issue that caused an error when using `#[pin_project]` on a type that has `#[pin]` + `!Unpin` field with no generics or lifetime.](https://github.com/taiki-e/pin-project/pull/111)
+
+## [0.4.0] - 2019-09-25
+
+**Note:** This release has been yanked. See [#148](https://github.com/taiki-e/pin-project/pull/148) for details.
+
+- [**Pin projection has become a safe operation.**](https://github.com/taiki-e/pin-project/pull/18) In the absence of other unsafe code that you write, it is impossible to cause undefined behavior.
+
+- `#[unsafe_project]` attribute has been replaced with `#[pin_project]` attribute. ([#18](https://github.com/taiki-e/pin-project/pull/18), [#33](https://github.com/taiki-e/pin-project/pull/33))
+
+- [The `Unpin` argument has been removed - an `Unpin` impl is now generated by default.](https://github.com/taiki-e/pin-project/pull/18)
+
+- Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl. ([#18](https://github.com/taiki-e/pin-project/pull/18), [#33](https://github.com/taiki-e/pin-project/pull/33), [#86](https://github.com/taiki-e/pin-project/pull/86))
+
+- [`Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait.](https://github.com/taiki-e/pin-project/pull/18)
+
+- [`#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type.](https://github.com/taiki-e/pin-project/pull/96)
+
+- [`#[pin_project]` can now be used for public type with private field types.](https://github.com/taiki-e/pin-project/pull/53)
+
+- [`#[pin_project]` can now interoperate with `#[cfg()]`.](https://github.com/taiki-e/pin-project/pull/77)
+
+- [Add `project_ref` method to `#[pin_project]` types.](https://github.com/taiki-e/pin-project/pull/93)
+
+- [Add `#[project_ref]` attribute.](https://github.com/taiki-e/pin-project/pull/93)
+
+- [Remove "project_attr" feature and always enable `#[project]` attribute.](https://github.com/taiki-e/pin-project/pull/94)
+
+- [`#[project]` attribute can now be used for `impl` blocks.](https://github.com/taiki-e/pin-project/pull/46)
+
+- [`#[project]` attribute can now be used for `use` statements.](https://github.com/taiki-e/pin-project/pull/85)
+
+- [`#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions.](https://github.com/taiki-e/pin-project/pull/51)
+
+Changes since the 0.4.0-beta.1 release:
+
+- [Fix an issue that caused an error when using `#[pin_project(UnsafeUnpin)]` and not providing a manual `UnsafeUnpin` implementation on a type with no generics or lifetime.](https://github.com/taiki-e/pin-project/pull/107)
+
+## [0.4.0-beta.1] - 2019-09-21
+
+- [Change the argument type of project method back to `self: Pin<&mut Self>`.](https://github.com/taiki-e/pin-project/pull/90)
+
+- [Remove "project_attr" feature and always enable `#[project]` attribute.](https://github.com/taiki-e/pin-project/pull/94)
+
+- [Remove "renamed" feature.](https://github.com/taiki-e/pin-project/pull/100)
+
+- [`#[project]` attribute can now be used for `use` statements.](https://github.com/taiki-e/pin-project/pull/85)
+
+- [Add `project_ref` method and `#[project_ref]` attribute.](https://github.com/taiki-e/pin-project/pull/93)
+
+- [`#[pin_project]` attribute now determines the visibility of the projection type/method is based on the original type.](https://github.com/taiki-e/pin-project/pull/96)
+
+## [0.4.0-alpha.11] - 2019-09-11
+
+- [Change #[pinned_drop] to trait implementation.](https://github.com/taiki-e/pin-project/pull/86)
+
+ ```rust
+ #[pinned_drop]
+ impl<T> PinnedDrop for Foo<'_, T> {
+ fn drop(mut self: Pin<&mut Self>) {
+ **self.project().was_dropped = true;
+ }
+ }
+ ```
+
+- Add some examples and generated code.
+
+- Diagnostic improvements.
+
+## [0.4.0-alpha.10] - 2019-09-07
+
+- [`#[pin_project]` can now interoperate with `#[cfg()]`.](https://github.com/taiki-e/pin-project/pull/77)
+
+- Documentation improvements.
+
+## [0.4.0-alpha.9] - 2019-09-05
+
+- [Add `project_into` method to `#[pin_project]` types](https://github.com/taiki-e/pin-project/pull/69). This can be useful when returning a pin projection from a method.
+
+ ```rust
+ fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
+ self.project_into().pinned
+ }
+ ```
+
+- [Prevent `UnpinStruct` from appearing in the document by default.](https://github.com/taiki-e/pin-project/pull/71) See [#71](https://github.com/taiki-e/pin-project/pull/71) for more details.
+
+## [0.4.0-alpha.8] - 2019-09-03
+
+- [Improve document of generated code.](https://github.com/taiki-e/pin-project/pull/62). Also added an option to control the document of generated code. See [#62](https://github.com/taiki-e/pin-project/pull/62) for more details.
+
+- [Diagnostic improvements.](https://github.com/taiki-e/pin-project/pull/61)
+
+## [0.4.0-alpha.7] - 2019-09-02
+
+- [Suppress `dead_code` lint in generated types.](https://github.com/taiki-e/pin-project/pull/57)
+
+## [0.4.0-alpha.6] - 2019-09-01
+
+- [Allow using `#[pin_project]` type with private field types](https://github.com/taiki-e/pin-project/pull/53)
+
+## [0.4.0-alpha.5] - 2019-08-24
+
+- [`#[project]` attribute now supports `match` expressions at the position of the initializer expression of `let` expressions.](https://github.com/taiki-e/pin-project/pull/51)
+
+## [0.4.0-alpha.4] - 2019-08-23
+
+- Suppress `clippy::drop_bounds` lint in generated code.
+
+## [0.4.0-alpha.3] - 2019-08-23
+
+- [Change `project` method generated by `#[pin_project]` attribute to take an `&mut Pin<&mut Self>` argument.](https://github.com/taiki-e/pin-project/pull/47)
+
+- [`#[project]` attribute can now be used for impl blocks.](https://github.com/taiki-e/pin-project/pull/46)
+
+- [`#[pin_project]` attribute can now detect that the type used does not have its own drop implementation without actually implementing drop.](https://github.com/taiki-e/pin-project/pull/48) This removed some restrictions.
+
+## [0.4.0-alpha.2] - 2019-08-13
+
+- Update `proc-macro2`, `syn`, and `quote` to 1.0.
+
+## [0.4.0-alpha.1] - 2019-08-11
+
+- **Pin projection has become a safe operation.**
+
+- `#[unsafe_project]` has been replaced with `#[pin_project]`.
+
+- The `Unpin` argument has been removed - an `Unpin` impl is now generated by default.
+
+- Drop impls must be specified with `#[pinned_drop]` instead of via a normal `Drop` impl.
+
+- `Unpin` impls must be specified with an impl of `UnsafeUnpin`, instead of implementing the normal `Unpin` trait.
+
+- Make `#[project]` attribute disabled by default.
+
+See also [tracking issue for 0.4 release](https://github.com/taiki-e/pin-project/issues/21).
+
+## [0.3.5] - 2019-08-14
+
+- Update `proc-macro2`, `syn`, and `quote` to 1.0.
+
+## [0.3.4] - 2019-07-21
+
+- Diagnostic improvements.
+
+## [0.3.3] - 2019-07-15
+
+**Note:** This release has been yanked. See [#16](https://github.com/taiki-e/pin-project/issues/16) for details.
+
+- Diagnostic improvements.
+
+## [0.3.2] - 2019-03-30
+
+- Avoid suffixes on tuple index.
+
+## [0.3.1] - 2019-03-02
+
+- Documentation improvements.
+
+- Update minimum `syn` version to 0.15.22.
+
+## [0.3.0] - 2019-02-20
+
+- Remove `unsafe_fields` attribute.
+
+- Remove `unsafe_variants` attribute.
+
+## [0.2.2] - 2019-02-20
+
+- Fix a bug that generates incorrect code for the some structures with trait bounds on type generics.
+
+## [0.2.1] - 2019-02-20
+
+- Fix a bug that generates incorrect code for the structures with where clause and associated type fields.
+
+## [0.2.0] - 2019-02-11
+
+- Make `unsafe_fields` optional.
+
+- Documentation improvements.
+
+## [0.1.8] - 2019-02-02
+
+- Add the feature to create projected enums to `unsafe_project`.
+
+- Add `project` attribute to support pattern matching.
+
+## [0.1.7] - 2019-01-19
+
+- Fix documentation.
+
+## [0.1.6] - 2019-01-19
+
+- `unsafe_fields` can now opt-out.
+
+- Add `unsafe_variants` attribute. This attribute is available if pin-project is built with the "unsafe_variants" feature.
+
+## [0.1.5] - 2019-01-17
+
+- Add support for tuple struct to `unsafe_project`.
+
+## [0.1.4] - 2019-01-12
+
+- Add options for automatically implementing `Unpin` to both `unsafe_project` and `unsafe_fields`.
+
+## [0.1.3] - 2019-01-11
+
+- Fix dependencies.
+
+- Add `unsafe_fields` attribute.
+
+## [0.1.2] - 2019-01-09
+
+- Documentation improvements.
+
+## [0.1.1] - 2019-01-08
+
+- Rename from `unsafe_pin_project` to `unsafe_project`.
+
+## [0.1.0] - 2019-01-08
+
+**Note:** This release has been yanked.
+
+Initial release
+
+[Unreleased]: https://github.com/taiki-e/pin-project/compare/v1.0.12...HEAD
+[1.0.12]: https://github.com/taiki-e/pin-project/compare/v1.0.11...v1.0.12
+[1.0.11]: https://github.com/taiki-e/pin-project/compare/v1.0.10...v1.0.11
+[1.0.10]: https://github.com/taiki-e/pin-project/compare/v1.0.9...v1.0.10
+[1.0.9]: https://github.com/taiki-e/pin-project/compare/v1.0.8...v1.0.9
+[1.0.8]: https://github.com/taiki-e/pin-project/compare/v1.0.7...v1.0.8
+[1.0.7]: https://github.com/taiki-e/pin-project/compare/v1.0.6...v1.0.7
+[1.0.6]: https://github.com/taiki-e/pin-project/compare/v1.0.5...v1.0.6
+[1.0.5]: https://github.com/taiki-e/pin-project/compare/v1.0.4...v1.0.5
+[1.0.4]: https://github.com/taiki-e/pin-project/compare/v1.0.3...v1.0.4
+[1.0.3]: https://github.com/taiki-e/pin-project/compare/v1.0.2...v1.0.3
+[1.0.2]: https://github.com/taiki-e/pin-project/compare/v1.0.1...v1.0.2
+[1.0.1]: https://github.com/taiki-e/pin-project/compare/v1.0.0...v1.0.1
+[1.0.0]: https://github.com/taiki-e/pin-project/compare/v1.0.0-alpha.1...v1.0.0
+[1.0.0-alpha.1]: https://github.com/taiki-e/pin-project/compare/v0.4.23...v1.0.0-alpha.1
+[0.4.30]: https://github.com/taiki-e/pin-project/compare/v0.4.29...v0.4.30
+[0.4.29]: https://github.com/taiki-e/pin-project/compare/v0.4.28...v0.4.29
+[0.4.28]: https://github.com/taiki-e/pin-project/compare/v0.4.27...v0.4.28
+[0.4.27]: https://github.com/taiki-e/pin-project/compare/v0.4.26...v0.4.27
+[0.4.26]: https://github.com/taiki-e/pin-project/compare/v0.4.25...v0.4.26
+[0.4.25]: https://github.com/taiki-e/pin-project/compare/v0.4.24...v0.4.25
+[0.4.24]: https://github.com/taiki-e/pin-project/compare/v0.4.23...v0.4.24
+[0.4.23]: https://github.com/taiki-e/pin-project/compare/v0.4.22...v0.4.23
+[0.4.22]: https://github.com/taiki-e/pin-project/compare/v0.4.21...v0.4.22
+[0.4.21]: https://github.com/taiki-e/pin-project/compare/v0.4.20...v0.4.21
+[0.4.20]: https://github.com/taiki-e/pin-project/compare/v0.4.19...v0.4.20
+[0.4.19]: https://github.com/taiki-e/pin-project/compare/v0.4.18...v0.4.19
+[0.4.18]: https://github.com/taiki-e/pin-project/compare/v0.4.17...v0.4.18
+[0.4.17]: https://github.com/taiki-e/pin-project/compare/v0.4.16...v0.4.17
+[0.4.16]: https://github.com/taiki-e/pin-project/compare/v0.4.15...v0.4.16
+[0.4.15]: https://github.com/taiki-e/pin-project/compare/v0.4.14...v0.4.15
+[0.4.14]: https://github.com/taiki-e/pin-project/compare/v0.4.13...v0.4.14
+[0.4.13]: https://github.com/taiki-e/pin-project/compare/v0.4.11...v0.4.13
+[0.4.12]: https://github.com/taiki-e/pin-project/compare/v0.4.10...v0.4.12
+[0.4.11]: https://github.com/taiki-e/pin-project/compare/v0.4.10...v0.4.11
+[0.4.10]: https://github.com/taiki-e/pin-project/compare/v0.4.9...v0.4.10
+[0.4.9]: https://github.com/taiki-e/pin-project/compare/v0.4.8...v0.4.9
+[0.4.8]: https://github.com/taiki-e/pin-project/compare/v0.4.7...v0.4.8
+[0.4.7]: https://github.com/taiki-e/pin-project/compare/v0.4.6...v0.4.7
+[0.4.6]: https://github.com/taiki-e/pin-project/compare/v0.4.5...v0.4.6
+[0.4.5]: https://github.com/taiki-e/pin-project/compare/v0.4.4...v0.4.5
+[0.4.4]: https://github.com/taiki-e/pin-project/compare/v0.4.3...v0.4.4
+[0.4.3]: https://github.com/taiki-e/pin-project/compare/v0.4.2...v0.4.3
+[0.4.2]: https://github.com/taiki-e/pin-project/compare/v0.4.1...v0.4.2
+[0.4.1]: https://github.com/taiki-e/pin-project/compare/v0.4.0...v0.4.1
+[0.4.0]: https://github.com/taiki-e/pin-project/compare/v0.4.0-beta.1...v0.4.0
+[0.4.0-beta.1]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.11...v0.4.0-beta.1
+[0.4.0-alpha.11]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.10...v0.4.0-alpha.11
+[0.4.0-alpha.10]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.9...v0.4.0-alpha.10
+[0.4.0-alpha.9]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.8...v0.4.0-alpha.9
+[0.4.0-alpha.8]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.7...v0.4.0-alpha.8
+[0.4.0-alpha.7]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.6...v0.4.0-alpha.7
+[0.4.0-alpha.6]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.5...v0.4.0-alpha.6
+[0.4.0-alpha.5]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.4...v0.4.0-alpha.5
+[0.4.0-alpha.4]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.3...v0.4.0-alpha.4
+[0.4.0-alpha.3]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.2...v0.4.0-alpha.3
+[0.4.0-alpha.2]: https://github.com/taiki-e/pin-project/compare/v0.4.0-alpha.1...v0.4.0-alpha.2
+[0.4.0-alpha.1]: https://github.com/taiki-e/pin-project/compare/v0.3.5...v0.4.0-alpha.1
+[0.3.5]: https://github.com/taiki-e/pin-project/compare/v0.3.4...v0.3.5
+[0.3.4]: https://github.com/taiki-e/pin-project/compare/v0.3.3...v0.3.4
+[0.3.3]: https://github.com/taiki-e/pin-project/compare/v0.3.2...v0.3.3
+[0.3.2]: https://github.com/taiki-e/pin-project/compare/v0.3.1...v0.3.2
+[0.3.1]: https://github.com/taiki-e/pin-project/compare/v0.3.0...v0.3.1
+[0.3.0]: https://github.com/taiki-e/pin-project/compare/v0.2.2...v0.3.0
+[0.2.2]: https://github.com/taiki-e/pin-project/compare/v0.2.1...v0.2.2
+[0.2.1]: https://github.com/taiki-e/pin-project/compare/v0.2.0...v0.2.1
+[0.2.0]: https://github.com/taiki-e/pin-project/compare/v0.1.8...v0.2.0
+[0.1.8]: https://github.com/taiki-e/pin-project/compare/v0.1.7...v0.1.8
+[0.1.7]: https://github.com/taiki-e/pin-project/compare/v0.1.6...v0.1.7
+[0.1.6]: https://github.com/taiki-e/pin-project/compare/v0.1.5...v0.1.6
+[0.1.5]: https://github.com/taiki-e/pin-project/compare/v0.1.4...v0.1.5
+[0.1.4]: https://github.com/taiki-e/pin-project/compare/v0.1.3...v0.1.4
+[0.1.3]: https://github.com/taiki-e/pin-project/compare/v0.1.2...v0.1.3
+[0.1.2]: https://github.com/taiki-e/pin-project/compare/v0.1.1...v0.1.2
+[0.1.1]: https://github.com/taiki-e/pin-project/compare/v0.1.0...v0.1.1
+[0.1.0]: https://github.com/taiki-e/pin-project/releases/tag/v0.1.0
diff --git a/third_party/rust/pin-project/Cargo.lock b/third_party/rust/pin-project/Cargo.lock
new file mode 100644
index 0000000000..502ac21268
--- /dev/null
+++ b/third_party/rust/pin-project/Cargo.lock
@@ -0,0 +1,222 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "diff"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
+
+[[package]]
+name = "glob"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
+
+[[package]]
+name = "itoa"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
+
+[[package]]
+name = "macrotest"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7489ae0986ce45414b7b3122c2e316661343ecf396b206e3e15f07c846616f10"
+dependencies = [
+ "diff",
+ "glob",
+ "prettyplease",
+ "serde",
+ "serde_json",
+ "syn",
+ "toml",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+dependencies = [
+ "macrotest",
+ "pin-project-internal",
+ "rustversion",
+ "static_assertions",
+ "trybuild",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "prettyplease"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "697ae720ee02011f439e0701db107ffe2916d83f718342d65d7f8bf7b8a5fee9"
+dependencies = [
+ "proc-macro2",
+ "syn",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
+
+[[package]]
+name = "ryu"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
+
+[[package]]
+name = "serde"
+version = "1.0.143"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.143"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "syn"
+version = "1.0.99"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "toml"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "trybuild"
+version = "1.0.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7f408301c7480f9e6294eb779cfc907f54bd901a9660ef24d7f233ed5376485"
+dependencies = [
+ "glob",
+ "once_cell",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "termcolor",
+ "toml",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/third_party/rust/pin-project/Cargo.toml b/third_party/rust/pin-project/Cargo.toml
new file mode 100644
index 0000000000..9ad85ba371
--- /dev/null
+++ b/third_party/rust/pin-project/Cargo.toml
@@ -0,0 +1,54 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2018"
+rust-version = "1.37"
+name = "pin-project"
+version = "1.0.12"
+exclude = [
+ "/.*",
+ "/ci",
+ "/tools",
+]
+description = """
+A crate for safe and ergonomic pin-projection.
+"""
+readme = "README.md"
+keywords = [
+ "pin",
+ "macros",
+ "attribute",
+]
+categories = [
+ "no-std",
+ "rust-patterns",
+]
+license = "Apache-2.0 OR MIT"
+repository = "https://github.com/taiki-e/pin-project"
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]
+
+[dependencies.pin-project-internal]
+version = "=1.0.12"
+
+[dev-dependencies.macrotest]
+version = "1.0.9"
+
+[dev-dependencies.rustversion]
+version = "1"
+
+[dev-dependencies.static_assertions]
+version = "1"
+
+[dev-dependencies.trybuild]
+version = "1.0.49"
diff --git a/third_party/rust/pin-project/LICENSE-APACHE b/third_party/rust/pin-project/LICENSE-APACHE
new file mode 100644
index 0000000000..f433b1a53f
--- /dev/null
+++ b/third_party/rust/pin-project/LICENSE-APACHE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/third_party/rust/pin-project/LICENSE-MIT b/third_party/rust/pin-project/LICENSE-MIT
new file mode 100644
index 0000000000..31aa79387f
--- /dev/null
+++ b/third_party/rust/pin-project/LICENSE-MIT
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/third_party/rust/pin-project/README.md b/third_party/rust/pin-project/README.md
new file mode 100644
index 0000000000..0a306540c6
--- /dev/null
+++ b/third_party/rust/pin-project/README.md
@@ -0,0 +1,99 @@
+# pin-project
+
+[![crates.io](https://img.shields.io/crates/v/pin-project?style=flat-square&logo=rust)](https://crates.io/crates/pin-project)
+[![docs.rs](https://img.shields.io/badge/docs.rs-pin--project-blue?style=flat-square&logo=docs.rs)](https://docs.rs/pin-project)
+[![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)](#license)
+[![rustc](https://img.shields.io/badge/rustc-1.37+-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)
+[![build status](https://img.shields.io/github/workflow/status/taiki-e/pin-project/CI/main?style=flat-square&logo=github)](https://github.com/taiki-e/pin-project/actions)
+
+A crate for safe and ergonomic [pin-projection].
+
+## Usage
+
+Add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+pin-project = "1"
+```
+
+*Compiler support: requires rustc 1.37+*
+
+## Examples
+
+[`#[pin_project]`][`pin_project`] attribute creates projection types
+covering all the fields of struct or enum.
+
+```rust
+use pin_project::pin_project;
+use std::pin::Pin;
+
+#[pin_project]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+impl<T, U> Struct<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ let this = self.project();
+ let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+ let _: &mut U = this.unpinned; // Normal reference to the field
+ }
+}
+```
+
+[*code like this will be generated*][struct-default-expanded]
+
+To use `#[pin_project]` on enums, you need to name the projection type
+returned from the method.
+
+```rust
+use pin_project::pin_project;
+use std::pin::Pin;
+
+#[pin_project(project = EnumProj)]
+enum Enum<T, U> {
+ Pinned(#[pin] T),
+ Unpinned(U),
+}
+
+impl<T, U> Enum<T, U> {
+ fn method(self: Pin<&mut Self>) {
+ match self.project() {
+ EnumProj::Pinned(x) => {
+ let _: Pin<&mut T> = x;
+ }
+ EnumProj::Unpinned(y) => {
+ let _: &mut U = y;
+ }
+ }
+ }
+}
+```
+
+[*code like this will be generated*][enum-default-expanded]
+
+See [documentation](https://docs.rs/pin-project) for more details, and
+see [examples] directory for more examples and generated code.
+
+## Related Projects
+
+- [pin-project-lite]: A lightweight version of pin-project written with declarative macros.
+
+[`pin_project`]: https://docs.rs/pin-project/1/pin_project/attr.pin_project.html
+[enum-default-expanded]: examples/enum-default-expanded.rs
+[examples]: examples/README.md
+[pin-project-lite]: https://github.com/taiki-e/pin-project-lite
+[pin-projection]: https://doc.rust-lang.org/std/pin/index.html#projections-and-structural-pinning
+[struct-default-expanded]: examples/struct-default-expanded.rs
+
+## License
+
+Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
+[MIT license](LICENSE-MIT) at your option.
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall
+be dual licensed as above, without any additional terms or conditions.
diff --git a/third_party/rust/pin-project/examples/README.md b/third_party/rust/pin-project/examples/README.md
new file mode 100644
index 0000000000..0f30a7fc82
--- /dev/null
+++ b/third_party/rust/pin-project/examples/README.md
@@ -0,0 +1,39 @@
+# Examples and generated code of each feature of pin-project
+
+### Basic usage of `#[pin_project]` on structs
+
+- [example](struct-default.rs)
+- [generated code](struct-default-expanded.rs)
+
+### Basic usage of `#[pin_project]` on enums
+
+- [example](enum-default.rs)
+- [generated code](enum-default-expanded.rs)
+
+### Manual implementation of `Unpin` by `UnsafeUnpin`
+
+- [example](unsafe_unpin.rs)
+- [generated code](unsafe_unpin-expanded.rs)
+- [`UnsafeUnpin` documentation](https://docs.rs/pin-project/1/pin_project/trait.UnsafeUnpin.html)
+
+### Manual implementation of `Drop` by `#[pinned_drop]`
+
+- [example](pinned_drop.rs)
+- [generated code](pinned_drop-expanded.rs)
+- [`#[pinned_drop]` documentation](https://docs.rs/pin-project/1/pin_project/attr.pinned_drop.html)
+
+### `project_replace()` method
+
+- [example](project_replace.rs)
+- [generated code](project_replace-expanded.rs)
+- [`project_replace()` documentation](https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#project_replace-method)
+
+### Ensure `!Unpin` by `#[pin_project(!Unpin)]`
+
+- [example](not_unpin.rs)
+- [generated code](not_unpin-expanded.rs)
+- [`!Unpin` documentation](https://docs.rs/pin-project/1/pin_project/attr.pin_project.html#unpin)
+
+Note: These generated code examples are the little simplified version of the
+actual generated code. See [expansion tests](../tests#expansion-tests-expand-expandtestrs) if you
+want to see the exact version of the actual generated code.
diff --git a/third_party/rust/pin-project/examples/enum-default-expanded.rs b/third_party/rust/pin-project/examples/enum-default-expanded.rs
new file mode 100644
index 0000000000..459ca39b03
--- /dev/null
+++ b/third_party/rust/pin-project/examples/enum-default-expanded.rs
@@ -0,0 +1,101 @@
+// Original code (./enum-default.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use pin_project::pin_project;
+//
+// #[pin_project(project = EnumProj)]
+// enum Enum<T, U> {
+// Pinned(#[pin] T),
+// Unpinned(U),
+// }
+//
+// fn main() {}
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(
+ clippy::needless_lifetimes,
+ clippy::just_underscores_and_digits,
+ clippy::used_underscore_binding
+)]
+
+use pin_project::pin_project;
+
+// #[pin_project(project = EnumProj)]
+enum Enum<T, U> {
+ Pinned(/* #[pin] */ T),
+ Unpinned(U),
+}
+
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Pinned(::pin_project::__private::Pin<&'pin mut (T)>),
+ Unpinned(&'pin mut (U)),
+}
+
+const _: () = {
+ // When `#[pin_project]` is used on enums, only named projection types and
+ // methods are generated because there is no way to access variants of
+ // projected types without naming it.
+ // (When `#[pin_project]` is used on structs, both methods are always generated.)
+
+ impl<T, U> Enum<T, U> {
+ fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Pinned(_0) => {
+ EnumProj::Pinned(::pin_project::__private::Pin::new_unchecked(_0))
+ }
+ Self::Unpinned(_0) => EnumProj::Unpinned(_0),
+ }
+ }
+ }
+ }
+
+ // Automatically create the appropriate conditional `Unpin` implementation.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
+ // for details.
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> ::pin_project::__private::Unpin for Enum<T, U> where
+ __Enum<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Enum<T, U> where
+ __Enum<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+
+ // Ensure that enum does not implement `Drop`.
+ //
+ // See ./struct-default-expanded.rs for details.
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
+ impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ // We don't need to check for `#[repr(packed)]`,
+ // since it does not apply to enums.
+};
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/enum-default.rs b/third_party/rust/pin-project/examples/enum-default.rs
new file mode 100644
index 0000000000..bd3f2e636c
--- /dev/null
+++ b/third_party/rust/pin-project/examples/enum-default.rs
@@ -0,0 +1,13 @@
+// See ./enum-default-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use pin_project::pin_project;
+
+#[pin_project(project = EnumProj)]
+enum Enum<T, U> {
+ Pinned(#[pin] T),
+ Unpinned(U),
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/not_unpin-expanded.rs b/third_party/rust/pin-project/examples/not_unpin-expanded.rs
new file mode 100644
index 0000000000..5700c120a5
--- /dev/null
+++ b/third_party/rust/pin-project/examples/not_unpin-expanded.rs
@@ -0,0 +1,125 @@
+// Original code (./not_unpin.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use pin_project::pin_project;
+//
+// #[pin_project(!Unpin)]
+// pub struct Struct<T, U> {
+// #[pin]
+// pinned: T,
+// unpinned: U,
+// }
+//
+// fn main() {
+// fn _is_unpin<T: Unpin>() {}
+// // _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
+// }
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
+
+use pin_project::pin_project;
+
+// #[pin_project(!Unpin)]
+pub struct Struct<T, U> {
+ // #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+const _: () = {
+ pub(crate) struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ pub(crate) struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
+ impl<T, U> Struct<T, U> {
+ pub(crate) fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ pub(crate) fn project_ref<'pin>(
+ self: ::pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
+ // Create `Unpin` impl that has trivial `Unpin` bounds.
+ //
+ // See https://github.com/taiki-e/pin-project/issues/102#issuecomment-540472282
+ // for details.
+ impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
+ ::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>:
+ ::pin_project::__private::Unpin
+ {
+ }
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ //
+ // To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
+ // impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
+ // impl, they'll get a "conflicting implementations of trait" error when
+ // coherence checks are run.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ ::pin_project::__private::Wrapper<'pin, ::pin_project::__private::PhantomPinned>:
+ ::pin_project::__private::Unpin
+ {
+ }
+
+ // Ensure that struct does not implement `Drop`.
+ //
+ // See ./struct-default-expanded.rs for details.
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
+ impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+
+fn main() {
+ fn _is_unpin<T: Unpin>() {}
+ // _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
+}
diff --git a/third_party/rust/pin-project/examples/not_unpin.rs b/third_party/rust/pin-project/examples/not_unpin.rs
new file mode 100644
index 0000000000..2ad72a87f2
--- /dev/null
+++ b/third_party/rust/pin-project/examples/not_unpin.rs
@@ -0,0 +1,17 @@
+// See ./not_unpin-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use pin_project::pin_project;
+
+#[pin_project(!Unpin)]
+pub struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {
+ fn _is_unpin<T: Unpin>() {}
+ // _is_unpin::<Struct<(), ()>>(); //~ ERROR `std::marker::PhantomPinned` cannot be unpinned
+}
diff --git a/third_party/rust/pin-project/examples/pinned_drop-expanded.rs b/third_party/rust/pin-project/examples/pinned_drop-expanded.rs
new file mode 100644
index 0000000000..82207b60b1
--- /dev/null
+++ b/third_party/rust/pin-project/examples/pinned_drop-expanded.rs
@@ -0,0 +1,154 @@
+// Original code (./pinned_drop.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use std::pin::Pin;
+//
+// use pin_project::{pin_project, pinned_drop};
+//
+// #[pin_project(PinnedDrop)]
+// pub struct Struct<'a, T> {
+// was_dropped: &'a mut bool,
+// #[pin]
+// field: T,
+// }
+//
+// #[pinned_drop]
+// fn drop_Struct<T>(mut this: Pin<&mut Struct<'_, T>>) {
+// **this.project().was_dropped = true;
+// }
+//
+// fn main() {}
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes, clippy::mut_mut)]
+
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+// #[pin_project(PinnedDrop)]
+pub struct Struct<'a, T> {
+ was_dropped: &'a mut bool,
+ // #[pin]
+ field: T,
+}
+
+const _: () = {
+ pub(crate) struct __StructProjection<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin mut (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin mut (T)>,
+ }
+ pub(crate) struct __StructProjectionRef<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin (T)>,
+ }
+
+ impl<'a, T> Struct<'a, T> {
+ pub(crate) fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, 'a, T> {
+ unsafe {
+ let Self { was_dropped, field } = self.get_unchecked_mut();
+ __StructProjection {
+ was_dropped,
+ field: ::pin_project::__private::Pin::new_unchecked(field),
+ }
+ }
+ }
+ pub(crate) fn project_ref<'pin>(
+ self: ::pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, 'a, T> {
+ unsafe {
+ let Self { was_dropped, field } = self.get_ref();
+ __StructProjectionRef {
+ was_dropped,
+ field: ::pin_project::__private::Pin::new_unchecked(field),
+ }
+ }
+ }
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<'a, T>(this: &Struct<'a, T>) {
+ let _ = &this.was_dropped;
+ let _ = &this.field;
+ }
+
+ impl<'a, T> ::pin_project::__private::Drop for Struct<'a, T> {
+ fn drop(&mut self) {
+ // Safety - we're in 'drop', so we know that 'self' will
+ // never move again.
+ let pinned_self = unsafe { ::pin_project::__private::Pin::new_unchecked(self) };
+ // We call `pinned_drop` only once. Since `PinnedDrop::drop`
+ // is an unsafe method and a private API, it is never called again in safe
+ // code *unless the user uses a maliciously crafted macro*.
+ unsafe {
+ ::pin_project::__private::PinnedDrop::drop(pinned_self);
+ }
+ }
+ }
+
+ // Automatically create the appropriate conditional `Unpin` implementation.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
+ // for details.
+ pub struct __Struct<'pin, 'a, T> {
+ __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<'pin, (T)>,
+ __field0: T,
+ __lifetime0: &'a (),
+ }
+ impl<'pin, 'a, T> ::pin_project::__private::Unpin for Struct<'a, T> where
+ __Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
+ {
+ }
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, 'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where
+ __Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
+ {
+ }
+};
+
+// Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
+// This is because destructors can be called multiple times in safe code and
+// [double dropping is unsound](https://github.com/rust-lang/rust/pull/62360).
+//
+// Ideally, it would be desirable to be able to forbid manual calls in
+// the same way as `Drop::drop`, but the library cannot do it. So, by using
+// macros and replacing them with private traits, we prevent users from
+// calling `PinnedDrop::drop`.
+//
+// Users can implement [`Drop`] safely using `#[pinned_drop]` and can drop a
+// type that implements `PinnedDrop` using the [`drop`] function safely.
+// **Do not call or implement this trait directly.**
+#[doc(hidden)]
+impl<T> ::pin_project::__private::PinnedDrop for Struct<'_, T> {
+ // Since calling it twice on the same object would be UB,
+ // this method is unsafe.
+ unsafe fn drop(self: Pin<&mut Self>) {
+ #[allow(clippy::needless_pass_by_value)]
+ fn __drop_inner<T>(__self: Pin<&mut Struct<'_, T>>) {
+ // A dummy `__drop_inner` function to prevent users call outer `__drop_inner`.
+ fn __drop_inner() {}
+
+ **__self.project().was_dropped = true;
+ }
+ __drop_inner(self);
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/pinned_drop.rs b/third_party/rust/pin-project/examples/pinned_drop.rs
new file mode 100644
index 0000000000..6fb87193f6
--- /dev/null
+++ b/third_party/rust/pin-project/examples/pinned_drop.rs
@@ -0,0 +1,23 @@
+// See ./pinned_drop-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+pub struct Struct<'a, T> {
+ was_dropped: &'a mut bool,
+ #[pin]
+ field: T,
+}
+
+#[pinned_drop]
+impl<T> PinnedDrop for Struct<'_, T> {
+ fn drop(self: Pin<&mut Self>) {
+ **self.project().was_dropped = true;
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/project_replace-expanded.rs b/third_party/rust/pin-project/examples/project_replace-expanded.rs
new file mode 100644
index 0000000000..445e5705e1
--- /dev/null
+++ b/third_party/rust/pin-project/examples/project_replace-expanded.rs
@@ -0,0 +1,156 @@
+// Original code (./struct-default.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use pin_project::pin_project;
+//
+// #[pin_project(project_replace)]
+// struct Struct<T, U> {
+// #[pin]
+// pinned: T,
+// unpinned: U,
+// }
+//
+// fn main() {}
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
+
+use pin_project::pin_project;
+
+// #[pin_project(project_replace)]
+struct Struct<T, U> {
+ // #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+const _: () = {
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ struct __StructProjectionOwned<T, U> {
+ pinned: ::pin_project::__private::PhantomData<T>,
+ unpinned: U,
+ }
+
+ impl<T, U> Struct<T, U> {
+ fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ fn project_ref<'pin>(
+ self: ::pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ fn project_replace(
+ self: ::pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> __StructProjectionOwned<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+
+ // Destructors will run in reverse order, so next create a guard to overwrite
+ // `self` with the replacement value without calling destructors.
+ let __guard =
+ ::pin_project::__private::UnsafeOverwriteGuard::new(__self_ptr, __replacement);
+
+ let Self { pinned, unpinned } = &mut *__self_ptr;
+
+ // First, extract all the unpinned fields
+ let __result = __StructProjectionOwned {
+ pinned: ::pin_project::__private::PhantomData,
+ unpinned: ::pin_project::__private::ptr::read(unpinned),
+ };
+
+ // Now create guards to drop all the pinned fields
+ //
+ // Due to a compiler bug (https://github.com/rust-lang/rust/issues/47949)
+ // this must be in its own scope, or else `__result` will not be dropped
+ // if any of the destructors panic.
+ {
+ let __guard = ::pin_project::__private::UnsafeDropInPlaceGuard::new(pinned);
+ }
+
+ // Finally, return the result
+ __result
+ }
+ }
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
+ // Automatically create the appropriate conditional `Unpin` implementation.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/53.
+ // for details.
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+
+ // Ensure that struct does not implement `Drop`.
+ //
+ // See ./struct-default-expanded.rs for details.
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
+ impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/project_replace.rs b/third_party/rust/pin-project/examples/project_replace.rs
new file mode 100644
index 0000000000..99cec18472
--- /dev/null
+++ b/third_party/rust/pin-project/examples/project_replace.rs
@@ -0,0 +1,14 @@
+// See ./struct-default-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use pin_project::pin_project;
+
+#[pin_project(project_replace)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/struct-default-expanded.rs b/third_party/rust/pin-project/examples/struct-default-expanded.rs
new file mode 100644
index 0000000000..d6610993d3
--- /dev/null
+++ b/third_party/rust/pin-project/examples/struct-default-expanded.rs
@@ -0,0 +1,155 @@
+// Original code (./struct-default.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use pin_project::pin_project;
+//
+// #[pin_project]
+// struct Struct<T, U> {
+// #[pin]
+// pinned: T,
+// unpinned: U,
+// }
+//
+// fn main() {}
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
+
+use pin_project::pin_project;
+
+// #[pin_project]
+struct Struct<T, U> {
+ // #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+const _: () = {
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
+ impl<T, U> Struct<T, U> {
+ fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ fn project_ref<'pin>(
+ self: ::pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // Taking a reference to a packed field is UB, and applying
+ // `#[forbid(unaligned_references)]` makes sure that doing this is a hard error.
+ //
+ // If the struct ends up having #[repr(packed)] applied somehow,
+ // this will generate an (unfriendly) error message. Under all reasonable
+ // circumstances, we'll detect the #[repr(packed)] attribute, and generate
+ // a much nicer error above.
+ //
+ // See https://github.com/taiki-e/pin-project/pull/34 for more details.
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
+ // Automatically create the appropriate conditional `Unpin` implementation.
+ //
+ // Basically this is equivalent to the following code:
+ //
+ // ```rust
+ // impl<T, U> Unpin for Struct<T, U> where T: Unpin {}
+ // ```
+ //
+ // However, if struct is public and there is a private type field,
+ // this would cause an E0446 (private type in public interface).
+ //
+ // When RFC 2145 is implemented (rust-lang/rust#48054),
+ // this will become a lint, rather then a hard error.
+ //
+ // As a workaround for this, we generate a new struct, containing all of
+ // the pinned fields from our #[pin_project] type. This struct is declared
+ // within a function, which makes it impossible to be named by user code.
+ // This guarantees that it will use the default auto-trait impl for Unpin -
+ // that is, it will implement Unpin iff all of its fields implement Unpin.
+ // This type can be safely declared as 'public', satisfying the privacy
+ // checker without actually allowing user code to access it.
+ //
+ // This allows users to apply the #[pin_project] attribute to types
+ // regardless of the privacy of the types of their fields.
+ //
+ // See also https://github.com/taiki-e/pin-project/pull/53.
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: ::pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (::pin_project::__private::PhantomData<T>, ::pin_project::__private::PhantomData<U>),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ //
+ // To ensure that users don't accidentally write a non-functional `UnsafeUnpin`
+ // impls, we emit one ourselves. If the user ends up writing an `UnsafeUnpin`
+ // impl, they'll get a "conflicting implementations of trait" error when
+ // coherence checks are run.
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> ::pin_project::UnsafeUnpin for Struct<T, U> where
+ __Struct<'pin, T, U>: ::pin_project::__private::Unpin
+ {
+ }
+
+ // Ensure that struct does not implement `Drop`.
+ //
+ // If you attempt to provide an Drop impl, the blanket impl will
+ // then apply to your type, causing a compile-time error due to
+ // the conflict with the second impl.
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
+ impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/struct-default.rs b/third_party/rust/pin-project/examples/struct-default.rs
new file mode 100644
index 0000000000..46808a5827
--- /dev/null
+++ b/third_party/rust/pin-project/examples/struct-default.rs
@@ -0,0 +1,14 @@
+// See ./struct-default-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use pin_project::pin_project;
+
+#[pin_project]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/unsafe_unpin-expanded.rs b/third_party/rust/pin-project/examples/unsafe_unpin-expanded.rs
new file mode 100644
index 0000000000..e9c7abcedd
--- /dev/null
+++ b/third_party/rust/pin-project/examples/unsafe_unpin-expanded.rs
@@ -0,0 +1,107 @@
+// Original code (./unsafe_unpin.rs):
+//
+// ```rust
+// #![allow(dead_code)]
+//
+// use pin_project::{pin_project, UnsafeUnpin};
+//
+// #[pin_project(UnsafeUnpin)]
+// pub struct Struct<T, U> {
+// #[pin]
+// pinned: T,
+// unpinned: U,
+// }
+//
+// unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+//
+// fn main() {}
+// ```
+
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
+
+use pin_project::{pin_project, UnsafeUnpin};
+
+// #[pin_project(UnsafeUnpin)]
+pub struct Struct<T, U> {
+ // #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+const _: () = {
+ pub(crate) struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ pub(crate) struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+
+ impl<T, U> Struct<T, U> {
+ pub(crate) fn project<'pin>(
+ self: ::pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ pub(crate) fn project_ref<'pin>(
+ self: ::pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: ::pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+
+ // Implement `Unpin` via `UnsafeUnpin`.
+ impl<'pin, T, U> ::pin_project::__private::Unpin for Struct<T, U> where
+ ::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin
+ {
+ }
+
+ // Ensure that struct does not implement `Drop`.
+ //
+ // See ./struct-default-expanded.rs for details.
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: ::pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ // A dummy impl of `PinnedDrop`, to ensure that users don't accidentally
+ // write a non-functional `PinnedDrop` impls.
+ #[doc(hidden)]
+ impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/examples/unsafe_unpin.rs b/third_party/rust/pin-project/examples/unsafe_unpin.rs
new file mode 100644
index 0000000000..5ec0cd22ba
--- /dev/null
+++ b/third_party/rust/pin-project/examples/unsafe_unpin.rs
@@ -0,0 +1,16 @@
+// See ./unsafe_unpin-expanded.rs for generated code.
+
+#![allow(dead_code)]
+
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(UnsafeUnpin)]
+pub struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/src/lib.rs b/third_party/rust/pin-project/src/lib.rs
new file mode 100644
index 0000000000..5fa9298011
--- /dev/null
+++ b/third_party/rust/pin-project/src/lib.rs
@@ -0,0 +1,315 @@
+//! A crate for safe and ergonomic [pin-projection].
+//!
+//! # Examples
+//!
+//! [`#[pin_project]`][`pin_project`] attribute creates projection types
+//! covering all the fields of struct or enum.
+//!
+//! ```rust
+//! use std::pin::Pin;
+//!
+//! use pin_project::pin_project;
+//!
+//! #[pin_project]
+//! struct Struct<T, U> {
+//! #[pin]
+//! pinned: T,
+//! unpinned: U,
+//! }
+//!
+//! impl<T, U> Struct<T, U> {
+//! fn method(self: Pin<&mut Self>) {
+//! let this = self.project();
+//! let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
+//! let _: &mut U = this.unpinned; // Normal reference to the field
+//! }
+//! }
+//! ```
+//!
+//! [*code like this will be generated*][struct-default-expanded]
+//!
+//! To use `#[pin_project]` on enums, you need to name the projection type
+//! returned from the method.
+//!
+//! ```rust
+//! use std::pin::Pin;
+//!
+//! use pin_project::pin_project;
+//!
+//! #[pin_project(project = EnumProj)]
+//! enum Enum<T, U> {
+//! Pinned(#[pin] T),
+//! Unpinned(U),
+//! }
+//!
+//! impl<T, U> Enum<T, U> {
+//! fn method(self: Pin<&mut Self>) {
+//! match self.project() {
+//! EnumProj::Pinned(x) => {
+//! let _: Pin<&mut T> = x;
+//! }
+//! EnumProj::Unpinned(y) => {
+//! let _: &mut U = y;
+//! }
+//! }
+//! }
+//! }
+//! ```
+//!
+//! [*code like this will be generated*][enum-default-expanded]
+//!
+//! See [`#[pin_project]`][`pin_project`] attribute for more details, and
+//! see [examples] directory for more examples and generated code.
+//!
+//! [examples]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/README.md
+//! [enum-default-expanded]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/enum-default-expanded.rs
+//! [pin-projection]: core::pin#projections-and-structural-pinning
+//! [struct-default-expanded]: https://github.com/taiki-e/pin-project/blob/HEAD/examples/struct-default-expanded.rs
+
+#![no_std]
+#![doc(test(
+ no_crate_inject,
+ attr(
+ deny(warnings, rust_2018_idioms, single_use_lifetimes),
+ allow(dead_code, unused_variables)
+ )
+))]
+#![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
+#![warn(
+ clippy::pedantic,
+ // lints for public library
+ clippy::alloc_instead_of_core,
+ clippy::exhaustive_enums,
+ clippy::exhaustive_structs,
+ clippy::std_instead_of_alloc,
+ clippy::std_instead_of_core,
+ // lints that help writing unsafe code
+ clippy::default_union_representation,
+ clippy::trailing_empty_array,
+ clippy::transmute_undefined_repr,
+ clippy::undocumented_unsafe_blocks,
+)]
+#![allow(clippy::needless_doctest_main)]
+
+#[doc(inline)]
+pub use pin_project_internal::pin_project;
+#[doc(inline)]
+pub use pin_project_internal::pinned_drop;
+
+/// A trait used for custom implementations of [`Unpin`].
+///
+/// This trait is used in conjunction with the `UnsafeUnpin` argument to
+/// the [`#[pin_project]`][macro@pin_project] attribute.
+///
+/// # Safety
+///
+/// The Rust [`Unpin`] trait is safe to implement - by itself,
+/// implementing it cannot lead to [undefined behavior][undefined-behavior].
+/// Undefined behavior can only occur when other unsafe code is used.
+///
+/// It turns out that using pin projections, which requires unsafe code,
+/// imposes additional requirements on an [`Unpin`] impl. Normally, all of this
+/// unsafety is contained within this crate, ensuring that it's impossible for
+/// you to violate any of the guarantees required by pin projection.
+///
+/// However, things change if you want to provide a custom [`Unpin`] impl
+/// for your `#[pin_project]` type. As stated in [the Rust
+/// documentation][pin-projection], you must be sure to only implement [`Unpin`]
+/// when all of your `#[pin]` fields (i.e. structurally pinned fields) are also
+/// [`Unpin`].
+///
+/// To help highlight this unsafety, the `UnsafeUnpin` trait is provided.
+/// Implementing this trait is logically equivalent to implementing [`Unpin`] -
+/// this crate will generate an [`Unpin`] impl for your type that 'forwards' to
+/// your `UnsafeUnpin` impl. However, this trait is `unsafe` - since your type
+/// uses structural pinning (otherwise, you wouldn't be using this crate!),
+/// you must be sure that your `UnsafeUnpin` impls follows all of
+/// the requirements for an [`Unpin`] impl of a structurally-pinned type.
+///
+/// Note that if you specify `#[pin_project(UnsafeUnpin)]`, but do *not*
+/// provide an impl of `UnsafeUnpin`, your type will never implement [`Unpin`].
+/// This is effectively the same thing as adding a [`PhantomPinned`] to your
+/// type.
+///
+/// Since this trait is `unsafe`, impls of it will be detected by the
+/// `unsafe_code` lint, and by tools like [`cargo geiger`][cargo-geiger].
+///
+/// # Examples
+///
+/// An `UnsafeUnpin` impl which, in addition to requiring that structurally
+/// pinned fields be [`Unpin`], imposes an additional requirement:
+///
+/// ```rust
+/// use pin_project::{pin_project, UnsafeUnpin};
+///
+/// #[pin_project(UnsafeUnpin)]
+/// struct Struct<K, V> {
+/// #[pin]
+/// field_1: K,
+/// field_2: V,
+/// }
+///
+/// unsafe impl<K, V> UnsafeUnpin for Struct<K, V> where K: Unpin + Clone {}
+/// ```
+///
+/// [`PhantomPinned`]: core::marker::PhantomPinned
+/// [cargo-geiger]: https://github.com/rust-secure-code/cargo-geiger
+/// [pin-projection]: core::pin#projections-and-structural-pinning
+/// [undefined-behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
+pub unsafe trait UnsafeUnpin {}
+
+// Not public API.
+#[doc(hidden)]
+pub mod __private {
+ use core::mem::ManuallyDrop;
+ #[doc(hidden)]
+ pub use core::{
+ marker::{PhantomData, PhantomPinned, Unpin},
+ ops::Drop,
+ pin::Pin,
+ ptr,
+ };
+
+ #[doc(hidden)]
+ pub use pin_project_internal::__PinProjectInternalDerive;
+
+ use super::UnsafeUnpin;
+
+ // An internal trait used for custom implementations of [`Drop`].
+ //
+ // **Do not call or implement this trait directly.**
+ //
+ // # Why this trait is private and `#[pinned_drop]` attribute is needed?
+ //
+ // Implementing `PinnedDrop::drop` is safe, but calling it is not safe.
+ // This is because destructors can be called multiple times in safe code and
+ // [double dropping is unsound][rust-lang/rust#62360].
+ //
+ // Ideally, it would be desirable to be able to forbid manual calls in
+ // the same way as [`Drop::drop`], but the library cannot do it. So, by using
+ // macros and replacing them with private traits,
+ // this crate prevent users from calling `PinnedDrop::drop` in safe code.
+ //
+ // This allows implementing [`Drop`] safely using `#[pinned_drop]`.
+ // Also by using the [`drop`] function just like dropping a type that directly
+ // implements [`Drop`], can drop safely a type that implements `PinnedDrop`.
+ //
+ // [rust-lang/rust#62360]: https://github.com/rust-lang/rust/pull/62360
+ #[doc(hidden)]
+ pub trait PinnedDrop {
+ #[doc(hidden)]
+ unsafe fn drop(self: Pin<&mut Self>);
+ }
+
+ // This is an internal helper struct used by `pin-project-internal`.
+ // This allows us to force an error if the user tries to provide
+ // a regular `Unpin` impl when they specify the `UnsafeUnpin` argument.
+ // This is why we need Wrapper:
+ //
+ // Supposed we have the following code:
+ //
+ // ```rust
+ // #[pin_project(UnsafeUnpin)]
+ // struct MyStruct<T> {
+ // #[pin] field: T
+ // }
+ //
+ // impl<T> Unpin for MyStruct<T> where MyStruct<T>: UnsafeUnpin {} // generated by pin-project-internal
+ // impl<T> Unpin for MyStruct<T> where T: Copy // written by the user
+ // ```
+ //
+ // We want this code to be rejected - the user is completely bypassing
+ // `UnsafeUnpin`, and providing an unsound Unpin impl in safe code!
+ //
+ // Unfortunately, the Rust compiler will accept the above code.
+ // Because MyStruct is declared in the same crate as the user-provided impl,
+ // the compiler will notice that `MyStruct<T>: UnsafeUnpin` never holds.
+ //
+ // The solution is to introduce the `Wrapper` struct, which is defined
+ // in the `pin-project` crate.
+ //
+ // We now have code that looks like this:
+ //
+ // ```rust
+ // impl<T> Unpin for MyStruct<T> where Wrapper<MyStruct<T>>: UnsafeUnpin {} // generated by pin-project-internal
+ // impl<T> Unpin for MyStruct<T> where T: Copy // written by the user
+ // ```
+ //
+ // We also have `unsafe impl<T> UnsafeUnpin for Wrapper<T> where T: UnsafeUnpin {}`
+ // in the `pin-project` crate.
+ //
+ // Now, our generated impl has a bound involving a type defined in another
+ // crate - Wrapper. This will cause rust to conservatively assume that
+ // `Wrapper<MyStruct<T>>: UnsafeUnpin` holds, in the interest of preserving
+ // forwards compatibility (in case such an impl is added for Wrapper<T> in
+ // a new version of the crate).
+ //
+ // This will cause rust to reject any other `Unpin` impls for MyStruct<T>,
+ // since it will assume that our generated impl could potentially apply in
+ // any situation.
+ //
+ // This achieves the desired effect - when the user writes
+ // `#[pin_project(UnsafeUnpin)]`, the user must either provide no impl of
+ // `UnsafeUnpin` (which is equivalent to making the type never implement
+ // Unpin), or provide an impl of `UnsafeUnpin`. It is impossible for them to
+ // provide an impl of `Unpin`
+ #[doc(hidden)]
+ pub struct Wrapper<'a, T: ?Sized>(PhantomData<&'a ()>, T);
+
+ // SAFETY: `T` implements UnsafeUnpin.
+ unsafe impl<T: ?Sized + UnsafeUnpin> UnsafeUnpin for Wrapper<'_, T> {}
+
+ // This is an internal helper struct used by `pin-project-internal`.
+ //
+ // See https://github.com/taiki-e/pin-project/pull/53 for more details.
+ #[doc(hidden)]
+ pub struct AlwaysUnpin<'a, T>(PhantomData<&'a ()>, PhantomData<T>);
+
+ impl<T> Unpin for AlwaysUnpin<'_, T> {}
+
+ // This is an internal helper used to ensure a value is dropped.
+ #[doc(hidden)]
+ pub struct UnsafeDropInPlaceGuard<T: ?Sized>(*mut T);
+
+ impl<T: ?Sized> UnsafeDropInPlaceGuard<T> {
+ #[doc(hidden)]
+ pub unsafe fn new(ptr: *mut T) -> Self {
+ Self(ptr)
+ }
+ }
+
+ impl<T: ?Sized> Drop for UnsafeDropInPlaceGuard<T> {
+ fn drop(&mut self) {
+ // SAFETY: the caller of `UnsafeDropInPlaceGuard::new` must guarantee
+ // that `ptr` is valid for drop when this guard is destructed.
+ unsafe {
+ ptr::drop_in_place(self.0);
+ }
+ }
+ }
+
+ // This is an internal helper used to ensure a value is overwritten without
+ // its destructor being called.
+ #[doc(hidden)]
+ pub struct UnsafeOverwriteGuard<T> {
+ target: *mut T,
+ value: ManuallyDrop<T>,
+ }
+
+ impl<T> UnsafeOverwriteGuard<T> {
+ #[doc(hidden)]
+ pub unsafe fn new(target: *mut T, value: T) -> Self {
+ Self { target, value: ManuallyDrop::new(value) }
+ }
+ }
+
+ impl<T> Drop for UnsafeOverwriteGuard<T> {
+ fn drop(&mut self) {
+ // SAFETY: the caller of `UnsafeOverwriteGuard::new` must guarantee
+ // that `target` is valid for writes when this guard is destructed.
+ unsafe {
+ ptr::write(self.target, ptr::read(&*self.value));
+ }
+ }
+ }
+}
diff --git a/third_party/rust/pin-project/tests/README.md b/third_party/rust/pin-project/tests/README.md
new file mode 100644
index 0000000000..b109e71534
--- /dev/null
+++ b/third_party/rust/pin-project/tests/README.md
@@ -0,0 +1,44 @@
+# Tests
+
+To run all tests, run the following command:
+
+```sh
+cargo +nightly test --all
+```
+
+## UI tests (`ui`, `compiletest.rs`)
+
+This checks errors detected by the macro or the Rust compiler in the resulting
+expanded code.
+
+To run this test, run the following command:
+
+```sh
+cargo +nightly test --test compiletest
+```
+
+Locally, this test updates the files in the `ui` directory if there are
+changes to the generated code. If there are any changes to the files in the
+`ui` directory after running the test, please commit them.
+
+See also [`trybuild` documentation](https://docs.rs/trybuild).
+
+## Expansion tests (`expand`, `expandtest.rs`)
+
+Similar to ui tests, but instead of checking the compiler output, this checks
+the code generated by macros.
+
+See [examples](../examples/README.md) for descriptions of what the generated
+code does, and why it needs to be generated.
+
+To run this test, run the following command:
+
+```sh
+cargo +nightly test --test expandtest
+```
+
+Locally, this test updates the files in the `expand` directory if there are
+changes to the generated code. If there are any changes to the files in the
+`expand` directory after running the test, please commit them.
+
+See also [`macrotest` documentation](https://docs.rs/macrotest).
diff --git a/third_party/rust/pin-project/tests/auxiliary/mod.rs b/third_party/rust/pin-project/tests/auxiliary/mod.rs
new file mode 100644
index 0000000000..1457099160
--- /dev/null
+++ b/third_party/rust/pin-project/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/third_party/rust/pin-project/tests/cfg.rs b/third_party/rust/pin-project/tests/cfg.rs
new file mode 100644
index 0000000000..2f5387b671
--- /dev/null
+++ b/third_party/rust/pin-project/tests/cfg.rs
@@ -0,0 +1,184 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+// Refs: https://doc.rust-lang.org/reference/attributes.html
+
+#[macro_use]
+mod auxiliary;
+
+use std::{marker::PhantomPinned, pin::Pin};
+
+use pin_project::pin_project;
+
+struct Always;
+
+// Use this type to check that `cfg(any())` is working properly.
+struct Never(PhantomPinned);
+
+#[test]
+fn cfg() {
+ // structs
+
+ #[pin_project(project_replace)]
+ struct SameName {
+ #[cfg(not(any()))]
+ #[pin]
+ inner: Always,
+ #[cfg(any())]
+ #[pin]
+ inner: Never,
+ }
+
+ assert_unpin!(SameName);
+
+ let _ = SameName { inner: Always };
+
+ #[pin_project(project_replace)]
+ struct DifferentName {
+ #[cfg(not(any()))]
+ #[pin]
+ a: Always,
+ #[cfg(any())]
+ #[pin]
+ n: Never,
+ }
+
+ assert_unpin!(DifferentName);
+
+ let _ = DifferentName { a: Always };
+
+ #[pin_project(project_replace)]
+ struct TupleStruct(
+ #[cfg(not(any()))]
+ #[pin]
+ Always,
+ #[cfg(any())]
+ #[pin]
+ Never,
+ );
+
+ assert_unpin!(TupleStruct);
+
+ let _ = TupleStruct(Always);
+
+ // enums
+
+ #[pin_project(
+ project = VariantProj,
+ project_ref = VariantProjRef,
+ project_replace = VariantProjOwn,
+ )]
+ enum Variant {
+ #[cfg(not(any()))]
+ Inner(#[pin] Always),
+ #[cfg(any())]
+ Inner(#[pin] Never),
+
+ #[cfg(not(any()))]
+ A(#[pin] Always),
+ #[cfg(any())]
+ N(#[pin] Never),
+ }
+
+ assert_unpin!(Variant);
+
+ let _ = Variant::Inner(Always);
+ let _ = Variant::A(Always);
+
+ #[pin_project(
+ project = FieldProj,
+ project_ref = FieldProjRef,
+ project_replace = FieldProjOwn,
+ )]
+ enum Field {
+ SameName {
+ #[cfg(not(any()))]
+ #[pin]
+ inner: Always,
+ #[cfg(any())]
+ #[pin]
+ inner: Never,
+ },
+ DifferentName {
+ #[cfg(not(any()))]
+ #[pin]
+ a: Always,
+ #[cfg(any())]
+ #[pin]
+ n: Never,
+ },
+ TupleVariant(
+ #[cfg(not(any()))]
+ #[pin]
+ Always,
+ #[cfg(any())]
+ #[pin]
+ Never,
+ ),
+ }
+
+ assert_unpin!(Field);
+
+ let _ = Field::SameName { inner: Always };
+ let _ = Field::DifferentName { a: Always };
+ let _ = Field::TupleVariant(Always);
+}
+
+#[test]
+fn cfg_attr() {
+ #[pin_project(project_replace)]
+ struct SameCfg {
+ #[cfg(not(any()))]
+ #[cfg_attr(not(any()), pin)]
+ inner: Always,
+ #[cfg(any())]
+ #[cfg_attr(any(), pin)]
+ inner: Never,
+ }
+
+ assert_unpin!(SameCfg);
+
+ let mut x = SameCfg { inner: Always };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut Always> = x.inner;
+
+ #[pin_project(project_replace)]
+ struct DifferentCfg {
+ #[cfg(not(any()))]
+ #[cfg_attr(any(), pin)]
+ inner: Always,
+ #[cfg(any())]
+ #[cfg_attr(not(any()), pin)]
+ inner: Never,
+ }
+
+ assert_unpin!(DifferentCfg);
+
+ let mut x = DifferentCfg { inner: Always };
+ let x = Pin::new(&mut x).project();
+ let _: &mut Always = x.inner;
+
+ #[cfg_attr(not(any()), pin_project)]
+ struct Foo<T> {
+ #[cfg_attr(not(any()), pin)]
+ inner: T,
+ }
+
+ assert_unpin!(Foo<()>);
+ assert_not_unpin!(Foo<PhantomPinned>);
+
+ let mut x = Foo { inner: 0_u8 };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut u8> = x.inner;
+}
+
+#[test]
+fn cfg_attr_any_packed() {
+ // Since `cfg(any())` can never be true, it is okay for this to pass.
+ #[pin_project(project_replace)]
+ #[cfg_attr(any(), repr(packed))]
+ struct Struct {
+ #[pin]
+ f: u32,
+ }
+}
diff --git a/third_party/rust/pin-project/tests/compiletest.rs b/third_party/rust/pin-project/tests/compiletest.rs
new file mode 100644
index 0000000000..b06e1e8fad
--- /dev/null
+++ b/third_party/rust/pin-project/tests/compiletest.rs
@@ -0,0 +1,16 @@
+#![cfg(not(miri))]
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+use std::env;
+
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+fn ui() {
+ if env::var_os("CI").is_none() {
+ env::set_var("TRYBUILD", "overwrite");
+ }
+
+ let t = trybuild::TestCases::new();
+ t.compile_fail("tests/ui/**/*.rs");
+ t.pass("tests/run-pass/**/*.rs");
+}
diff --git a/third_party/rust/pin-project/tests/drop_order.rs b/third_party/rust/pin-project/tests/drop_order.rs
new file mode 100644
index 0000000000..8ced56e75a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/drop_order.rs
@@ -0,0 +1,162 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+// Refs: https://doc.rust-lang.org/reference/destructors.html
+
+use std::{cell::Cell, pin::Pin, thread};
+
+use pin_project::pin_project;
+
+struct D<'a>(&'a Cell<usize>, usize);
+
+impl Drop for D<'_> {
+ fn drop(&mut self) {
+ if !thread::panicking() {
+ let old = self.0.replace(self.1);
+ assert_eq!(old, self.1 - 1);
+ }
+ }
+}
+
+#[pin_project(project_replace)]
+struct StructPinned<'a> {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+}
+
+#[pin_project(project_replace)]
+struct StructUnpinned<'a> {
+ f1: D<'a>,
+ f2: D<'a>,
+}
+
+#[pin_project(project_replace)]
+struct TuplePinned<'a>(#[pin] D<'a>, #[pin] D<'a>);
+
+#[pin_project(project_replace)]
+struct TupleUnpinned<'a>(D<'a>, D<'a>);
+
+#[pin_project(project_replace = EnumProj)]
+enum Enum<'a> {
+ #[allow(dead_code)] // false positive that fixed in Rust 1.38
+ StructPinned {
+ #[pin]
+ f1: D<'a>,
+ #[pin]
+ f2: D<'a>,
+ },
+ #[allow(dead_code)] // false positive that fixed in Rust 1.38
+ StructUnpinned {
+ f1: D<'a>,
+ f2: D<'a>,
+ },
+ TuplePinned(#[pin] D<'a>, #[pin] D<'a>),
+ TupleUnpinned(D<'a>, D<'a>),
+}
+
+#[test]
+fn struct_pinned() {
+ {
+ let c = Cell::new(0);
+ let _x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn struct_unpinned() {
+ {
+ let c = Cell::new(0);
+ let _x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn tuple_pinned() {
+ {
+ let c = Cell::new(0);
+ let _x = TuplePinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = TuplePinned(D(&c, 1), D(&c, 2));
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(TuplePinned(D(&c, 3), D(&c, 4)));
+ }
+}
+
+#[test]
+fn tuple_unpinned() {
+ {
+ let c = Cell::new(0);
+ let _x = TupleUnpinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = TupleUnpinned(D(&c, 1), D(&c, 2));
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(TupleUnpinned(D(&c, 3), D(&c, 4)));
+ }
+}
+
+#[test]
+fn enum_struct() {
+ {
+ let c = Cell::new(0);
+ let _x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(Enum::StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+
+ {
+ let c = Cell::new(0);
+ let _x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(Enum::StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
+ }
+}
+
+#[test]
+fn enum_tuple() {
+ {
+ let c = Cell::new(0);
+ let _x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(Enum::TuplePinned(D(&c, 3), D(&c, 4)));
+ }
+
+ {
+ let c = Cell::new(0);
+ let _x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
+ }
+ {
+ let c = Cell::new(0);
+ let mut x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
+ let y = Pin::new(&mut x);
+ let _z = y.project_replace(Enum::TupleUnpinned(D(&c, 3), D(&c, 4)));
+ }
+}
diff --git a/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs
new file mode 100644
index 0000000000..490bf2e453
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/enum.expanded.rs
@@ -0,0 +1,145 @@
+use pin_project::pin_project;
+#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/default/enum.rs b/third_party/rust/pin-project/tests/expand/default/enum.rs
new file mode 100644
index 0000000000..ff056150ad
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/enum.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs
new file mode 100644
index 0000000000..0005d863c4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/struct.expanded.rs
@@ -0,0 +1,104 @@
+use pin_project::pin_project;
+#[pin(__private())]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/default/struct.rs b/third_party/rust/pin-project/tests/expand/default/struct.rs
new file mode 100644
index 0000000000..474f0a1161
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/struct.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..1c5e3b08be
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/tuple_struct.expanded.rs
@@ -0,0 +1,98 @@
+use pin_project::pin_project;
+#[pin(__private())]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs
new file mode 100644
index 0000000000..398b14f3a5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/default/tuple_struct.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs
new file mode 100644
index 0000000000..8223de3418
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/enum.expanded.rs
@@ -0,0 +1,268 @@
+use pin_project::pin_project;
+#[pin(
+ __private(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn
+ )
+)]
+enum Enum<T, U> {
+ Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U },
+ Tuple(#[pin] T, #[pin] T, U, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
+ pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned1: &'pin mut (U),
+ unpinned2: &'pin mut (U),
+ },
+ Tuple(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ &'pin mut (U),
+ ),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned1: ::pin_project::__private::Pin<&'pin (T)>,
+ pinned2: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned1: &'pin (U),
+ unpinned2: &'pin (U),
+ },
+ Tuple(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ &'pin (U),
+ ),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(variant_size_differences)]
+#[allow(clippy::large_enum_variant)]
+enum EnumProjOwn<T, U> {
+ Struct {
+ pinned1: ::pin_project::__private::PhantomData<T>,
+ pinned2: ::pin_project::__private::PhantomData<T>,
+ unpinned1: U,
+ unpinned2: U,
+ },
+ Tuple(
+ ::pin_project::__private::PhantomData<T>,
+ ::pin_project::__private::PhantomData<T>,
+ U,
+ U,
+ ),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
+ EnumProj::Struct {
+ pinned1: _pin_project::__private::Pin::new_unchecked(
+ pinned1,
+ ),
+ pinned2: _pin_project::__private::Pin::new_unchecked(
+ pinned2,
+ ),
+ unpinned1,
+ unpinned2,
+ }
+ }
+ Self::Tuple(_0, _1, _2, _3) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _pin_project::__private::Pin::new_unchecked(_1),
+ _2,
+ _3,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
+ EnumProjRef::Struct {
+ pinned1: _pin_project::__private::Pin::new_unchecked(
+ pinned1,
+ ),
+ pinned2: _pin_project::__private::Pin::new_unchecked(
+ pinned2,
+ ),
+ unpinned1,
+ unpinned2,
+ }
+ }
+ Self::Tuple(_0, _1, _2, _3) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _pin_project::__private::Pin::new_unchecked(_1),
+ _2,
+ _3,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> EnumProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
+ let __result = EnumProjOwn::Struct {
+ pinned1: _pin_project::__private::PhantomData,
+ pinned2: _pin_project::__private::PhantomData,
+ unpinned1: _pin_project::__private::ptr::read(unpinned1),
+ unpinned2: _pin_project::__private::ptr::read(unpinned2),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned2,
+ );
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned1,
+ );
+ }
+ __result
+ }
+ Self::Tuple(_0, _1, _2, _3) => {
+ let __result = EnumProjOwn::Tuple(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_2),
+ _pin_project::__private::ptr::read(_3),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _1,
+ );
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ Self::Unit => {
+ let __result = EnumProjOwn::Unit;
+ {}
+ __result
+ }
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ __field2: T,
+ __field3: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/enum.rs b/third_party/rust/pin-project/tests/expand/multifields/enum.rs
new file mode 100644
index 0000000000..754d48c9f9
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/enum.rs
@@ -0,0 +1,17 @@
+use pin_project::pin_project;
+
+#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned1: T,
+ #[pin]
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+ },
+ Tuple(#[pin] T, #[pin] T, U, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs
new file mode 100644
index 0000000000..df8dc92575
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/struct.expanded.rs
@@ -0,0 +1,155 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace))]
+struct Struct<T, U> {
+ #[pin]
+ pinned1: T,
+ #[pin]
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
+ pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned1: &'pin mut (U),
+ unpinned2: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned1: ::pin_project::__private::Pin<&'pin (T)>,
+ pinned2: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned1: &'pin (U),
+ unpinned2: &'pin (U),
+ }
+ #[allow(dead_code)]
+ struct __StructProjectionOwned<T, U> {
+ pinned1: ::pin_project::__private::PhantomData<T>,
+ pinned2: ::pin_project::__private::PhantomData<T>,
+ unpinned1: U,
+ unpinned2: U,
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = self
+ .get_unchecked_mut();
+ __StructProjection {
+ pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
+ pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
+ unpinned1,
+ unpinned2,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = self.get_ref();
+ __StructProjectionRef {
+ pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
+ pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
+ unpinned1,
+ unpinned2,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> __StructProjectionOwned<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self { pinned1, pinned2, unpinned1, unpinned2 } = &mut *__self_ptr;
+ let __result = __StructProjectionOwned {
+ pinned1: _pin_project::__private::PhantomData,
+ pinned2: _pin_project::__private::PhantomData,
+ unpinned1: _pin_project::__private::ptr::read(unpinned1),
+ unpinned2: _pin_project::__private::ptr::read(unpinned2),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned2,
+ );
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned1,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned1;
+ let _ = &this.pinned2;
+ let _ = &this.unpinned1;
+ let _ = &this.unpinned2;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/struct.rs b/third_party/rust/pin-project/tests/expand/multifields/struct.rs
new file mode 100644
index 0000000000..3b319bf813
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/struct.rs
@@ -0,0 +1,13 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)]
+struct Struct<T, U> {
+ #[pin]
+ pinned1: T,
+ #[pin]
+ pinned2: T,
+ unpinned1: U,
+ unpinned2: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..0c85f9a605
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.expanded.rs
@@ -0,0 +1,145 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace))]
+struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ struct __TupleStructProjectionOwned<T, U>(
+ ::pin_project::__private::PhantomData<T>,
+ ::pin_project::__private::PhantomData<T>,
+ U,
+ U,
+ );
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1, _2, _3) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _pin_project::__private::Pin::new_unchecked(_1),
+ _2,
+ _3,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1, _2, _3) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _pin_project::__private::Pin::new_unchecked(_1),
+ _2,
+ _3,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> __TupleStructProjectionOwned<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self(_0, _1, _2, _3) = &mut *__self_ptr;
+ let __result = __TupleStructProjectionOwned(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_2),
+ _pin_project::__private::ptr::read(_3),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _1,
+ );
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ let _ = &this.2;
+ let _ = &this.3;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs
new file mode 100644
index 0000000000..bc92eee52c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/multifields/tuple_struct.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)]
+struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs
new file mode 100644
index 0000000000..8dbe768ef3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-all.expanded.rs
@@ -0,0 +1,204 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum Proj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum ProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(variant_size_differences)]
+#[allow(clippy::large_enum_variant)]
+enum ProjOwn<T, U> {
+ Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
+ Tuple(::pin_project::__private::PhantomData<T>, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ Proj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ Self::Unit => Proj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ ProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ ProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => ProjRef::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned, unpinned } => {
+ let __result = ProjOwn::Struct {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ Self::Tuple(_0, _1) => {
+ let __result = ProjOwn::Tuple(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ Self::Unit => {
+ let __result = ProjOwn::Unit;
+ {}
+ __result
+ }
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-all.rs b/third_party/rust/pin-project/tests/expand/naming/enum-all.rs
new file mode 100644
index 0000000000..dd513e6c36
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-all.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs
new file mode 100644
index 0000000000..c6916ece85
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-mut.expanded.rs
@@ -0,0 +1,99 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum Proj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ Proj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ Self::Unit => Proj::Unit,
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs b/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs
new file mode 100644
index 0000000000..818276f39c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-mut.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs
new file mode 100644
index 0000000000..46477d1e9d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-none.expanded.rs
@@ -0,0 +1,56 @@
+use pin_project::pin_project;
+#[pin(__private())]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {}
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-none.rs b/third_party/rust/pin-project/tests/expand/naming/enum-none.rs
new file mode 100644
index 0000000000..a87438db38
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-none.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs
new file mode 100644
index 0000000000..ddeb00c4b5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-own.expanded.rs
@@ -0,0 +1,119 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace = ProjOwn))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(variant_size_differences)]
+#[allow(clippy::large_enum_variant)]
+enum ProjOwn<T, U> {
+ Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
+ Tuple(::pin_project::__private::PhantomData<T>, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned, unpinned } => {
+ let __result = ProjOwn::Struct {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ Self::Tuple(_0, _1) => {
+ let __result = ProjOwn::Tuple(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ Self::Unit => {
+ let __result = ProjOwn::Unit;
+ {}
+ __result
+ }
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-own.rs b/third_party/rust/pin-project/tests/expand/naming/enum-own.rs
new file mode 100644
index 0000000000..cf886974db
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-own.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace = ProjOwn)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs
new file mode 100644
index 0000000000..1a49584e75
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-ref.expanded.rs
@@ -0,0 +1,100 @@
+use pin_project::pin_project;
+#[pin(__private(project_ref = ProjRef))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum ProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ ProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ ProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => ProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs b/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs
new file mode 100644
index 0000000000..b1ff805ce5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/enum-ref.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project_ref = ProjRef)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs
new file mode 100644
index 0000000000..e598a4f354
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-all.expanded.rs
@@ -0,0 +1,163 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+struct Proj<'pin, T, U>
+where
+ Struct<T, U>: 'pin,
+{
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+struct ProjRef<'pin, T, U>
+where
+ Struct<T, U>: 'pin,
+{
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+struct ProjOwn<T, U> {
+ pinned: ::pin_project::__private::PhantomData<T>,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Proj {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self { pinned, unpinned } = &mut *__self_ptr;
+ let __result = ProjOwn {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-all.rs b/third_party/rust/pin-project/tests/expand/naming/struct-all.rs
new file mode 100644
index 0000000000..c229ba4e0e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-all.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs
new file mode 100644
index 0000000000..88782ee253
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-mut.expanded.rs
@@ -0,0 +1,114 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+struct Proj<'pin, T, U>
+where
+ Struct<T, U>: 'pin,
+{
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ Proj {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs b/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs
new file mode 100644
index 0000000000..2f554d324d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-mut.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs
new file mode 100644
index 0000000000..0005d863c4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-none.expanded.rs
@@ -0,0 +1,104 @@
+use pin_project::pin_project;
+#[pin(__private())]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-none.rs b/third_party/rust/pin-project/tests/expand/naming/struct-none.rs
new file mode 100644
index 0000000000..474f0a1161
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-none.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs
new file mode 100644
index 0000000000..cc248628a9
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-own.expanded.rs
@@ -0,0 +1,143 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace = ProjOwn))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+struct ProjOwn<T, U> {
+ pinned: ::pin_project::__private::PhantomData<T>,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self { pinned, unpinned } = &mut *__self_ptr;
+ let __result = ProjOwn {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-own.rs b/third_party/rust/pin-project/tests/expand/naming/struct-own.rs
new file mode 100644
index 0000000000..4924362ba0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-own.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace = ProjOwn)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs
new file mode 100644
index 0000000000..e392f6f9c3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-ref.expanded.rs
@@ -0,0 +1,114 @@
+use pin_project::pin_project;
+#[pin(__private(project_ref = ProjRef))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+struct ProjRef<'pin, T, U>
+where
+ Struct<T, U>: 'pin,
+{
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ ProjRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs b/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs
new file mode 100644
index 0000000000..4e29a162d4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/struct-ref.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(project_ref = ProjRef)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs
new file mode 100644
index 0000000000..8c148ed95b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.expanded.rs
@@ -0,0 +1,148 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+struct Proj<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+)
+where
+ TupleStruct<T, U>: 'pin;
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+struct ProjRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+)
+where
+ TupleStruct<T, U>: 'pin;
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self(_0, _1) = &mut *__self_ptr;
+ let __result = ProjOwn(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs
new file mode 100644
index 0000000000..0d95cb0080
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-all.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs
new file mode 100644
index 0000000000..79c790100d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.expanded.rs
@@ -0,0 +1,105 @@
+use pin_project::pin_project;
+#[pin(__private(project = Proj))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+struct Proj<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+)
+where
+ TupleStruct<T, U>: 'pin;
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> Proj<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs
new file mode 100644
index 0000000000..e9779a6cad
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-mut.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project = Proj)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs
new file mode 100644
index 0000000000..1c5e3b08be
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.expanded.rs
@@ -0,0 +1,98 @@
+use pin_project::pin_project;
+#[pin(__private())]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs
new file mode 100644
index 0000000000..398b14f3a5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-none.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs
new file mode 100644
index 0000000000..37e4c34373
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.expanded.rs
@@ -0,0 +1,134 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace = ProjOwn))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> ProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self(_0, _1) = &mut *__self_ptr;
+ let __result = ProjOwn(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs
new file mode 100644
index 0000000000..a15ad4094a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-own.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace = ProjOwn)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs
new file mode 100644
index 0000000000..8c8686808c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.expanded.rs
@@ -0,0 +1,105 @@
+use pin_project::pin_project;
+#[pin(__private(project_ref = ProjRef))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+struct ProjRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+)
+where
+ TupleStruct<T, U>: 'pin;
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> ProjRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs
new file mode 100644
index 0000000000..cc61edfb79
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/naming/tuple_struct-ref.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project_ref = ProjRef)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs
new file mode 100644
index 0000000000..98e7bbe16d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/enum.expanded.rs
@@ -0,0 +1,139 @@
+use pin_project::pin_project;
+#[pin(__private(!Unpin, project = EnumProj, project_ref = EnumProjRef))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs b/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs
new file mode 100644
index 0000000000..ac0b3b80c0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/enum.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(!Unpin, project = EnumProj, project_ref = EnumProjRef)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs
new file mode 100644
index 0000000000..420f21aaaf
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/struct.expanded.rs
@@ -0,0 +1,99 @@
+use pin_project::pin_project;
+#[pin(__private(!Unpin))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs b/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs
new file mode 100644
index 0000000000..233e6d41f8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/struct.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(!Unpin)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..99621f496d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.expanded.rs
@@ -0,0 +1,93 @@
+use pin_project::pin_project;
+#[pin(__private(!Unpin))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ _pin_project::__private::Wrapper<
+ 'pin,
+ _pin_project::__private::PhantomPinned,
+ >: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs
new file mode 100644
index 0000000000..c8065db6ad
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/not_unpin/tuple_struct.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(!Unpin)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs
new file mode 100644
index 0000000000..1a8e746127
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.expanded.rs
@@ -0,0 +1,157 @@
+use std::pin::Pin;
+use pin_project::{pin_project, pinned_drop};
+#[pin(__private(PinnedDrop, project = EnumProj, project_ref = EnumProjRef))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ impl<T, U> _pin_project::__private::Drop for Enum<T, U> {
+ fn drop(&mut self) {
+ unsafe {
+ let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
+ _pin_project::__private::PinnedDrop::drop(__pinned_self);
+ }
+ }
+ }
+};
+#[doc(hidden)]
+impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: Pin<&mut Self>) {
+ #[allow(clippy::needless_pass_by_value)]
+ fn __drop_inner<T, U>(__self: Pin<&mut Enum<T, U>>) {
+ fn __drop_inner() {}
+ let _ = __self;
+ }
+ __drop_inner(self);
+ }
+}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs
new file mode 100644
index 0000000000..c162ef6b2b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/enum.rs
@@ -0,0 +1,23 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[pinned_drop]
+impl<T, U> PinnedDrop for Enum<T, U> {
+ fn drop(self: Pin<&mut Self>) {
+ let _ = self;
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs
new file mode 100644
index 0000000000..d21440d347
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.expanded.rs
@@ -0,0 +1,116 @@
+use std::pin::Pin;
+use pin_project::{pin_project, pinned_drop};
+#[pin(__private(PinnedDrop))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ impl<T, U> _pin_project::__private::Drop for Struct<T, U> {
+ fn drop(&mut self) {
+ unsafe {
+ let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
+ _pin_project::__private::PinnedDrop::drop(__pinned_self);
+ }
+ }
+ }
+};
+#[doc(hidden)]
+impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: Pin<&mut Self>) {
+ #[allow(clippy::needless_pass_by_value)]
+ fn __drop_inner<T, U>(__self: Pin<&mut Struct<T, U>>) {
+ fn __drop_inner() {}
+ let _ = __self;
+ }
+ __drop_inner(self);
+ }
+}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs
new file mode 100644
index 0000000000..691d3cb4a0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/struct.rs
@@ -0,0 +1,19 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+#[pinned_drop]
+impl<T, U> PinnedDrop for Struct<T, U> {
+ fn drop(self: Pin<&mut Self>) {
+ let _ = self;
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..9a614ae551
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.expanded.rs
@@ -0,0 +1,110 @@
+use std::pin::Pin;
+use pin_project::{pin_project, pinned_drop};
+#[pin(__private(PinnedDrop))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ impl<T, U> _pin_project::__private::Drop for TupleStruct<T, U> {
+ fn drop(&mut self) {
+ unsafe {
+ let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
+ _pin_project::__private::PinnedDrop::drop(__pinned_self);
+ }
+ }
+ }
+};
+#[doc(hidden)]
+impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: Pin<&mut Self>) {
+ #[allow(clippy::needless_pass_by_value)]
+ fn __drop_inner<T, U>(__self: Pin<&mut TupleStruct<T, U>>) {
+ fn __drop_inner() {}
+ let _ = __self;
+ }
+ __drop_inner(self);
+ }
+}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs
new file mode 100644
index 0000000000..1f4917c221
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pinned_drop/tuple_struct.rs
@@ -0,0 +1,15 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+#[pinned_drop]
+impl<T, U> PinnedDrop for TupleStruct<T, U> {
+ fn drop(self: Pin<&mut Self>) {
+ let _ = self;
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs
new file mode 100644
index 0000000000..178cb99758
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/enum.expanded.rs
@@ -0,0 +1,119 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace = EnumProjOwn))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(variant_size_differences)]
+#[allow(clippy::large_enum_variant)]
+enum EnumProjOwn<T, U> {
+ Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
+ Tuple(::pin_project::__private::PhantomData<T>, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> EnumProjOwn<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ match &mut *__self_ptr {
+ Self::Struct { pinned, unpinned } => {
+ let __result = EnumProjOwn::Struct {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ Self::Tuple(_0, _1) => {
+ let __result = EnumProjOwn::Tuple(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ Self::Unit => {
+ let __result = EnumProjOwn::Unit;
+ {}
+ __result
+ }
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/enum.rs b/third_party/rust/pin-project/tests/expand/project_replace/enum.rs
new file mode 100644
index 0000000000..d737f649bf
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/enum.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace = EnumProjOwn)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs
new file mode 100644
index 0000000000..45839a2857
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/struct.expanded.rs
@@ -0,0 +1,133 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ #[allow(dead_code)]
+ struct __StructProjectionOwned<T, U> {
+ pinned: ::pin_project::__private::PhantomData<T>,
+ unpinned: U,
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> __StructProjectionOwned<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self { pinned, unpinned } = &mut *__self_ptr;
+ let __result = __StructProjectionOwned {
+ pinned: _pin_project::__private::PhantomData,
+ unpinned: _pin_project::__private::ptr::read(unpinned),
+ };
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ pinned,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/struct.rs b/third_party/rust/pin-project/tests/expand/project_replace/struct.rs
new file mode 100644
index 0000000000..5865526a58
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/struct.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..cdee3d149e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.expanded.rs
@@ -0,0 +1,127 @@
+use pin_project::pin_project;
+#[pin(__private(project_replace))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ struct __TupleStructProjectionOwned<T, U>(
+ ::pin_project::__private::PhantomData<T>,
+ U,
+ );
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ fn project_replace(
+ self: _pin_project::__private::Pin<&mut Self>,
+ __replacement: Self,
+ ) -> __TupleStructProjectionOwned<T, U> {
+ unsafe {
+ let __self_ptr: *mut Self = self.get_unchecked_mut();
+ let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ __replacement,
+ );
+ let Self(_0, _1) = &mut *__self_ptr;
+ let __result = __TupleStructProjectionOwned(
+ _pin_project::__private::PhantomData,
+ _pin_project::__private::ptr::read(_1),
+ );
+ {
+ let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
+ _0,
+ );
+ }
+ __result
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs
new file mode 100644
index 0000000000..c4d05f5faa
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/project_replace/tuple_struct.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs
new file mode 100644
index 0000000000..90be268005
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/enum.expanded.rs
@@ -0,0 +1,145 @@
+use pin_project::pin_project;
+#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
+pub enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+pub(crate) enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+pub(crate) enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ pub(crate) fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ pub(crate) fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ #[allow(missing_debug_implementations)]
+ pub struct __Enum<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ __field1: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
+ where
+ __Enum<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/enum.rs b/third_party/rust/pin-project/tests/expand/pub/enum.rs
new file mode 100644
index 0000000000..7c8577fd1b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/enum.rs
@@ -0,0 +1,14 @@
+use pin_project::pin_project;
+
+#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
+pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs
new file mode 100644
index 0000000000..ca31f3d768
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/struct.expanded.rs
@@ -0,0 +1,104 @@
+use pin_project::pin_project;
+#[pin(__private())]
+pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ pub(crate) struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pub pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ pub unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ pub(crate) struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pub pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ pub unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ pub(crate) fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ pub(crate) fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ #[allow(missing_debug_implementations)]
+ pub struct __Struct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
+ where
+ __Struct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/struct.rs b/third_party/rust/pin-project/tests/expand/pub/struct.rs
new file mode 100644
index 0000000000..f50d1e9272
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/struct.rs
@@ -0,0 +1,10 @@
+use pin_project::pin_project;
+
+#[pin_project]
+pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..5c7efbf23d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.expanded.rs
@@ -0,0 +1,98 @@
+use pin_project::pin_project;
+#[pin(__private())]
+pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ pub(crate) struct __TupleStructProjection<'pin, T, U>(
+ pub ::pin_project::__private::Pin<&'pin mut (T)>,
+ pub &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ pub(crate) struct __TupleStructProjectionRef<'pin, T, U>(
+ pub ::pin_project::__private::Pin<&'pin (T)>,
+ pub &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ pub(crate) fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ pub(crate) fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ #[allow(missing_debug_implementations)]
+ pub struct __TupleStruct<'pin, T, U> {
+ __pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
+ 'pin,
+ (
+ _pin_project::__private::PhantomData<T>,
+ _pin_project::__private::PhantomData<U>,
+ ),
+ >,
+ __field0: T,
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ #[doc(hidden)]
+ unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
+ where
+ __TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs
new file mode 100644
index 0000000000..5756aafcc8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/pub/tuple_struct.rs
@@ -0,0 +1,6 @@
+use pin_project::pin_project;
+
+#[pin_project]
+pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs
new file mode 100644
index 0000000000..1f88cccae6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.expanded.rs
@@ -0,0 +1,129 @@
+use pin_project::{pin_project, UnsafeUnpin};
+#[pin(__private(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef))]
+enum Enum<T, U> {
+ Struct { #[pin] pinned: T, unpinned: U },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::mut_mut)]
+enum EnumProj<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ },
+ Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(dead_code)]
+#[allow(clippy::ref_option_ref)]
+enum EnumProjRef<'pin, T, U>
+where
+ Enum<T, U>: 'pin,
+{
+ Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
+ Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
+ Unit,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ impl<T, U> Enum<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> EnumProj<'pin, T, U> {
+ unsafe {
+ match self.get_unchecked_mut() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProj::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProj::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProj::Unit,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> EnumProjRef<'pin, T, U> {
+ unsafe {
+ match self.get_ref() {
+ Self::Struct { pinned, unpinned } => {
+ EnumProjRef::Struct {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ Self::Tuple(_0, _1) => {
+ EnumProjRef::Tuple(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ Self::Unit => EnumProjRef::Unit,
+ }
+ }
+ }
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
+ where
+ _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
+ {}
+ trait EnumMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
+ impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs
new file mode 100644
index 0000000000..d368d7132b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/enum.rs
@@ -0,0 +1,16 @@
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef)]
+enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs
new file mode 100644
index 0000000000..5fa7271572
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.expanded.rs
@@ -0,0 +1,89 @@
+use pin_project::{pin_project, UnsafeUnpin};
+#[pin(__private(UnsafeUnpin))]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __StructProjection<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
+ unpinned: &'pin mut (U),
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __StructProjectionRef<'pin, T, U>
+ where
+ Struct<T, U>: 'pin,
+ {
+ pinned: ::pin_project::__private::Pin<&'pin (T)>,
+ unpinned: &'pin (U),
+ }
+ impl<T, U> Struct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __StructProjection<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_unchecked_mut();
+ __StructProjection {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __StructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self { pinned, unpinned } = self.get_ref();
+ __StructProjectionRef {
+ pinned: _pin_project::__private::Pin::new_unchecked(pinned),
+ unpinned,
+ }
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
+ let _ = &this.pinned;
+ let _ = &this.unpinned;
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
+ where
+ _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
+ {}
+ trait StructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
+ impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs
new file mode 100644
index 0000000000..b0851b1ad6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/struct.rs
@@ -0,0 +1,12 @@
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(UnsafeUnpin)]
+struct Struct<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+}
+
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs
new file mode 100644
index 0000000000..de4e9269cb
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.expanded.rs
@@ -0,0 +1,83 @@
+use pin_project::{pin_project, UnsafeUnpin};
+#[pin(__private(UnsafeUnpin))]
+struct TupleStruct<T, U>(#[pin] T, U);
+#[allow(box_pointers)]
+#[allow(deprecated)]
+#[allow(explicit_outlives_requirements)]
+#[allow(single_use_lifetimes)]
+#[allow(unreachable_pub)]
+#[allow(unused_tuple_struct_fields)]
+#[allow(clippy::unknown_clippy_lints)]
+#[allow(clippy::pattern_type_mismatch)]
+#[allow(clippy::redundant_pub_crate)]
+#[allow(clippy::type_repetition_in_bounds)]
+#[allow(unused_qualifications)]
+#[allow(clippy::semicolon_if_nothing_returned)]
+#[allow(clippy::use_self)]
+#[allow(clippy::used_underscore_binding)]
+const _: () = {
+ #[allow(unused_extern_crates)]
+ extern crate pin_project as _pin_project;
+ #[allow(dead_code)]
+ #[allow(clippy::mut_mut)]
+ struct __TupleStructProjection<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin mut (T)>,
+ &'pin mut (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ #[allow(dead_code)]
+ #[allow(clippy::ref_option_ref)]
+ struct __TupleStructProjectionRef<'pin, T, U>(
+ ::pin_project::__private::Pin<&'pin (T)>,
+ &'pin (U),
+ )
+ where
+ TupleStruct<T, U>: 'pin;
+ impl<T, U> TupleStruct<T, U> {
+ #[allow(dead_code)]
+ fn project<'pin>(
+ self: _pin_project::__private::Pin<&'pin mut Self>,
+ ) -> __TupleStructProjection<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_unchecked_mut();
+ __TupleStructProjection(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ #[allow(dead_code)]
+ #[allow(clippy::missing_const_for_fn)]
+ fn project_ref<'pin>(
+ self: _pin_project::__private::Pin<&'pin Self>,
+ ) -> __TupleStructProjectionRef<'pin, T, U> {
+ unsafe {
+ let Self(_0, _1) = self.get_ref();
+ __TupleStructProjectionRef(
+ _pin_project::__private::Pin::new_unchecked(_0),
+ _1,
+ )
+ }
+ }
+ }
+ #[forbid(unaligned_references, safe_packed_borrows)]
+ fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
+ let _ = &this.0;
+ let _ = &this.1;
+ }
+ impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
+ where
+ _pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
+ {}
+ trait TupleStructMustNotImplDrop {}
+ #[allow(clippy::drop_bounds, drop_bounds)]
+ impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
+ impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
+ #[doc(hidden)]
+ impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
+ unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
+ }
+};
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs
new file mode 100644
index 0000000000..964617a1c9
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expand/unsafe_unpin/tuple_struct.rs
@@ -0,0 +1,8 @@
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(UnsafeUnpin)]
+struct TupleStruct<T, U>(#[pin] T, U);
+
+unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/expandtest.rs b/third_party/rust/pin-project/tests/expandtest.rs
new file mode 100644
index 0000000000..4feec1a484
--- /dev/null
+++ b/third_party/rust/pin-project/tests/expandtest.rs
@@ -0,0 +1,43 @@
+#![cfg(not(miri))]
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+use std::{
+ env,
+ process::{Command, ExitStatus, Stdio},
+};
+
+const PATH: &str = "tests/expand/**/*.rs";
+
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+fn expandtest() {
+ let is_ci = env::var_os("CI").is_some();
+ let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into());
+ if !has_command(&[cargo, "expand"]) {
+ if is_ci {
+ panic!("expandtest requires cargo-expand");
+ }
+ return;
+ }
+
+ let args = &["--all-features"];
+ if is_ci {
+ macrotest::expand_without_refresh_args(PATH, args);
+ } else {
+ env::set_var("MACROTEST", "overwrite");
+ macrotest::expand_args(PATH, args);
+ }
+}
+
+fn has_command(command: &[&str]) -> bool {
+ Command::new(command[0])
+ .args(&command[1..])
+ .arg("--version")
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .as_ref()
+ .map(ExitStatus::success)
+ .unwrap_or(false)
+}
diff --git a/third_party/rust/pin-project/tests/include/basic-safe-part.rs b/third_party/rust/pin-project/tests/include/basic-safe-part.rs
new file mode 100644
index 0000000000..0b7c43e873
--- /dev/null
+++ b/third_party/rust/pin-project/tests/include/basic-safe-part.rs
@@ -0,0 +1,193 @@
+// default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.
+
+#[::pin_project::pin_project]
+#[derive(Debug)]
+pub struct DefaultStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(
+ project = DefaultStructNamedProj,
+ project_ref = DefaultStructNamedProjRef,
+)]
+#[derive(Debug)]
+pub struct DefaultStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project]
+#[derive(Debug)]
+pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ project = DefaultTupleStructNamedProj,
+ project_ref = DefaultTupleStructNamedProjRef,
+)]
+#[derive(Debug)]
+pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ project = DefaultEnumProj,
+ project_ref = DefaultEnumProjRef,
+)]
+#[derive(Debug)]
+pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(PinnedDrop)]
+#[derive(Debug)]
+pub struct PinnedDropStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(PinnedDrop)]
+#[derive(Debug)]
+pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(
+ PinnedDrop,
+ project = PinnedDropEnumProj,
+ project_ref = PinnedDropEnumProjRef,
+)]
+#[derive(Debug)]
+pub enum PinnedDropEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pinned_drop]
+impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+}
+
+#[::pin_project::pin_project(project_replace)]
+#[derive(Debug)]
+pub struct ReplaceStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(
+ project = ReplaceStructNamedProj,
+ project_ref = ReplaceStructNamedProjRef,
+ project_replace = ReplaceStructNamedProjOwn,
+)]
+#[derive(Debug)]
+pub struct ReplaceStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(project_replace)]
+#[derive(Debug)]
+pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ project = ReplaceTupleStructNamedProj,
+ project_ref = ReplaceTupleStructNamedProjRef,
+ project_replace = ReplaceTupleStructNamedProjOwn,
+)]
+#[derive(Debug)]
+pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ project = ReplaceEnumProj,
+ project_ref = ReplaceEnumProjRef,
+ project_replace = ReplaceEnumProjOwn,
+)]
+#[derive(Debug)]
+pub enum ReplaceEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(UnsafeUnpin)]
+#[derive(Debug)]
+pub struct UnsafeUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(UnsafeUnpin)]
+#[derive(Debug)]
+pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ UnsafeUnpin,
+ project = UnsafeUnpinEnumProj,
+ project_ref = UnsafeUnpinEnumProjRef,
+)]
+#[derive(Debug)]
+pub enum UnsafeUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
+
+#[::pin_project::pin_project(!Unpin)]
+#[derive(Debug)]
+pub struct NotUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+}
+
+#[::pin_project::pin_project(!Unpin)]
+#[derive(Debug)]
+pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+#[::pin_project::pin_project(
+ !Unpin,
+ project = NotUnpinEnumProj,
+ project_ref = NotUnpinEnumProjRef,
+)]
+#[derive(Debug)]
+pub enum NotUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+}
diff --git a/third_party/rust/pin-project/tests/include/basic.rs b/third_party/rust/pin-project/tests/include/basic.rs
new file mode 100644
index 0000000000..57cbaeb86b
--- /dev/null
+++ b/third_party/rust/pin-project/tests/include/basic.rs
@@ -0,0 +1,17 @@
+include!("basic-safe-part.rs");
+
+#[allow(clippy::undocumented_unsafe_blocks)]
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U>
+{
+}
+#[allow(clippy::undocumented_unsafe_blocks)]
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U>
+{
+}
+#[allow(clippy::undocumented_unsafe_blocks)]
+unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U>
+{
+}
diff --git a/third_party/rust/pin-project/tests/lint.rs b/third_party/rust/pin-project/tests/lint.rs
new file mode 100644
index 0000000000..35f05d50f4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/lint.rs
@@ -0,0 +1,1190 @@
+// Check interoperability with rustc and clippy lints.
+
+// for old compilers
+#![allow(unknown_lints)]
+#![warn(nonstandard_style, rust_2018_idioms, 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, rust_2021_compatibility)]
+// lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below.
+// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms
+// unsafe_op_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn.
+// non_exhaustive_omitted_patterns: unstable
+// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features
+// unused_crate_dependencies, must_not_suspend: unrelated
+// unsafe_code: checked in forbid_unsafe module
+#![warn(
+ box_pointers,
+ deprecated_in_future,
+ fuzzy_provenance_casts,
+ lossy_provenance_casts,
+ macro_use_extern_crate,
+ meta_variable_misuse,
+ missing_abi,
+ missing_copy_implementations,
+ missing_debug_implementations,
+ missing_docs,
+ non_ascii_idents,
+ noop_method_call,
+ single_use_lifetimes,
+ trivial_casts,
+ trivial_numeric_casts,
+ unreachable_pub,
+ unused_import_braces,
+ unused_lifetimes,
+ unused_qualifications,
+ unused_results,
+ unused_tuple_struct_fields,
+ variant_size_differences
+)]
+#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)]
+#![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
+#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums, clippy::single_char_lifetime_names)] // TODO
+
+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(
+ project = DefaultStructNamedProj,
+ project_ref = DefaultStructNamedProjRef,
+ )]
+ #[derive(Debug)]
+ pub struct DefaultStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project]
+ #[derive(Debug)]
+ pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = DefaultTupleStructNamedProj,
+ project_ref = DefaultTupleStructNamedProjRef,
+ )]
+ #[derive(Debug)]
+ pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = DefaultEnumProj,
+ project_ref = DefaultEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(
+ PinnedDrop,
+ project = PinnedDropEnumProj,
+ project_ref = PinnedDropEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum PinnedDropEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(
+ project = ReplaceStructNamedProj,
+ project_ref = ReplaceStructNamedProjRef,
+ project_replace = ReplaceStructNamedProjOwn,
+ )]
+ #[derive(Debug)]
+ pub struct ReplaceStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = ReplaceTupleStructNamedProj,
+ project_ref = ReplaceTupleStructNamedProjRef,
+ project_replace = ReplaceTupleStructNamedProjOwn,
+ )]
+ #[derive(Debug)]
+ pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = ReplaceEnumProj,
+ project_ref = ReplaceEnumProjRef,
+ project_replace = ReplaceEnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum ReplaceEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ UnsafeUnpin,
+ project = UnsafeUnpinEnumProj,
+ project_ref = UnsafeUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum UnsafeUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ !Unpin,
+ project = NotUnpinEnumProj,
+ project_ref = NotUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum NotUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[allow(clippy::undocumented_unsafe_blocks)]
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U>
+ {
+ }
+ #[allow(clippy::undocumented_unsafe_blocks)]
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U>
+ {
+ }
+ #[allow(clippy::undocumented_unsafe_blocks)]
+ unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
+ ::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U>
+ {
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod forbid_unsafe {
+ #![forbid(unsafe_code)]
+
+ include!("include/basic-safe-part.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(
+ project = DefaultStructNamedProj,
+ project_ref = DefaultStructNamedProjRef,
+ )]
+ #[derive(Debug)]
+ pub struct DefaultStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project]
+ #[derive(Debug)]
+ pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = DefaultTupleStructNamedProj,
+ project_ref = DefaultTupleStructNamedProjRef,
+ )]
+ #[derive(Debug)]
+ pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = DefaultEnumProj,
+ project_ref = DefaultEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum DefaultEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(PinnedDrop)]
+ #[derive(Debug)]
+ pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(
+ PinnedDrop,
+ project = PinnedDropEnumProj,
+ project_ref = PinnedDropEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum PinnedDropEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pinned_drop]
+ impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
+ fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(
+ project = ReplaceStructNamedProj,
+ project_ref = ReplaceStructNamedProjRef,
+ project_replace = ReplaceStructNamedProjOwn,
+ )]
+ #[derive(Debug)]
+ pub struct ReplaceStructNamed<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(project_replace)]
+ #[derive(Debug)]
+ pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = ReplaceTupleStructNamedProj,
+ project_ref = ReplaceTupleStructNamedProjRef,
+ project_replace = ReplaceTupleStructNamedProjOwn,
+ )]
+ #[derive(Debug)]
+ pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ project = ReplaceEnumProj,
+ project_ref = ReplaceEnumProjRef,
+ project_replace = ReplaceEnumProjOwn,
+ )]
+ #[derive(Debug)]
+ pub enum ReplaceEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(UnsafeUnpin)]
+ #[derive(Debug)]
+ pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ UnsafeUnpin,
+ project = UnsafeUnpinEnumProj,
+ project_ref = UnsafeUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum UnsafeUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinStruct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[::pin_project::pin_project(!Unpin)]
+ #[derive(Debug)]
+ pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[::pin_project::pin_project(
+ !Unpin,
+ project = NotUnpinEnumProj,
+ project_ref = NotUnpinEnumProjRef,
+ )]
+ #[derive(Debug)]
+ pub enum NotUnpinEnum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+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 deprecated {
+ use pin_project::pin_project;
+
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub struct Struct {
+ #[deprecated]
+ #[pin]
+ pub p: (),
+ #[deprecated]
+ pub u: (),
+ }
+
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub struct TupleStruct(
+ #[deprecated]
+ #[pin]
+ pub (),
+ #[deprecated] pub (),
+ );
+
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub enum Enum {
+ #[deprecated]
+ Struct {
+ #[deprecated]
+ #[pin]
+ p: (),
+ #[deprecated]
+ u: (),
+ },
+ #[deprecated]
+ Tuple(
+ #[deprecated]
+ #[pin]
+ (),
+ #[deprecated] (),
+ ),
+ #[deprecated]
+ Unit,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub struct Struct {
+ #[deprecated]
+ #[pin]
+ pub p: (),
+ #[deprecated]
+ pub u: (),
+ }
+
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(project_replace)]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub struct TupleStruct(
+ #[deprecated]
+ #[pin]
+ pub (),
+ #[deprecated] pub (),
+ );
+
+ #[allow(deprecated)] // for the type itself
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ #[derive(Debug, Clone, Copy)]
+ #[deprecated]
+ pub enum Enum {
+ #[deprecated]
+ Struct {
+ #[deprecated]
+ #[pin]
+ p: (),
+ #[deprecated]
+ u: (),
+ },
+ #[deprecated]
+ Tuple(
+ #[deprecated]
+ #[pin]
+ (),
+ #[deprecated] (),
+ ),
+ #[deprecated]
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+pub mod explicit_outlives_requirements {
+ use pin_project::pin_project;
+
+ #[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,
+ }
+
+ 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!();
+ }
+}
+
+#[allow(missing_debug_implementations)]
+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)]
+ 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)]
+ 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 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,
+ }
+
+ 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(missing_debug_implementations)]
+#[allow(unreachable_pub)]
+mod clippy_redundant_pub_crate {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[allow(dead_code)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ 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;
+
+ #[allow(clippy::redundant_pub_crate)]
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
+
+ #[allow(dead_code)]
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+#[allow(missing_debug_implementations)]
+pub mod clippy_type_repetition_in_bounds {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ pub struct Struct<T, U>
+ where
+ Self: Sized,
+ {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TupleStruct<T, U>(#[pin] T, U)
+ where
+ Self: Sized;
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum<T, U>
+ where
+ Self: Sized,
+ {
+ 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)]
+ pub struct Struct<T, U>
+ where
+ Self: Sized,
+ {
+ #[pin]
+ pub pinned: T,
+ pub unpinned: U,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TupleStruct<T, U>(#[pin] T, U)
+ where
+ Self: Sized;
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum<T, U>
+ where
+ Self: Sized,
+ {
+ Struct {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ Tuple(#[pin] T, U),
+ Unit,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+#[allow(missing_debug_implementations)]
+pub mod clippy_use_self {
+ use pin_project::pin_project;
+
+ pub trait Trait {
+ type Assoc;
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Generics<T: Trait<Assoc = Self>>
+ where
+ Self: Trait<Assoc = Self>,
+ {
+ _f: T,
+ }
+
+ pub mod inside_macro {
+ use pin_project::pin_project;
+
+ use super::Trait;
+
+ #[rustfmt::skip]
+ macro_rules! mac {
+ () => {
+ #[pin_project(project_replace)]
+ pub struct Generics<T: Trait<Assoc = Self>>
+ where
+ Self: Trait<Assoc = Self>,
+ {
+ _f: T,
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+#[allow(missing_debug_implementations)]
+pub mod clippy_used_underscore_binding {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub _pinned: T,
+ pub _unpinned: U,
+ }
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ 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)]
+ pub struct Struct<T, U> {
+ #[pin]
+ pub _pinned: T,
+ pub _unpinned: U,
+ }
+
+ #[pin_project(
+ project = EnumProj,
+ project_ref = EnumProjRef,
+ project_replace = EnumProjOwn,
+ )]
+ pub enum Enum<T, U> {
+ Struct {
+ #[pin]
+ _pinned: T,
+ _unpinned: U,
+ },
+ }
+ };
+ }
+
+ mac!();
+ }
+}
+
+#[allow(missing_debug_implementations)]
+pub mod clippy_ref_option_ref {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ pub struct Struct<'a> {
+ #[pin]
+ pub _pinned: Option<&'a ()>,
+ pub _unpinned: Option<&'a ()>,
+ }
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef)]
+ pub enum Enum<'a> {
+ Struct {
+ #[pin]
+ _pinned: Option<&'a ()>,
+ _unpinned: Option<&'a ()>,
+ },
+ }
+}
diff --git a/third_party/rust/pin-project/tests/pin_project.rs b/third_party/rust/pin-project/tests/pin_project.rs
new file mode 100644
index 0000000000..aa08056e81
--- /dev/null
+++ b/third_party/rust/pin-project/tests/pin_project.rs
@@ -0,0 +1,887 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+use std::{
+ marker::{PhantomData, PhantomPinned},
+ panic,
+ pin::Pin,
+};
+
+use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
+
+#[test]
+fn projection() {
+ #[pin_project(
+ project = StructProj,
+ project_ref = StructProjRef,
+ project_replace = StructProjOwn,
+ )]
+ struct Struct<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+ }
+
+ let mut s = Struct { f1: 1, f2: 2 };
+ let mut s_orig = Pin::new(&mut s);
+ let s = s_orig.as_mut().project();
+
+ let _: Pin<&mut i32> = s.f1;
+ assert_eq!(*s.f1, 1);
+ let _: &mut i32 = s.f2;
+ assert_eq!(*s.f2, 2);
+
+ assert_eq!(s_orig.as_ref().f1, 1);
+ assert_eq!(s_orig.as_ref().f2, 2);
+
+ let mut s = Struct { f1: 1, f2: 2 };
+ let mut s = Pin::new(&mut s);
+ {
+ let StructProj { f1, f2 } = s.as_mut().project();
+ let _: Pin<&mut i32> = f1;
+ let _: &mut i32 = f2;
+ }
+ {
+ let StructProjRef { f1, f2 } = s.as_ref().project_ref();
+ let _: Pin<&i32> = f1;
+ let _: &i32 = f2;
+ }
+ {
+ 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);
+
+ let mut s = TupleStruct(1, 2);
+ let s = Pin::new(&mut s).project();
+
+ let _: Pin<&mut i32> = s.0;
+ assert_eq!(*s.0, 1);
+ let _: &mut i32 = s.1;
+ assert_eq!(*s.1, 2);
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ #[derive(Eq, PartialEq, Debug)]
+ enum Enum<A, B, C, D> {
+ Tuple(#[pin] A, B),
+ Struct {
+ #[pin]
+ f1: C,
+ f2: D,
+ },
+ Unit,
+ }
+
+ let mut e = Enum::Tuple(1, 2);
+ let mut e = Pin::new(&mut e);
+
+ match e.as_mut().project() {
+ EnumProj::Tuple(x, y) => {
+ let x: Pin<&mut i32> = x;
+ assert_eq!(*x, 1);
+ let y: &mut i32 = y;
+ assert_eq!(*y, 2);
+ }
+ EnumProj::Struct { f1, f2 } => {
+ let _: Pin<&mut i32> = f1;
+ let _: &mut i32 = f2;
+ unreachable!();
+ }
+ EnumProj::Unit => unreachable!(),
+ }
+
+ assert_eq!(&*e, &Enum::Tuple(1, 2));
+
+ let mut e = Enum::Struct { f1: 3, f2: 4 };
+ let mut e = Pin::new(&mut e);
+
+ match e.as_mut().project() {
+ EnumProj::Tuple(x, y) => {
+ let _: Pin<&mut i32> = x;
+ let _: &mut i32 = y;
+ unreachable!();
+ }
+ EnumProj::Struct { f1, f2 } => {
+ let _: Pin<&mut i32> = f1;
+ assert_eq!(*f1, 3);
+ let _: &mut i32 = f2;
+ assert_eq!(*f2, 4);
+ }
+ EnumProj::Unit => unreachable!(),
+ }
+
+ if let EnumProj::Struct { f1, f2 } = e.as_mut().project() {
+ let _: Pin<&mut i32> = f1;
+ assert_eq!(*f1, 3);
+ let _: &mut i32 = f2;
+ assert_eq!(*f2, 4);
+ }
+}
+
+#[test]
+fn enum_project_set() {
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ #[derive(Eq, PartialEq, Debug)]
+ enum Enum {
+ V1(#[pin] u8),
+ V2(bool),
+ }
+
+ 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::V1(val) => {
+ let new_e = Enum::V2(val.as_ref().get_ref() == &25);
+ e_orig.set(new_e);
+ }
+ EnumProj::V2(_) => unreachable!(),
+ }
+
+ assert_eq!(e, Enum::V2(true));
+}
+
+#[test]
+fn where_clause() {
+ #[pin_project]
+ struct Struct<T>
+ where
+ T: Copy,
+ {
+ f: T,
+ }
+
+ #[pin_project]
+ struct TupleStruct<T>(T)
+ where
+ T: Copy;
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum<T>
+ where
+ T: Copy,
+ {
+ V(T),
+ }
+}
+
+#[test]
+fn where_clause_and_associated_type_field() {
+ #[pin_project(project_replace)]
+ struct Struct1<I>
+ where
+ I: Iterator,
+ {
+ #[pin]
+ f1: I,
+ f2: I::Item,
+ }
+
+ #[pin_project(project_replace)]
+ struct Struct2<I, J>
+ where
+ I: Iterator<Item = J>,
+ {
+ #[pin]
+ f1: I,
+ f2: J,
+ }
+
+ #[pin_project(project_replace)]
+ struct Struct3<T>
+ where
+ T: 'static,
+ {
+ f: T,
+ }
+
+ trait Static: 'static {}
+
+ impl<T> Static for Struct3<T> {}
+
+ #[pin_project(project_replace)]
+ struct TupleStruct<I>(#[pin] I, I::Item)
+ where
+ I: Iterator;
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum<I>
+ where
+ I: Iterator,
+ {
+ V1(#[pin] I),
+ V2(I::Item),
+ }
+}
+
+#[test]
+fn derive_copy() {
+ #[pin_project(project_replace)]
+ #[derive(Clone, Copy)]
+ struct Struct<T> {
+ f: T,
+ }
+
+ fn is_copy<T: Copy>() {}
+
+ is_copy::<Struct<u8>>();
+}
+
+#[test]
+fn move_out() {
+ struct NotCopy;
+
+ #[pin_project(project_replace)]
+ struct Struct {
+ f: NotCopy,
+ }
+
+ let x = Struct { f: NotCopy };
+ let _val: NotCopy = x.f;
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum {
+ V(NotCopy),
+ }
+
+ let x = Enum::V(NotCopy);
+ #[allow(clippy::infallible_destructuring_match)]
+ let _val: NotCopy = match x {
+ Enum::V(val) => val,
+ };
+}
+
+#[test]
+fn trait_bounds_on_type_generics() {
+ #[pin_project(project_replace)]
+ pub struct Struct1<'a, T: ?Sized> {
+ f: &'a mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct2<'a, T: ::core::fmt::Debug> {
+ f: &'a mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct3<'a, T: core::fmt::Debug> {
+ f: &'a mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct4<'a, T: core::fmt::Debug + core::fmt::Display> {
+ f: &'a mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct5<'a, T: core::fmt::Debug + ?Sized> {
+ f: &'a mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct6<'a, T: core::fmt::Debug = [u8; 16]> {
+ f: &'a mut T,
+ }
+
+ let _: Struct6<'_> = Struct6 { f: &mut [0_u8; 16] };
+
+ #[pin_project(project_replace)]
+ pub struct Struct7<T: 'static> {
+ f: T,
+ }
+
+ trait Static: 'static {}
+
+ impl<T> Static for Struct7<T> {}
+
+ #[pin_project(project_replace)]
+ pub struct Struct8<'a, 'b: 'a> {
+ f1: &'a u8,
+ f2: &'b u8,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct TupleStruct<'a, T: ?Sized>(&'a mut T);
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum<'a, T: ?Sized> {
+ V(&'a mut T),
+ }
+}
+
+#[test]
+fn overlapping_lifetime_names() {
+ #[pin_project(project_replace)]
+ pub struct Struct1<'pin, T> {
+ #[pin]
+ f: &'pin mut T,
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct2<'pin, 'pin_, 'pin__> {
+ #[pin]
+ f: &'pin &'pin_ &'pin__ (),
+ }
+
+ 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> Trait<'pin>,
+ for<'pin, 'pin_, 'pin__> &'pin &'pin_ &'pin__ T: Unpin,
+ {
+ #[pin]
+ 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 (),
+ }
+}
+
+#[test]
+fn combine() {
+ #[pin_project(PinnedDrop, UnsafeUnpin)]
+ pub struct PinnedDropWithUnsafeUnpin<T> {
+ #[pin]
+ f: T,
+ }
+
+ #[pinned_drop]
+ impl<T> PinnedDrop for PinnedDropWithUnsafeUnpin<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ unsafe impl<T: Unpin> UnsafeUnpin for PinnedDropWithUnsafeUnpin<T> {}
+
+ #[pin_project(PinnedDrop, !Unpin)]
+ pub struct PinnedDropWithNotUnpin<T> {
+ #[pin]
+ f: T,
+ }
+
+ #[pinned_drop]
+ impl<T> PinnedDrop for PinnedDropWithNotUnpin<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(UnsafeUnpin, project_replace)]
+ pub struct UnsafeUnpinWithReplace<T> {
+ #[pin]
+ f: T,
+ }
+
+ unsafe impl<T: Unpin> UnsafeUnpin for UnsafeUnpinWithReplace<T> {}
+
+ #[pin_project(!Unpin, project_replace)]
+ pub struct NotUnpinWithReplace<T> {
+ #[pin]
+ f: T,
+ }
+}
+
+#[test]
+fn private_type_in_public_type() {
+ #[pin_project(project_replace)]
+ pub struct PublicStruct<T> {
+ #[pin]
+ inner: PrivateStruct<T>,
+ }
+
+ struct PrivateStruct<T>(T);
+}
+
+#[allow(clippy::needless_lifetimes)]
+#[test]
+fn lifetime_project() {
+ #[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 T,
+ unpinned: U,
+ }
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum<T, U> {
+ V {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ },
+ }
+
+ impl<T, U> Struct1<T, U> {
+ fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
+ self.project_ref().pinned
+ }
+ 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> {
+ fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a &'b T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut &'b T> {
+ self.project().pinned
+ }
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&&'b T> {
+ self.project_ref().pinned
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut &'b 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::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
+ match self.project() {
+ EnumProj::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
+ match self.project_ref() {
+ EnumProjRef::V { pinned, .. } => pinned,
+ }
+ }
+ fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
+ match self.project() {
+ EnumProj::V { pinned, .. } => pinned,
+ }
+ }
+ }
+}
+
+mod visibility {
+ use pin_project::pin_project;
+
+ #[pin_project(project_replace)]
+ pub(crate) struct S {
+ pub f: u8,
+ }
+}
+
+#[test]
+fn visibility() {
+ let mut x = visibility::S { f: 0 };
+ let x = Pin::new(&mut x);
+ let y = x.as_ref().project_ref();
+ let _: &u8 = y.f;
+ let y = x.project();
+ let _: &mut u8 = y.f;
+}
+
+#[test]
+fn trivial_bounds() {
+ #[pin_project(project_replace)]
+ pub struct NoGenerics {
+ #[pin]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(NoGenerics);
+}
+
+#[test]
+fn dst() {
+ #[pin_project]
+ struct Struct1<T: ?Sized> {
+ f: T,
+ }
+
+ let mut x = Struct1 { f: 0_u8 };
+ let x: Pin<&mut Struct1<dyn core::fmt::Debug>> = Pin::new(&mut x as _);
+ let _: &mut (dyn core::fmt::Debug) = x.project().f;
+
+ #[pin_project]
+ struct Struct2<T: ?Sized> {
+ #[pin]
+ f: T,
+ }
+
+ let mut x = Struct2 { f: 0_u8 };
+ let x: Pin<&mut Struct2<dyn core::fmt::Debug + Unpin>> = Pin::new(&mut x as _);
+ 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> {
+ f: T,
+ }
+
+ #[pin_project(UnsafeUnpin)]
+ struct Struct6<T: ?Sized> {
+ #[pin]
+ f: T,
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Struct7<T: ?Sized> {
+ f: T,
+ }
+
+ #[pinned_drop]
+ impl<T: ?Sized> PinnedDrop for Struct7<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Struct8<T: ?Sized> {
+ #[pin]
+ f: T,
+ }
+
+ #[pinned_drop]
+ impl<T: ?Sized> PinnedDrop for Struct8<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(!Unpin)]
+ struct Struct9<T: ?Sized> {
+ f: T,
+ }
+
+ #[pin_project(!Unpin)]
+ struct Struct10<T: ?Sized> {
+ #[pin]
+ f: T,
+ }
+
+ #[pin_project]
+ struct Struct11<'a, T: ?Sized, U: ?Sized> {
+ f1: &'a mut T,
+ f2: U,
+ }
+
+ #[pin_project]
+ struct TupleStruct1<T: ?Sized>(T);
+
+ #[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);
+
+ #[pin_project(UnsafeUnpin)]
+ struct TupleStruct6<T: ?Sized>(#[pin] T);
+
+ #[pin_project(PinnedDrop)]
+ struct TupleStruct7<T: ?Sized>(T);
+
+ #[pinned_drop]
+ impl<T: ?Sized> PinnedDrop for TupleStruct7<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct TupleStruct8<T: ?Sized>(#[pin] T);
+
+ #[pinned_drop]
+ impl<T: ?Sized> PinnedDrop for TupleStruct8<T> {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(!Unpin)]
+ struct TupleStruct9<T: ?Sized>(T);
+
+ #[pin_project(!Unpin)]
+ struct TupleStruct10<T: ?Sized>(#[pin] T);
+
+ #[pin_project]
+ struct TupleStruct11<'a, T: ?Sized, U: ?Sized>(&'a mut T, U);
+}
+
+#[test]
+fn dyn_type() {
+ #[pin_project]
+ struct Struct1 {
+ f: dyn core::fmt::Debug,
+ }
+
+ #[pin_project]
+ struct Struct2 {
+ #[pin]
+ f: dyn core::fmt::Debug,
+ }
+
+ #[pin_project]
+ struct Struct3 {
+ f: dyn core::fmt::Debug + Send,
+ }
+
+ #[pin_project]
+ struct Struct4 {
+ #[pin]
+ f: dyn core::fmt::Debug + Send,
+ }
+
+ #[pin_project]
+ struct TupleStruct1(dyn core::fmt::Debug);
+
+ #[pin_project]
+ struct TupleStruct2(#[pin] dyn core::fmt::Debug);
+
+ #[pin_project]
+ struct TupleStruct3(dyn core::fmt::Debug + Send);
+
+ #[pin_project]
+ struct TupleStruct4(#[pin] dyn core::fmt::Debug + Send);
+}
+
+#[test]
+fn parse_self() {
+ macro_rules! mac {
+ ($($tt:tt)*) => {
+ $($tt)*
+ };
+ }
+
+ pub trait Trait {
+ type Assoc;
+ }
+
+ #[allow(clippy::type_repetition_in_bounds)]
+ #[pin_project(project_replace)]
+ pub struct Generics<T: Trait<Assoc = Self>>
+ where
+ Self: Trait<Assoc = Self>,
+ <Self as Trait>::Assoc: Sized,
+ mac!(Self): Trait<Assoc = mac!(Self)>,
+ {
+ _f: T,
+ }
+
+ impl<T: Trait<Assoc = Self>> Trait for Generics<T> {
+ type Assoc = Self;
+ }
+
+ #[pin_project(project_replace)]
+ pub struct Struct {
+ _f1: Box<Self>,
+ _f2: Box<<Self as Trait>::Assoc>,
+ _f3: Box<mac!(Self)>,
+ _f4: [(); Self::ASSOC],
+ _f5: [(); Self::assoc()],
+ _f6: [(); mac!(Self::assoc())],
+ }
+
+ impl Struct {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
+ }
+
+ impl Trait for Struct {
+ type Assoc = Self;
+ }
+
+ #[pin_project(project_replace)]
+ struct Tuple(
+ Box<Self>,
+ Box<<Self as Trait>::Assoc>,
+ Box<mac!(Self)>,
+ [(); Self::ASSOC],
+ [(); Self::assoc()],
+ [(); mac!(Self::assoc())],
+ );
+
+ impl Tuple {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
+ }
+
+ impl Trait for Tuple {
+ type Assoc = Self;
+ }
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
+ enum Enum {
+ Struct {
+ _f1: Box<Self>,
+ _f2: Box<<Self as Trait>::Assoc>,
+ _f3: Box<mac!(Self)>,
+ _f4: [(); Self::ASSOC],
+ _f5: [(); Self::assoc()],
+ _f6: [(); mac!(Self::assoc())],
+ },
+ Tuple(
+ Box<Self>,
+ Box<<Self as Trait>::Assoc>,
+ Box<mac!(Self)>,
+ [(); Self::ASSOC],
+ [(); Self::assoc()],
+ [(); mac!(Self::assoc())],
+ ),
+ }
+
+ impl Enum {
+ const ASSOC: usize = 1;
+ const fn assoc() -> usize {
+ 0
+ }
+ }
+
+ impl Trait for Enum {
+ type Assoc = Self;
+ }
+}
+
+#[test]
+fn no_infer_outlives() {
+ trait Trait<X> {
+ type Y;
+ }
+
+ struct Struct1<A>(A);
+
+ impl<X, T> Trait<X> for Struct1<T> {
+ type Y = Option<T>;
+ }
+
+ #[pin_project(project_replace)]
+ struct Struct2<A, B> {
+ _f: <Struct1<A> as Trait<B>>::Y,
+ }
+}
+
+// https://github.com/rust-lang/rust/issues/47949
+// https://github.com/taiki-e/pin-project/pull/194#discussion_r419098111
+#[allow(clippy::many_single_char_names)]
+#[test]
+fn project_replace_panic() {
+ #[pin_project(project_replace)]
+ struct S<T, U> {
+ #[pin]
+ pinned: T,
+ unpinned: U,
+ }
+
+ struct D<'a>(&'a mut bool, bool);
+ impl Drop for D<'_> {
+ fn drop(&mut self) {
+ *self.0 = true;
+ if self.1 {
+ panic!();
+ }
+ }
+ }
+
+ let (mut a, mut b, mut c, mut d) = (false, false, false, false);
+ let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
+ let mut x = S { pinned: D(&mut a, true), unpinned: D(&mut b, false) };
+ let _y = Pin::new(&mut x)
+ .project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
+ // Previous `x.pinned` was dropped and panicked when `project_replace` is
+ // called, so this is unreachable.
+ unreachable!();
+ }));
+ assert!(res.is_err());
+ assert!(a);
+ assert!(b);
+ assert!(c);
+ assert!(d);
+
+ let (mut a, mut b, mut c, mut d) = (false, false, false, false);
+ let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
+ let mut x = S { pinned: D(&mut a, false), unpinned: D(&mut b, true) };
+ {
+ let _y = Pin::new(&mut x)
+ .project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
+ // `_y` (previous `x.unpinned`) live to the end of this scope, so
+ // this is not unreachable.
+ // unreachable!();
+ }
+ unreachable!();
+ }));
+ assert!(res.is_err());
+ assert!(a);
+ assert!(b);
+ assert!(c);
+ assert!(d);
+}
diff --git a/third_party/rust/pin-project/tests/pinned_drop.rs b/third_party/rust/pin-project/tests/pinned_drop.rs
new file mode 100644
index 0000000000..99273c4234
--- /dev/null
+++ b/third_party/rust/pin-project/tests/pinned_drop.rs
@@ -0,0 +1,284 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[test]
+fn safe_project() {
+ #[pin_project(PinnedDrop)]
+ pub struct Struct<'a> {
+ was_dropped: &'a mut bool,
+ #[pin]
+ field: u8,
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Struct<'_> {
+ fn drop(self: Pin<&mut Self>) {
+ **self.project().was_dropped = true;
+ }
+ }
+
+ let mut was_dropped = false;
+ drop(Struct { was_dropped: &mut was_dropped, field: 42 });
+ assert!(was_dropped);
+}
+
+#[test]
+fn self_call() {
+ #[pin_project(PinnedDrop)]
+ pub struct S<T>(T);
+
+ trait Trait {
+ fn self_ref(&self) {}
+ fn self_pin_ref(self: Pin<&Self>) {}
+ fn self_mut(&mut self) {}
+ fn self_pin_mut(self: Pin<&mut Self>) {}
+ fn assoc_fn(_this: Pin<&mut Self>) {}
+ }
+
+ impl<T> Trait for S<T> {}
+
+ #[pinned_drop]
+ impl<T> PinnedDrop for S<T> {
+ fn drop(mut self: Pin<&mut Self>) {
+ self.self_ref();
+ self.as_ref().self_pin_ref();
+ self.self_mut();
+ self.as_mut().self_pin_mut();
+ Self::assoc_fn(self.as_mut());
+ <Self>::assoc_fn(self.as_mut());
+ }
+ }
+}
+
+#[test]
+fn self_ty() {
+ #[pin_project(PinnedDrop)]
+ pub struct Struct {
+ pub f: (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Struct {
+ #[allow(irrefutable_let_patterns)]
+ #[allow(clippy::match_single_binding)]
+ fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self { f: () };
+
+ // pat
+ match *self {
+ Self { f: () } => {}
+ }
+ if let Self { f: () } = *self {}
+ let Self { f: () } = *self;
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct TupleStruct(());
+
+ #[pinned_drop]
+ impl PinnedDrop for TupleStruct {
+ #[allow(irrefutable_let_patterns)]
+ fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self(());
+
+ // pat
+ match *self {
+ Self(_) => {}
+ }
+ if let Self(_) = *self {}
+ let Self(_) = *self;
+ }
+ }
+
+ #[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
+ pub enum Enum {
+ Struct { f: () },
+ Tuple(()),
+ Unit,
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for Enum {
+ fn drop(mut self: Pin<&mut Self>) {
+ // expr
+ let _: Self = Self::Struct { f: () };
+ let _: Self = Self::Tuple(());
+ let _: Self = Self::Unit;
+
+ // pat
+ match *self {
+ Self::Struct { f: () } => {}
+ Self::Tuple(_) => {}
+ Self::Unit => {}
+ }
+ if let Self::Struct { f: () } = *self {}
+ if let Self::Tuple(_) = *self {}
+ if let Self::Unit = *self {}
+ }
+ }
+}
+
+#[test]
+fn self_inside_macro_containing_fn() {
+ macro_rules! mac {
+ ($($tt:tt)*) => {
+ $($tt)*
+ };
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct S(());
+
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ 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 S {
+ fn drop(self: Pin<&mut Self>) {
+ macro_rules! mac {
+ () => {{
+ let _ = self;
+ let _ = Self(());
+ }};
+ }
+ mac!();
+ }
+ }
+}
+
+#[test]
+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)*
+ };
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub struct Struct<T: Send>
+ where
+ mac!(Self): Send,
+ {
+ _f: T,
+ }
+
+ impl<T: Send> Struct<T> {
+ const ASSOC1: usize = 1;
+ fn assoc1() {}
+ }
+
+ trait Trait {
+ type Assoc2;
+ const ASSOC2: usize;
+ fn assoc2();
+ }
+
+ impl<T: Send> Trait for Struct<T> {
+ type Assoc2 = u8;
+ const ASSOC2: usize = 2;
+ fn assoc2() {}
+ }
+
+ #[pinned_drop]
+ impl<T: Send> PinnedDrop for Struct<T>
+ where
+ mac!(Self): Send,
+ {
+ #[allow(path_statements)]
+ #[allow(clippy::no_effect)]
+ fn drop(self: Pin<&mut Self>) {
+ // inherent items
+ mac!(Self::ASSOC1;);
+ mac!(<Self>::ASSOC1;);
+ mac!(Self::assoc1(););
+ mac!(<Self>::assoc1(););
+
+ // trait items
+ 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() {
+ #[pin_project(PinnedDrop)]
+ struct S(());
+
+ macro_rules! mac {
+ ($expr:expr) => {
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ let _ = $expr;
+ }
+ }
+ };
+ }
+
+ mac!(1);
+}
+
+pub mod self_path {
+ use super::*;
+
+ #[pin_project(PinnedDrop)]
+ pub struct S<T: Unpin>(T);
+
+ fn f() {}
+
+ #[pinned_drop]
+ impl<T: Unpin> PinnedDrop for self::S<T> {
+ fn drop(mut self: Pin<&mut Self>) {
+ self::f();
+ let _: self::S<()> = self::S(());
+ let _: self::S<Pin<&mut Self>> = self::S(self.as_mut());
+ let self::S(()) = self::S(());
+ let self::S(&mut Self(_)) = self::S(&mut *self);
+ }
+ }
+}
diff --git a/third_party/rust/pin-project/tests/proper_unpin.rs b/third_party/rust/pin-project/tests/proper_unpin.rs
new file mode 100644
index 0000000000..0ba3ce3b5d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/proper_unpin.rs
@@ -0,0 +1,153 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+pub mod default {
+ use std::marker::PhantomPinned;
+
+ use pin_project::pin_project;
+
+ struct Inner<T> {
+ f: T,
+ }
+
+ assert_unpin!(Inner<()>);
+ assert_not_unpin!(Inner<PhantomPinned>);
+
+ #[pin_project]
+ struct Struct<T, U> {
+ #[pin]
+ f1: Inner<T>,
+ f2: U,
+ }
+
+ assert_unpin!(Struct<(), ()>);
+ assert_unpin!(Struct<(), PhantomPinned>);
+ assert_not_unpin!(Struct<PhantomPinned, ()>);
+ assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>);
+
+ #[pin_project(project = EnumProj, project_ref = EnumProjRef)]
+ enum Enum<T, U> {
+ V1 {
+ #[pin]
+ f1: Inner<T>,
+ f2: U,
+ },
+ }
+
+ assert_unpin!(Enum<(), ()>);
+ assert_unpin!(Enum<(), PhantomPinned>);
+ assert_not_unpin!(Enum<PhantomPinned, ()>);
+ assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>);
+
+ #[pin_project]
+ struct TrivialBounds {
+ #[pin]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(TrivialBounds);
+
+ #[pin_project]
+ struct PinRef<'a, T, U> {
+ #[pin]
+ f1: &'a mut Inner<T>,
+ f2: U,
+ }
+
+ assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>);
+}
+
+pub mod cfg {
+ use std::marker::PhantomPinned;
+
+ use pin_project::pin_project;
+
+ #[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 std::marker::PhantomPinned;
+
+ use pin_project::pin_project;
+
+ #[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 std::marker::PhantomPinned;
+
+ use pin_project::pin_project;
+
+ struct Inner<T> {
+ f: T,
+ }
+
+ #[pin_project(!Unpin)]
+ struct Struct<T, U> {
+ #[pin]
+ inner: Inner<T>,
+ other: U,
+ }
+
+ assert_not_unpin!(Struct<(), ()>);
+ assert_not_unpin!(Struct<(), PhantomPinned>);
+ assert_not_unpin!(Struct<PhantomPinned, ()>);
+ assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>);
+
+ #[pin_project(!Unpin)]
+ struct TrivialBounds {
+ #[pin]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(TrivialBounds);
+
+ #[pin_project(!Unpin)]
+ struct PinRef<'a, T, U> {
+ #[pin]
+ inner: &'a mut Inner<T>,
+ other: U,
+ }
+
+ assert_not_unpin!(PinRef<'_, (), ()>);
+}
diff --git a/third_party/rust/pin-project/tests/repr_packed.rs b/third_party/rust/pin-project/tests/repr_packed.rs
new file mode 100644
index 0000000000..be7cab975f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/repr_packed.rs
@@ -0,0 +1,52 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+// unaligned_references did not exist in older compilers and safe_packed_borrows was removed in the latest compilers.
+// https://github.com/rust-lang/rust/pull/82525
+#![allow(unknown_lints, renamed_and_removed_lints)]
+#![forbid(unaligned_references, safe_packed_borrows)]
+
+use std::cell::Cell;
+
+// Ensure that the compiler doesn't copy the fields
+// of #[repr(packed)] types during drop, if the field has alignment 1
+// (that is, any reference to the field is guaranteed to have proper alignment)
+// We are currently unable to statically prevent the usage of #[pin_project]
+// on #[repr(packed)] types composed entirely of fields of alignment 1.
+// This shouldn't lead to undefined behavior, as long as the compiler doesn't
+// try to move the field anyway during drop.
+//
+// This tests validates that the compiler is doing what we expect.
+#[test]
+fn weird_repr_packed() {
+ // We keep track of the field address during
+ // drop using a thread local, to avoid changing
+ // the layout of our #[repr(packed)] type.
+ thread_local! {
+ static FIELD_ADDR: Cell<usize> = Cell::new(0);
+ }
+
+ #[repr(packed)]
+ struct Struct {
+ field: u8,
+ }
+
+ impl Drop for Struct {
+ fn drop(&mut self) {
+ FIELD_ADDR.with(|f| {
+ f.set(&self.field as *const u8 as usize);
+ });
+ }
+ }
+
+ #[allow(clippy::let_and_return)]
+ let field_addr = {
+ // We let this field drop by going out of scope,
+ // rather than explicitly calling drop(foo).
+ // Calling drop(foo) causes 'foo' to be moved
+ // into the 'drop' function, resulting in a different
+ // address.
+ let x = Struct { field: 27 };
+ let field_addr = &x.field as *const u8 as usize;
+ field_addr
+ };
+ assert_eq!(field_addr, FIELD_ADDR.with(Cell::get));
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs
new file mode 100644
index 0000000000..e36cc9593a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.rs
@@ -0,0 +1,11 @@
+use std::pin::Pin;
+
+#[cfg_attr(any(), pin_project::pin_project)]
+struct Foo<T> {
+ f: T,
+}
+
+fn main() {
+ let mut x = Foo { f: 0_u8 };
+ let _ = Pin::new(&mut x).project(); //~ ERROR E0599
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr
new file mode 100644
index 0000000000..0393c143fe
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-resolve.stderr
@@ -0,0 +1,5 @@
+error[E0599]: no method named `project` found for struct `Pin<&mut Foo<u8>>` in the current scope
+ --> tests/ui/cfg/cfg_attr-resolve.rs:10:30
+ |
+10 | let _ = Pin::new(&mut x).project(); //~ ERROR E0599
+ | ^^^^^^^ method not found in `Pin<&mut Foo<u8>>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs
new file mode 100644
index 0000000000..1b9664b544
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.rs
@@ -0,0 +1,25 @@
+use std::pin::Pin;
+
+use pin_project::pin_project;
+
+#[cfg_attr(not(any()), pin_project)]
+struct Foo<T> {
+ #[cfg_attr(any(), pin)]
+ f: T,
+}
+
+#[cfg_attr(not(any()), pin_project)]
+struct Bar<T> {
+ #[cfg_attr(not(any()), pin)]
+ f: T,
+}
+
+fn main() {
+ let mut x = Foo { f: 0_u8 };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut u8> = x.f; //~ ERROR E0308
+
+ let mut x = Bar { f: 0_u8 };
+ let x = Pin::new(&mut x).project();
+ let _: &mut u8 = x.f; //~ ERROR E0308
+}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr
new file mode 100644
index 0000000000..366d9c74cb
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/cfg_attr-type-mismatch.stderr
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+ --> tests/ui/cfg/cfg_attr-type-mismatch.rs:20:27
+ |
+20 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308
+ | ------------ ^^^ expected struct `Pin`, found `&mut u8`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Pin<&mut u8>`
+ found mutable reference `&mut u8`
+
+error[E0308]: mismatched types
+ --> tests/ui/cfg/cfg_attr-type-mismatch.rs:24:22
+ |
+24 | let _: &mut u8 = x.f; //~ ERROR E0308
+ | ------- ^^^
+ | | |
+ | | 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 `Pin<&mut u8>`
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs
new file mode 100644
index 0000000000..7e19952b6d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.rs
@@ -0,0 +1,15 @@
+use auxiliary_macro::hidden_repr;
+use pin_project::pin_project;
+
+#[pin_project]
+#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
+struct S {
+ #[cfg(not(any()))]
+ #[pin]
+ f: u32,
+ #[cfg(any())]
+ #[pin]
+ f: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr
new file mode 100644
index 0000000000..4f3acc3494
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-1.stderr
@@ -0,0 +1,5 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/cfg/packed_sneaky-span-issue-1.rs:5:15
+ |
+5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs
new file mode 100644
index 0000000000..fcea76bab8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.rs
@@ -0,0 +1,15 @@
+use auxiliary_macro::hidden_repr;
+use pin_project::pin_project;
+
+#[pin_project]
+#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
+struct S {
+ #[cfg(any())]
+ #[pin]
+ f: u32,
+ #[cfg(not(any()))]
+ #[pin]
+ f: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr
new file mode 100644
index 0000000000..cc2795ac68
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky-span-issue-2.stderr
@@ -0,0 +1,5 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/cfg/packed_sneaky-span-issue-2.rs:5:15
+ |
+5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs
new file mode 100644
index 0000000000..0b01dc90e2
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.rs
@@ -0,0 +1,12 @@
+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 S {
+ #[pin]
+ f: u32,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr
new file mode 100644
index 0000000000..a54c2ec2d2
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/packed_sneaky.stderr
@@ -0,0 +1,5 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/cfg/packed_sneaky.rs:6:27
+ |
+6 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs
new file mode 100644
index 0000000000..b950d4b828
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.rs
@@ -0,0 +1,11 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct S {
+ //~^ ERROR may not be used on structs with zero fields
+ #[cfg(any())]
+ #[pin]
+ f: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr
new file mode 100644
index 0000000000..e1c871c011
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/cfg/unsupported.stderr
@@ -0,0 +1,11 @@
+error: #[pin_project] attribute may not be used on structs with zero fields
+ --> tests/ui/cfg/unsupported.rs:4:10
+ |
+4 | struct S {
+ | __________^
+5 | | //~^ ERROR may not be used on structs with zero fields
+6 | | #[cfg(any())]
+7 | | #[pin]
+8 | | f: u8,
+9 | | }
+ | |_^
diff --git a/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.rs b/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.rs
new file mode 100644
index 0000000000..8985f37103
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.rs
@@ -0,0 +1,30 @@
+use pin_project::pin_project;
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T, U> Unpin for Bar<T, U> {}
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.stderr b/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.stderr
new file mode 100644
index 0000000000..d79fbfb9e3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/not_unpin/conflict-unpin.stderr
@@ -0,0 +1,26 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
+ --> tests/ui/not_unpin/conflict-unpin.rs:3:15
+ |
+3 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
+ | ------------------------------ first implementation here
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
+ --> tests/ui/not_unpin/conflict-unpin.rs:12:15
+ |
+12 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+19 | impl<T, U> Unpin for Bar<T, U> {}
+ | ------------------------------ first implementation here
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
+ --> tests/ui/not_unpin/conflict-unpin.rs:21:15
+ |
+21 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+28 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
+ | -------------------------------------------- first implementation here
diff --git a/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.rs b/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.rs
new file mode 100644
index 0000000000..2c078c71ff
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.rs
@@ -0,0 +1,30 @@
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
+
+#[pin_project(!Unpin)] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.stderr b/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.stderr
new file mode 100644
index 0000000000..93f225eb75
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/not_unpin/impl-unsafe-unpin.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Foo<_, _>`
+ --> tests/ui/not_unpin/impl-unsafe-unpin.rs:3:1
+ |
+3 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+10 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
+ | ------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Bar<_, _>`
+ --> tests/ui/not_unpin/impl-unsafe-unpin.rs:12:1
+ |
+12 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+19 | unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
+ | ------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Baz<_, _>`
+ --> tests/ui/not_unpin/impl-unsafe-unpin.rs:21:1
+ |
+21 | #[pin_project(!Unpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+28 | unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
+ | --------------------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs
new file mode 100644
index 0000000000..045e79664d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.rs
@@ -0,0 +1,20 @@
+use std::marker::PhantomPinned;
+
+use auxiliary_macro::add_pin_attr;
+use pin_project::pin_project;
+
+#[pin_project]
+#[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute
+struct Foo {
+ #[pin]
+ f: PhantomPinned,
+}
+
+#[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
+#[pin_project]
+struct Bar {
+ #[pin]
+ f: PhantomPinned,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr
new file mode 100644
index 0000000000..6fb88e8059
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-attr-to-struct.stderr
@@ -0,0 +1,15 @@
+error: duplicate #[pin] attribute
+ --> tests/ui/pin_project/add-attr-to-struct.rs:7:1
+ |
+7 | #[add_pin_attr(struct)] //~ ERROR duplicate #[pin] attribute
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the attribute macro `add_pin_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> tests/ui/pin_project/add-attr-to-struct.rs:13:1
+ |
+13 | #[add_pin_attr(struct)] //~ ERROR #[pin] attribute may only be used on fields of structs or variants
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the attribute macro `add_pin_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs
new file mode 100644
index 0000000000..c415f9c904
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.rs
@@ -0,0 +1,23 @@
+use auxiliary_macro::add_pinned_field;
+use pin_project::pin_project;
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[add_pinned_field]
+struct Foo {
+ #[pin]
+ f: u32,
+}
+
+#[add_pinned_field]
+#[pin_project]
+struct Bar {
+ #[pin]
+ f: u32,
+}
+
+fn main() {
+ is_unpin::<Foo>(); //~ ERROR E0277
+ is_unpin::<Bar>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr
new file mode 100644
index 0000000000..d0832cced8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/add-pinned-field.stderr
@@ -0,0 +1,52 @@
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/add-pinned-field.rs:21:5
+ |
+21 | is_unpin::<Foo>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `__Foo<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `__Foo<'_>`
+ --> tests/ui/pin_project/add-pinned-field.rs:8:8
+ |
+8 | struct Foo {
+ | ^^^
+note: required because of the requirements on the impl of `Unpin` for `Foo`
+ --> tests/ui/pin_project/add-pinned-field.rs:6:1
+ |
+6 | #[pin_project]
+ | ^^^^^^^^^^^^^^
+7 | #[add_pinned_field]
+8 | struct Foo {
+ | ^^^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/add-pinned-field.rs:4:16
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/add-pinned-field.rs:22:5
+ |
+22 | is_unpin::<Bar>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^ within `__Bar<'_>`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `__Bar<'_>`
+ --> tests/ui/pin_project/add-pinned-field.rs:15:8
+ |
+15 | struct Bar {
+ | ^^^
+note: required because of the requirements on the impl of `Unpin` for `Bar`
+ --> tests/ui/pin_project/add-pinned-field.rs:14:1
+ |
+14 | #[pin_project]
+ | ^^^^^^^^^^^^^^
+15 | struct Bar {
+ | ^^^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/add-pinned-field.rs:4:16
+ |
+4 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs
new file mode 100644
index 0000000000..4fdb118d06
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.rs
@@ -0,0 +1,32 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T, U> Drop for Foo<T, U> {
+ fn drop(&mut self) {}
+}
+
+#[pin_project(PinnedDrop)] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+#[pinned_drop]
+impl<T, U> PinnedDrop for Bar<T, U> {
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+impl<T, U> Drop for Bar<T, U> {
+ fn drop(&mut self) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr
new file mode 100644
index 0000000000..4ae628da75
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-drop.stderr
@@ -0,0 +1,19 @@
+error[E0119]: conflicting implementations of trait `_::FooMustNotImplDrop` for type `Foo<_, _>`
+ --> tests/ui/pin_project/conflict-drop.rs:5:1
+ |
+5 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^
+ | |
+ | first implementation here
+ | conflicting implementation for `Foo<_, _>`
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `Bar<_, _>`
+ --> tests/ui/pin_project/conflict-drop.rs:16:15
+ |
+16 | #[pin_project(PinnedDrop)] //~ ERROR E0119
+ | ^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+28 | impl<T, U> Drop for Bar<T, U> {
+ | ----------------------------- first implementation here
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs
new file mode 100644
index 0000000000..f58c45e09f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.rs
@@ -0,0 +1,37 @@
+use pin_project::pin_project;
+
+// The same implementation.
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+// conflicting implementations
+impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
+
+// The implementation that under different conditions.
+
+#[pin_project] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+// conflicting implementations
+impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
+
+#[pin_project] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+// conflicting implementations
+impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr
new file mode 100644
index 0000000000..7df5db272f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/conflict-unpin.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:5:1
+ |
+5 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+13 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
+ | ------------------------------ first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:17:1
+ |
+17 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+25 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
+ | ------------------------------ first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
+ --> tests/ui/pin_project/conflict-unpin.rs:27:1
+ |
+27 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+35 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
+ | -------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.rs b/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.rs
new file mode 100644
index 0000000000..562c9b64f6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.rs
@@ -0,0 +1,30 @@
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
+
+#[pin_project] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
+
+#[pin_project] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.stderr b/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.stderr
new file mode 100644
index 0000000000..9554b9b5df
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/impl-unsafe-unpin.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Foo<_, _>`
+ --> tests/ui/pin_project/impl-unsafe-unpin.rs:3:1
+ |
+3 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+10 | unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
+ | ------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Bar<_, _>`
+ --> tests/ui/pin_project/impl-unsafe-unpin.rs:12:1
+ |
+12 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+19 | unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
+ | ------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0119]: conflicting implementations of trait `_::_pin_project::UnsafeUnpin` for type `Baz<_, _>`
+ --> tests/ui/pin_project/impl-unsafe-unpin.rs:21:1
+ |
+21 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+28 | unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
+ | --------------------------------------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.rs b/third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.rs
new file mode 100644
index 0000000000..7926e61a63
--- /dev/null
+++ b/third_party/rust/pin-project/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/third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.stderr b/third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.stderr
new file mode 100644
index 0000000000..260a35a5c0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/import_unnamed.stderr
@@ -0,0 +1,29 @@
+error[E0432]: unresolved import `crate::pub_::__DefaultProjection`
+ --> tests/ui/pin_project/import_unnamed.rs:16:9
+ |
+16 | use crate::pub_::__DefaultProjection; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjection` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__DefaultProjectionRef`
+ --> tests/ui/pin_project/import_unnamed.rs:18:9
+ |
+18 | use crate::pub_::__DefaultProjectionRef; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__DefaultProjectionRef` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjection`
+ --> tests/ui/pin_project/import_unnamed.rs:20:9
+ |
+20 | use crate::pub_::__ReplaceProjection; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjection` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionOwned`
+ --> tests/ui/pin_project/import_unnamed.rs:22:9
+ |
+22 | use crate::pub_::__ReplaceProjectionOwned; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionOwned` in `pub_`
+
+error[E0432]: unresolved import `crate::pub_::__ReplaceProjectionRef`
+ --> tests/ui/pin_project/import_unnamed.rs:24:9
+ |
+24 | use crate::pub_::__ReplaceProjectionRef; //~ ERROR E0432
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `__ReplaceProjectionRef` in `pub_`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs b/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs
new file mode 100644
index 0000000000..d39a1fd4c9
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/invalid.rs
@@ -0,0 +1,280 @@
+mod pin_argument {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ struct Struct {
+ #[pin()] //~ ERROR unexpected token
+ f: (),
+ }
+
+ #[pin_project]
+ struct TupleStruct(#[pin(foo)] ()); //~ ERROR unexpected token
+
+ #[pin_project]
+ enum EnumTuple {
+ V(#[pin(foo)] ()), //~ ERROR unexpected token
+ }
+
+ #[pin_project]
+ enum EnumStruct {
+ V {
+ #[pin(foo)] //~ ERROR unexpected token
+ f: (),
+ },
+ }
+}
+
+mod pin_attribute {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ struct DuplicateStruct {
+ #[pin]
+ #[pin] //~ ERROR duplicate #[pin] attribute
+ f: (),
+ }
+
+ #[pin_project]
+ struct DuplicateTupleStruct(
+ #[pin]
+ #[pin]
+ (),
+ //~^^ ERROR duplicate #[pin] attribute
+ );
+
+ #[pin_project]
+ enum DuplicateEnumTuple {
+ V(
+ #[pin]
+ #[pin]
+ (),
+ //~^^ ERROR duplicate #[pin] attribute
+ ),
+ }
+
+ #[pin_project]
+ enum DuplicateEnumStruct {
+ V {
+ #[pin]
+ #[pin] //~ ERROR duplicate #[pin] attribute
+ f: (),
+ },
+ }
+}
+
+mod pin_item {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ #[pin] //~ ERROR may only be used on fields of structs or variants
+ struct Struct {
+ #[pin]
+ f: (),
+ }
+
+ #[pin_project]
+ enum Variant {
+ #[pin] //~ ERROR may only be used on fields of structs or variants
+ V(()),
+ }
+
+ #[pin_project]
+ #[pin] //~ ERROR may only be used on fields of structs or variants
+ enum Enum {
+ V(()),
+ }
+}
+
+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] ());
+
+ #[pin_project(Foo)] //~ ERROR unexpected argument
+ struct Unexpected2(#[pin] ());
+
+ #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
+ struct Unexpected3(#[pin] ());
+
+ #[pin_project()] // Ok
+ struct Unexpected4(#[pin] ());
+
+ #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
+ struct Unexpected5(#[pin] ());
+
+ #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+ struct DuplicatePinnedDrop(#[pin] ());
+
+ #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ struct DuplicateUnsafeUnpin(#[pin] ());
+
+ #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
+ struct DuplicateNotUnpin(#[pin] ());
+
+ #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ struct Duplicate3(#[pin] ());
+
+ #[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 = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
+ struct DuplicateProject2(#[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 DuplicateProjectReplace1(#[pin] ());
+
+ #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ struct DuplicateProjectReplace2(#[pin] ());
+
+ #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
+ struct DuplicateProjectReplace3(#[pin] ());
+
+ #[pin_project(project_replace = A)] // Ok
+ struct ProjectReplaceWithoutReplace(#[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(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ struct UnsafeUnpinWithNotUnpin1(#[pin] ());
+
+ #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ struct UnsafeUnpinWithNotUnpin2(#[pin] ());
+
+ #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
+ struct NotUnpin1(#[pin] ());
+
+ #[pin_project(Unpin)] //~ ERROR unexpected argument
+ struct NotUnpin2(#[pin] ());
+
+ #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
+ struct Project1(#[pin] ());
+
+ #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
+ struct Project2(#[pin] ());
+
+ #[pin_project(project = !)] //~ ERROR expected identifier
+ struct Project3(#[pin] ());
+
+ #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
+ struct ProjectRef1(#[pin] ());
+
+ #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
+ struct ProjectRef2(#[pin] ());
+
+ #[pin_project(project_ref = !)] //~ ERROR expected identifier
+ struct ProjectRef3(#[pin] ());
+
+ #[pin_project(project_replace)] // Ok
+ struct ProjectReplace1(#[pin] ());
+
+ #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
+ struct ProjectReplace2(#[pin] ());
+
+ #[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] ());
+
+ #[pin_project(project = A, project_replace = A)] //~ ERROR name `A` is already specified by `project` argument
+ struct ProjAndProjOwn(#[pin] ());
+
+ #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
+ struct ProjRefAndProjOwn(#[pin] ());
+}
+
+mod pin_project_attribute {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ #[pin_project] //~ ERROR duplicate #[pin_project] attribute
+ struct Duplicate(#[pin] ());
+}
+
+mod pin_project_item {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ struct Struct {} //~ ERROR may not be used on structs with zero fields
+
+ #[pin_project]
+ struct TupleStruct(); //~ ERROR may not be used on structs with zero fields
+
+ #[pin_project]
+ struct UnitStruct; //~ ERROR may not be used on structs with zero fields
+
+ #[pin_project]
+ enum EnumEmpty {} //~ ERROR may not be used on enums without variants
+
+ #[pin_project]
+ enum EnumDiscriminant {
+ V = 2, //~ ERROR may not be used on enums with discriminants
+ }
+
+ #[pin_project]
+ enum EnumZeroFields {
+ Unit, //~ ERROR may not be used on enums with zero fields
+ Tuple(),
+ Struct {},
+ }
+
+ #[pin_project]
+ union Union {
+ //~^ 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.
+mod pin_project_item_packed {
+ use pin_project::pin_project;
+
+ #[pin_project]
+ #[repr(packed)]
+ struct Struct {} //~ ERROR may not be used on #[repr(packed)] types
+
+ #[pin_project]
+ #[repr(packed)]
+ struct TupleStruct(); //~ ERROR may not be used on #[repr(packed)] types
+
+ #[pin_project]
+ #[repr(packed)]
+ struct UnitStruct; //~ ERROR may not be used on #[repr(packed)] types
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr b/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr
new file mode 100644
index 0000000000..c43d363de8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/invalid.stderr
@@ -0,0 +1,364 @@
+error: unexpected token: `()`
+ --> tests/ui/pin_project/invalid.rs:6:14
+ |
+6 | #[pin()] //~ ERROR unexpected token
+ | ^^
+
+error: unexpected token: `(foo)`
+ --> tests/ui/pin_project/invalid.rs:11:29
+ |
+11 | struct TupleStruct(#[pin(foo)] ()); //~ ERROR unexpected token
+ | ^^^^^
+
+error: unexpected token: `(foo)`
+ --> tests/ui/pin_project/invalid.rs:15:16
+ |
+15 | V(#[pin(foo)] ()), //~ ERROR unexpected token
+ | ^^^^^
+
+error: unexpected token: `(foo)`
+ --> tests/ui/pin_project/invalid.rs:21:18
+ |
+21 | #[pin(foo)] //~ ERROR unexpected token
+ | ^^^^^
+
+error: duplicate #[pin] attribute
+ --> tests/ui/pin_project/invalid.rs:33:9
+ |
+33 | #[pin] //~ ERROR duplicate #[pin] attribute
+ | ^^^^^^
+
+error: duplicate #[pin] attribute
+ --> tests/ui/pin_project/invalid.rs:40:9
+ |
+40 | #[pin]
+ | ^^^^^^
+
+error: duplicate #[pin] attribute
+ --> tests/ui/pin_project/invalid.rs:49:13
+ |
+49 | #[pin]
+ | ^^^^^^
+
+error: duplicate #[pin] attribute
+ --> tests/ui/pin_project/invalid.rs:59:13
+ |
+59 | #[pin] //~ ERROR duplicate #[pin] attribute
+ | ^^^^^^
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> tests/ui/pin_project/invalid.rs:69:5
+ |
+69 | #[pin] //~ ERROR may only be used on fields of structs or variants
+ | ^^^^^^
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> tests/ui/pin_project/invalid.rs:77:9
+ |
+77 | #[pin] //~ ERROR may only be used on fields of structs or variants
+ | ^^^^^^
+
+error: #[pin] attribute may only be used on fields of structs or variants
+ --> tests/ui/pin_project/invalid.rs:82:5
+ |
+82 | #[pin] //~ ERROR may only be used on fields of structs or variants
+ | ^^^^^^
+
+error: `Replace` argument was removed, use `project_replace` argument instead
+ --> tests/ui/pin_project/invalid.rs:91:19
+ |
+91 | #[pin_project(Replace)] //~ ERROR `Replace` argument was removed, use `project_replace` argument instead
+ | ^^^^^^^
+
+error: expected identifier
+ --> tests/ui/pin_project/invalid.rs:94:31
+ |
+94 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
+ | ^
+
+error: unexpected argument: Foo
+ --> tests/ui/pin_project/invalid.rs:97:19
+ |
+97 | #[pin_project(Foo)] //~ ERROR unexpected argument
+ | ^^^
+
+error: expected identifier
+ --> tests/ui/pin_project/invalid.rs:100:19
+ |
+100 | #[pin_project(,UnsafeUnpin)] //~ ERROR expected identifier
+ | ^
+
+error: expected `,`
+ --> tests/ui/pin_project/invalid.rs:106:30
+ |
+106 | #[pin_project(PinnedDrop PinnedDrop)] //~ ERROR expected `,`
+ | ^^^^^^^^^^
+
+error: duplicate `PinnedDrop` argument
+ --> tests/ui/pin_project/invalid.rs:109:31
+ |
+109 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
+ | ^^^^^^^^^^
+
+error: duplicate `UnsafeUnpin` argument
+ --> tests/ui/pin_project/invalid.rs:112:32
+ |
+112 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `!Unpin` argument
+ --> tests/ui/pin_project/invalid.rs:115:27
+ |
+115 | #[pin_project(!Unpin, !Unpin)] //~ ERROR duplicate `!Unpin` argument
+ | ^^^^^^
+
+error: duplicate `UnsafeUnpin` argument
+ --> tests/ui/pin_project/invalid.rs:118:44
+ |
+118 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `PinnedDrop` argument
+ --> tests/ui/pin_project/invalid.rs:121:44
+ |
+121 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, UnsafeUnpin)] //~ ERROR duplicate `PinnedDrop` argument
+ | ^^^^^^^^^^
+
+error: duplicate `project` argument
+ --> tests/ui/pin_project/invalid.rs:124:32
+ |
+124 | #[pin_project(project = A, project = B)] //~ ERROR duplicate `project` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `project` argument
+ --> tests/ui/pin_project/invalid.rs:127:49
+ |
+127 | #[pin_project(project = A, project_ref = A, project = B)] //~ ERROR duplicate `project` argument
+ | ^^^^^^^^^^^
+
+error: duplicate `project_ref` argument
+ --> tests/ui/pin_project/invalid.rs:130:36
+ |
+130 | #[pin_project(project_ref = A, project_ref = B)] //~ ERROR duplicate `project_ref` argument
+ | ^^^^^^^^^^^^^^^
+
+error: duplicate `project_replace` argument
+ --> tests/ui/pin_project/invalid.rs:133:40
+ |
+133 | #[pin_project(project_replace = A, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: duplicate `project_replace` argument
+ --> tests/ui/pin_project/invalid.rs:136:36
+ |
+136 | #[pin_project(project_replace, project_replace = B)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: duplicate `project_replace` argument
+ --> tests/ui/pin_project/invalid.rs:139:40
+ |
+139 | #[pin_project(project_replace = A, project_replace)] //~ ERROR duplicate `project_replace` argument
+ | ^^^^^^^^^^^^^^^
+
+error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ --> tests/ui/pin_project/invalid.rs:145:19
+ |
+145 | #[pin_project(PinnedDrop, project_replace)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ | ^^^^^^^^^^
+
+error: arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ --> tests/ui/pin_project/invalid.rs:148:49
+ |
+148 | #[pin_project(project_replace, UnsafeUnpin, PinnedDrop)] //~ ERROR arguments `PinnedDrop` and `project_replace` are mutually exclusive
+ | ^^^^^^^^^^
+
+error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ --> tests/ui/pin_project/invalid.rs:151:19
+ |
+151 | #[pin_project(UnsafeUnpin, !Unpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ | ^^^^^^^^^^^
+
+error: arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ --> tests/ui/pin_project/invalid.rs:154:39
+ |
+154 | #[pin_project(!Unpin, PinnedDrop, UnsafeUnpin)] //~ ERROR arguments `UnsafeUnpin` and `!Unpin` are mutually exclusive
+ | ^^^^^^^^^^^
+
+error: expected `!Unpin`, found `!`
+ --> tests/ui/pin_project/invalid.rs:157:19
+ |
+157 | #[pin_project(!)] //~ ERROR expected `!Unpin`, found `!`
+ | ^
+
+error: unexpected argument: Unpin
+ --> tests/ui/pin_project/invalid.rs:160:19
+ |
+160 | #[pin_project(Unpin)] //~ ERROR unexpected argument
+ | ^^^^^
+
+error: expected `project = <identifier>`, found `project`
+ --> tests/ui/pin_project/invalid.rs:163:19
+ |
+163 | #[pin_project(project)] //~ ERROR expected `project = <identifier>`, found `project`
+ | ^^^^^^^
+
+error: expected `project = <identifier>`, found `project =`
+ --> tests/ui/pin_project/invalid.rs:166:19
+ |
+166 | #[pin_project(project = )] //~ ERROR expected `project = <identifier>`, found `project =`
+ | ^^^^^^^^^
+
+error: expected identifier
+ --> tests/ui/pin_project/invalid.rs:169:29
+ |
+169 | #[pin_project(project = !)] //~ ERROR expected identifier
+ | ^
+
+error: expected `project_ref = <identifier>`, found `project_ref`
+ --> tests/ui/pin_project/invalid.rs:172:19
+ |
+172 | #[pin_project(project_ref)] //~ ERROR expected `project_ref = <identifier>`, found `project_ref`
+ | ^^^^^^^^^^^
+
+error: expected `project_ref = <identifier>`, found `project_ref =`
+ --> tests/ui/pin_project/invalid.rs:175:19
+ |
+175 | #[pin_project(project_ref = )] //~ ERROR expected `project_ref = <identifier>`, found `project_ref =`
+ | ^^^^^^^^^^^^^
+
+error: expected identifier
+ --> tests/ui/pin_project/invalid.rs:178:33
+ |
+178 | #[pin_project(project_ref = !)] //~ ERROR expected identifier
+ | ^
+
+error: expected `project_replace = <identifier>`, found `project_replace =`
+ --> tests/ui/pin_project/invalid.rs:184:19
+ |
+184 | #[pin_project(project_replace = )] //~ ERROR expected `project_replace = <identifier>`, found `project_replace =`
+ | ^^^^^^^^^^^^^^^^^
+
+error: expected identifier
+ --> tests/ui/pin_project/invalid.rs:187:37
+ |
+187 | #[pin_project(project_replace = !)] //~ ERROR expected identifier
+ | ^
+
+error: `project_replace` argument requires a value when used on enums
+ --> tests/ui/pin_project/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
+ --> tests/ui/pin_project/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
+ --> tests/ui/pin_project/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
+ --> tests/ui/pin_project/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
+ --> tests/ui/pin_project/invalid.rs:208:46
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:211:50
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:214:54
+ |
+214 | #[pin_project(project_ref = A, project_replace = A)] //~ ERROR name `A` is already specified by `project_ref` argument
+ | ^
+
+error: duplicate #[pin_project] attribute
+ --> tests/ui/pin_project/invalid.rs:222:5
+ |
+222 | #[pin_project] //~ ERROR duplicate #[pin_project] attribute
+ | ^^^^^^^^^^^^^^
+
+error: #[pin_project] attribute may not be used on structs with zero fields
+ --> tests/ui/pin_project/invalid.rs:230:19
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:233:23
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:236:12
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:239:20
+ |
+239 | enum EnumEmpty {} //~ ERROR may not be used on enums without variants
+ | ^^
+
+error: #[pin_project] attribute may not be used on enums with discriminants
+ --> tests/ui/pin_project/invalid.rs:243:13
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:248:9
+ |
+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
+ --> tests/ui/pin_project/invalid.rs:254:5
+ |
+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
+ --> tests/ui/pin_project/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
+ --> tests/ui/pin_project/invalid.rs:268:12
+ |
+268 | #[repr(packed)]
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/invalid.rs:272:12
+ |
+272 | #[repr(packed)]
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/invalid.rs:276:12
+ |
+276 | #[repr(packed)]
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs
new file mode 100644
index 0000000000..abfd5d1344
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.rs
@@ -0,0 +1,19 @@
+use std::marker::PhantomPinned;
+
+use pin_project::pin_project;
+
+#[pin_project]
+struct S<T> {
+ #[pin]
+ f: T,
+}
+
+struct __S {}
+
+impl Unpin for __S {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr
new file mode 100644
index 0000000000..1bd200d9c8
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -0,0 +1,25 @@
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:18:5
+ |
+18 | is_unpin::<S<PhantomPinned>>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__S<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `_::__S<'_, PhantomPinned>`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:6:8
+ |
+6 | struct S<T> {
+ | ^
+note: required because of the requirements on the impl of `Unpin` for `S<PhantomPinned>`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
+ |
+5 | #[pin_project]
+ | ^^^^^^^^^^^^^^
+6 | struct S<T> {
+ | ^^^^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:15:16
+ |
+15 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.rs b/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.rs
new file mode 100644
index 0000000000..890fd5b8de
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.rs
@@ -0,0 +1,32 @@
+// https://discord.com/channels/273534239310479360/512792629516173323/870075511009857617
+
+extern crate pin_project as pin_project_orig;
+extern crate self as pin_project;
+
+pub use ::pin_project_orig::*;
+mod __private {
+ pub use ::pin_project_orig::__private::*;
+ pub trait Drop {}
+}
+
+use std::{marker::PhantomPinned, mem};
+
+#[pin_project] //~ ERROR conflicting implementations of trait `_::FooMustNotImplDrop`
+struct S {
+ #[pin]
+ f: (u8, PhantomPinned),
+}
+
+impl Drop for S {
+ fn drop(&mut self) {
+ let prev = &self.f.0 as *const _ as usize;
+ let moved = mem::take(&mut self.f); // move pinned field
+ let moved = &moved.0 as *const _ as usize;
+ assert_eq!(prev, moved); // panic
+ }
+}
+
+fn main() {
+ let mut x = Box::pin(S { f: (1, PhantomPinned) });
+ let _f = x.as_mut().project().f; // first mutable access
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.stderr b/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.stderr
new file mode 100644
index 0000000000..8a3fb9b61a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/override-priv-mod.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `_::SMustNotImplDrop` for type `S`
+ --> tests/ui/pin_project/override-priv-mod.rs:14:1
+ |
+14 | #[pin_project] //~ ERROR conflicting implementations of trait `_::FooMustNotImplDrop`
+ | ^^^^^^^^^^^^^^
+ | |
+ | first implementation here
+ | conflicting implementation for `S`
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.rs
new file mode 100644
index 0000000000..023c08d14f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.rs
@@ -0,0 +1,24 @@
+use pin_project::pin_project;
+
+// #[repr(packed)] cannot be apply on enums and will be rejected by rustc.
+// However, we should not rely on the behavior of rustc that rejects this.
+// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+
+#[repr(packed)] //~ ERROR E0517
+enum E1 {
+ V(()),
+}
+
+#[pin_project]
+#[repr(packed)] //~ ERROR E0517
+enum E2 {
+ V(()),
+}
+
+#[repr(packed)] //~ ERROR E0517
+#[pin_project]
+enum E3 {
+ V(()),
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.stderr
new file mode 100644
index 0000000000..1872211206
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed-enum.stderr
@@ -0,0 +1,42 @@
+error: #[repr(packed)] attribute should be applied to a struct or union
+ --> tests/ui/pin_project/packed-enum.rs:13:8
+ |
+13 | #[repr(packed)] //~ ERROR E0517
+ | ^^^^^^
+
+error: #[repr(packed)] attribute should be applied to a struct or union
+ --> tests/ui/pin_project/packed-enum.rs:18:8
+ |
+18 | #[repr(packed)] //~ ERROR E0517
+ | ^^^^^^
+
+error[E0517]: attribute should be applied to a struct or union
+ --> tests/ui/pin_project/packed-enum.rs:7:8
+ |
+7 | #[repr(packed)] //~ ERROR E0517
+ | ^^^^^^
+8 | / enum E1 {
+9 | | V(()),
+10 | | }
+ | |_- not a struct or union
+
+error[E0517]: attribute should be applied to a struct or union
+ --> tests/ui/pin_project/packed-enum.rs:13:8
+ |
+13 | #[repr(packed)] //~ ERROR E0517
+ | ^^^^^^
+14 | / enum E2 {
+15 | | V(()),
+16 | | }
+ | |_- not a struct or union
+
+error[E0517]: attribute should be applied to a struct or union
+ --> tests/ui/pin_project/packed-enum.rs:18:8
+ |
+18 | #[repr(packed)] //~ ERROR E0517
+ | ^^^^^^
+19 | #[pin_project]
+20 | / enum E3 {
+21 | | V(()),
+22 | | }
+ | |_- not a struct or union
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.rs
new file mode 100644
index 0000000000..dedc4030fa
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.rs
@@ -0,0 +1,27 @@
+use pin_project::pin_project;
+
+// #[repr(packed = "")] is not valid format of #[repr(packed)] and will be
+// rejected by rustc.
+// However, we should not rely on the behavior of rustc that rejects this.
+// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+
+// https://github.com/taiki-e/pin-project/pull/324#discussion_r612388001
+// https://github.com/rust-lang/rust/issues/83921
+// #[repr(packed = "")] //~ ERROR E0552
+// struct S1 {
+// f: (),
+// }
+
+#[pin_project]
+#[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+struct S2 {
+ f: (),
+}
+
+#[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+#[pin_project]
+struct S3 {
+ f: (),
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.stderr
new file mode 100644
index 0000000000..d8b2194713
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed-name-value.stderr
@@ -0,0 +1,23 @@
+error: #[repr(packed)] attribute should not be name-value pair
+ --> tests/ui/pin_project/packed-name-value.rs:16:8
+ |
+16 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+ | ^^^^^^^^^^^
+
+error: #[repr(packed)] attribute should not be name-value pair
+ --> tests/ui/pin_project/packed-name-value.rs:21:8
+ |
+21 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+ | ^^^^^^^^^^^
+
+error[E0693]: incorrect `repr(packed)` attribute format
+ --> tests/ui/pin_project/packed-name-value.rs:16:8
+ |
+16 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+ | ^^^^^^^^^^^ help: use parentheses instead: `packed()`
+
+error[E0693]: incorrect `repr(packed)` attribute format
+ --> tests/ui/pin_project/packed-name-value.rs:21:8
+ |
+21 | #[repr(packed = "")] //~ ERROR attribute should not be name-value pair
+ | ^^^^^^^^^^^ help: use parentheses instead: `packed()`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed.rs
new file mode 100644
index 0000000000..dd3ebfd638
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed.rs
@@ -0,0 +1,33 @@
+use pin_project::pin_project;
+
+#[pin_project]
+#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+struct Packed1 {
+ #[pin]
+ f: u8,
+}
+
+// Test putting 'repr' before the 'pin_project' attribute
+#[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+#[pin_project]
+struct Packed2 {
+ #[pin]
+ f: u8,
+}
+
+#[pin_project]
+#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+struct PackedN1 {
+ #[pin]
+ f: u32,
+}
+
+// Test putting 'repr' before the 'pin_project' attribute
+#[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+#[pin_project]
+struct PackedN2 {
+ #[pin]
+ f: u32,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr
new file mode 100644
index 0000000000..25ea5f43e4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed.stderr
@@ -0,0 +1,23 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed.rs:4:8
+ |
+4 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed.rs:11:8
+ |
+11 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed.rs:19:8
+ |
+19 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed.rs:26:8
+ |
+26 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
+ | ^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs
new file mode 100644
index 0000000000..83a46122cc
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.rs
@@ -0,0 +1,41 @@
+use std::pin::Pin;
+
+use auxiliary_macro::{hidden_repr, hidden_repr2};
+use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
+
+#[pin_project] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct A {
+ #[pin]
+ f: u32,
+}
+
+#[hidden_repr2]
+#[pin_project] //~ ERROR may not be used on #[repr(packed)] types
+struct B {
+ #[pin]
+ f: u32,
+}
+
+#[pin_project(UnsafeUnpin)] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct C {
+ #[pin]
+ f: u32,
+}
+
+unsafe impl UnsafeUnpin for C {}
+
+#[pin_project(PinnedDrop)] //~ ERROR may not be used on #[repr(packed)] types
+#[hidden_repr(packed)]
+struct D {
+ #[pin]
+ f: u32,
+}
+
+#[pinned_drop]
+impl PinnedDrop for D {
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr
new file mode 100644
index 0000000000..0746e1a21c
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-1.stderr
@@ -0,0 +1,25 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed_sneaky-1.rs:7:15
+ |
+7 | #[hidden_repr(packed)]
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed_sneaky-1.rs:13:1
+ |
+13 | #[hidden_repr2]
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the attribute macro `hidden_repr2` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed_sneaky-1.rs:21:15
+ |
+21 | #[hidden_repr(packed)]
+ | ^^^^^^
+
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed_sneaky-1.rs:30:15
+ |
+30 | #[hidden_repr(packed)]
+ | ^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs
new file mode 100644
index 0000000000..b098358e6f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.rs
@@ -0,0 +1,12 @@
+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]
+ f: u32,
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr
new file mode 100644
index 0000000000..d643052fda
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-2.stderr
@@ -0,0 +1,13 @@
+error: #[pin_project] attribute may not be used on #[repr(packed)] types
+ --> tests/ui/pin_project/packed_sneaky-2.rs:4:1
+ |
+4 | / hidden_repr_macro! { //~ ERROR may not be used on #[repr(packed)] types
+5 | | #[pin_project]
+6 | | struct B {
+7 | | #[pin]
+8 | | f: u32,
+9 | | }
+10 | | }
+ | |_^
+ |
+ = note: this error originates in the macro `hidden_repr_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.rs
new file mode 100644
index 0000000000..d3f00f3d23
--- /dev/null
+++ b/third_party/rust/pin-project/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/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.stderr
new file mode 100644
index 0000000000..c97f18b75a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-3.stderr
@@ -0,0 +1,32 @@
+error: expected item after attributes
+ --> tests/ui/pin_project/packed_sneaky-3.rs:4:1
+ |
+4 | hidden_repr_macro! {} //~ ERROR expected item after attributes
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `hidden_repr_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected item after attributes
+ --> tests/ui/pin_project/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 the macro `hidden_repr_macro2` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected item after attributes
+ --> tests/ui/pin_project/packed_sneaky-3.rs:24:10
+ |
+24 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
+ | ^^^^^^^^^^
+ |
+ = note: this error originates in the derive macro `HiddenRepr` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: proc-macro derive produced unparseable tokens
+ --> tests/ui/pin_project/packed_sneaky-3.rs:24:10
+ |
+24 | #[derive(HiddenRepr)] //~ ERROR expected item after attributes
+ | ^^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.rs b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.rs
new file mode 100644
index 0000000000..fb954baf15
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.rs
@@ -0,0 +1,15 @@
+// https://github.com/taiki-e/pin-project/issues/342
+
+#![allow(unaligned_references)]
+
+use auxiliary_macro::hidden_repr2;
+use pin_project::pin_project;
+
+#[pin_project] //~ ERROR reference to packed field is unaligned
+#[hidden_repr2]
+struct A {
+ #[pin]
+ f: u32,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.stderr b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.stderr
new file mode 100644
index 0000000000..8072ce2f5f
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/packed_sneaky-4.stderr
@@ -0,0 +1,16 @@
+error: reference to packed field is unaligned
+ --> tests/ui/pin_project/packed_sneaky-4.rs:8:1
+ |
+8 | #[pin_project] //~ ERROR reference to packed field is unaligned
+ | ^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> tests/ui/pin_project/packed_sneaky-4.rs:8:1
+ |
+8 | #[pin_project] //~ ERROR reference to packed field is unaligned
+ | ^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
+ = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs
new file mode 100644
index 0000000000..15a82a9a92
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.rs
@@ -0,0 +1,23 @@
+// Even if allows private_in_public, these are errors.
+
+#![allow(private_in_public)]
+
+pub enum PublicEnum {
+ V(PrivateEnum), //~ ERROR E0446
+}
+
+enum PrivateEnum {
+ V(u8),
+}
+
+mod foo {
+ pub(crate) enum CrateEnum {
+ V(PrivateEnum), //~ ERROR E0446
+ }
+
+ enum PrivateEnum {
+ V(u8),
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr
new file mode 100644
index 0000000000..c93b265916
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/private_in_public-enum.stderr
@@ -0,0 +1,17 @@
+error[E0446]: private type `PrivateEnum` in public interface
+ --> tests/ui/pin_project/private_in_public-enum.rs:6:7
+ |
+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
+ --> tests/ui/pin_project/private_in_public-enum.rs:15:11
+ |
+15 | V(PrivateEnum), //~ ERROR E0446
+ | ^^^^^^^^^^^ can't leak private type
+...
+18 | enum PrivateEnum {
+ | ---------------- `foo::PrivateEnum` declared as private
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.rs b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.rs
new file mode 100644
index 0000000000..20dde12bd3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.rs
@@ -0,0 +1,11 @@
+use pin_project::pin_project;
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct Struct<T: ?Sized> {
+ f: T,
+}
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct TupleStruct<T: ?Sized>(T);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.stderr b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.stderr
new file mode 100644
index 0000000000..042b499434
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized.stderr
@@ -0,0 +1,118 @@
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized.rs:3:15
+ |
+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`
+ |
+note: required because it appears within the type `Struct<T>`
+ --> tests/ui/pin_project/project_replace_unsized.rs:4:8
+ |
+4 | struct Struct<T: ?Sized> {
+ | ^^^^^^
+ = help: unsized fn params are gated as an unstable feature
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+4 - struct Struct<T: ?Sized> {
+4 + struct Struct<T> {
+ |
+help: function arguments must have a statically known size, borrowed types always have a known size
+ |
+3 | #[pin_project(&project_replace)] //~ ERROR E0277
+ | +
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized.rs:3:1
+ |
+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`
+ |
+note: required because it appears within the type `Struct<T>`
+ --> tests/ui/pin_project/project_replace_unsized.rs:4:8
+ |
+4 | struct Struct<T: ?Sized> {
+ | ^^^^^^
+note: required by a bound in `UnsafeOverwriteGuard::<T>::new`
+ --> src/lib.rs
+ |
+ | impl<T> UnsafeOverwriteGuard<T> {
+ | ^ required by this bound in `UnsafeOverwriteGuard::<T>::new`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+4 - struct Struct<T: ?Sized> {
+4 + struct Struct<T> {
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized.rs:5:5
+ |
+3 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ------------------------------- required by a bound introduced by this call
+4 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+5 | f: T,
+ | ^ doesn't have a size known at compile-time
+ |
+note: required by a bound in `std::ptr::read`
+ --> $RUST/core/src/ptr/mod.rs
+ |
+ | pub const unsafe fn read<T>(src: *const T) -> T {
+ | ^ required by this bound in `std::ptr::read`
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+4 - struct Struct<T: ?Sized> {
+4 + struct Struct<T> {
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized.rs:8:15
+ |
+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`
+ |
+note: required because it appears within the type `TupleStruct<T>`
+ --> tests/ui/pin_project/project_replace_unsized.rs:9:8
+ |
+9 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^
+ = help: unsized fn params are gated as an unstable feature
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+9 - struct TupleStruct<T: ?Sized>(T);
+9 + struct TupleStruct<T>(T);
+ |
+help: function arguments must have a statically known size, borrowed types always have a known size
+ |
+8 | #[pin_project(&project_replace)] //~ ERROR E0277
+ | +
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized.rs:8:1
+ |
+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`
+ |
+note: required because it appears within the type `TupleStruct<T>`
+ --> tests/ui/pin_project/project_replace_unsized.rs:9:8
+ |
+9 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^
+note: required by a bound in `UnsafeOverwriteGuard::<T>::new`
+ --> src/lib.rs
+ |
+ | impl<T> UnsafeOverwriteGuard<T> {
+ | ^ required by this bound in `UnsafeOverwriteGuard::<T>::new`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+9 - struct TupleStruct<T: ?Sized>(T);
+9 + struct TupleStruct<T>(T);
+ |
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.rs b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.rs
new file mode 100644
index 0000000000..e0fa25bf7d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.rs
@@ -0,0 +1,13 @@
+#![feature(unsized_fn_params)]
+
+use pin_project::pin_project;
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct Struct<T: ?Sized> {
+ f: T,
+}
+
+#[pin_project(project_replace)] //~ ERROR E0277
+struct TupleStruct<T: ?Sized>(T);
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.stderr b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.stderr
new file mode 100644
index 0000000000..10fad081aa
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/project_replace_unsized_fn_params.stderr
@@ -0,0 +1,112 @@
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:6:8
+ |
+6 | struct Struct<T: ?Sized> {
+ | ^^^^^^^-^^^^^^^^^
+ | | |
+ | | this type parameter needs to be `std::marker::Sized`
+ | doesn't have a size known at compile-time
+ |
+note: required because it appears within the type `__StructProjectionOwned<T>`
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:6:8
+ |
+6 | struct Struct<T: ?Sized> {
+ | ^^^^^^
+ = note: the return type of a function must have a statically known size
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+6 - struct Struct<T: ?Sized> {
+6 + struct Struct<T> {
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:5:1
+ |
+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`
+ |
+note: required because it appears within the type `Struct<T>`
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:6:8
+ |
+6 | struct Struct<T: ?Sized> {
+ | ^^^^^^
+note: required by a bound in `UnsafeOverwriteGuard::<T>::new`
+ --> src/lib.rs
+ |
+ | impl<T> UnsafeOverwriteGuard<T> {
+ | ^ required by this bound in `UnsafeOverwriteGuard::<T>::new`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+6 - struct Struct<T: ?Sized> {
+6 + struct Struct<T> {
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:7:5
+ |
+5 | #[pin_project(project_replace)] //~ ERROR E0277
+ | ------------------------------- required by a bound introduced by this call
+6 | struct Struct<T: ?Sized> {
+ | - this type parameter needs to be `std::marker::Sized`
+7 | f: T,
+ | ^ doesn't have a size known at compile-time
+ |
+note: required by a bound in `std::ptr::read`
+ --> $RUST/core/src/ptr/mod.rs
+ |
+ | pub const unsafe fn read<T>(src: *const T) -> T {
+ | ^ required by this bound in `std::ptr::read`
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+6 - struct Struct<T: ?Sized> {
+6 + struct Struct<T> {
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8
+ |
+11 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^^-^^^^^^^^^
+ | | |
+ | | this type parameter needs to be `std::marker::Sized`
+ | doesn't have a size known at compile-time
+ |
+note: required because it appears within the type `__TupleStructProjectionOwned<T>`
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8
+ |
+11 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^
+ = note: the return type of a function must have a statically known size
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+11 - struct TupleStruct<T: ?Sized>(T);
+11 + struct TupleStruct<T>(T);
+ |
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:10:1
+ |
+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`
+ |
+note: required because it appears within the type `TupleStruct<T>`
+ --> tests/ui/pin_project/project_replace_unsized_fn_params.rs:11:8
+ |
+11 | struct TupleStruct<T: ?Sized>(T);
+ | ^^^^^^^^^^^
+note: required by a bound in `UnsafeOverwriteGuard::<T>::new`
+ --> src/lib.rs
+ |
+ | impl<T> UnsafeOverwriteGuard<T> {
+ | ^ required by this bound in `UnsafeOverwriteGuard::<T>::new`
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider removing the `?Sized` bound to make the type parameter `Sized`
+ |
+11 - struct TupleStruct<T: ?Sized>(T);
+11 + struct TupleStruct<T>(T);
+ |
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs
new file mode 100644
index 0000000000..fd14da37c1
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.rs
@@ -0,0 +1,33 @@
+use std::{marker::PhantomPinned, pin::Pin};
+
+use auxiliary_macro::remove_attr;
+use pin_project::pin_project;
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[remove_attr(field_all)]
+struct A {
+ #[pin]
+ f: PhantomPinned,
+}
+
+#[remove_attr(field_all)]
+#[pin_project]
+struct B {
+ #[pin]
+ f: PhantomPinned,
+}
+
+fn main() {
+ is_unpin::<A>();
+ is_unpin::<B>();
+
+ let mut x = A { f: PhantomPinned };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+
+ let mut x = B { f: PhantomPinned };
+ let x = Pin::new(&mut x).project();
+ let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr
new file mode 100644
index 0000000000..697cd63549
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-field.stderr
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+ --> tests/ui/pin_project/remove-attr-from-field.rs:28:38
+ |
+28 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+ | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Pin<&mut PhantomPinned>`
+ found mutable reference `&mut PhantomPinned`
+
+error[E0308]: mismatched types
+ --> tests/ui/pin_project/remove-attr-from-field.rs:32:38
+ |
+32 | let _: Pin<&mut PhantomPinned> = x.f; //~ ERROR E0308
+ | ----------------------- ^^^ expected struct `Pin`, found `&mut PhantomPinned`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Pin<&mut PhantomPinned>`
+ found mutable reference `&mut PhantomPinned`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs
new file mode 100644
index 0000000000..cbe5aba234
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.rs
@@ -0,0 +1,47 @@
+use std::{marker::PhantomPinned, pin::Pin};
+
+use auxiliary_macro::remove_attr;
+use pin_project::pin_project;
+
+fn is_unpin<T: Unpin>() {}
+
+#[pin_project]
+#[remove_attr(struct_all)]
+struct A {
+ #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ f: PhantomPinned,
+}
+
+#[remove_attr(struct_all)]
+#[pin_project]
+struct B {
+ #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ f: PhantomPinned,
+}
+
+#[pin_project] //~ ERROR has been removed
+#[remove_attr(struct_pin)]
+struct C {
+ f: PhantomPinned,
+}
+
+#[remove_attr(struct_pin)]
+#[pin_project] // Ok
+struct D {
+ f: PhantomPinned,
+}
+
+fn main() {
+ is_unpin::<A>(); //~ ERROR E0277
+ is_unpin::<B>(); //~ ERROR E0277
+ is_unpin::<D>(); // Ok
+
+ let mut x = A { f: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+
+ let mut x = B { f: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+
+ let mut x = D { f: PhantomPinned };
+ let _ = Pin::new(&mut x).project(); //~ Ok
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr
new file mode 100644
index 0000000000..1a9cd42ce2
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/remove-attr-from-struct.stderr
@@ -0,0 +1,107 @@
+error: #[pin_project] attribute has been removed
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:22:1
+ |
+22 | #[pin_project] //~ ERROR has been removed
+ | ^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: cannot find attribute `pin` in this scope
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:18:7
+ |
+18 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ | ^^^
+
+error: cannot find attribute `pin` in this scope
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:11:7
+ |
+11 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
+ | ^^^
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:35:5
+ |
+35 | is_unpin::<A>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `A`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:10:8
+ |
+10 | struct A {
+ | ^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:6:16
+ |
+6 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:36:5
+ |
+36 | is_unpin::<B>(); //~ ERROR E0277
+ | ^^^^^^^^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `B`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:17:8
+ |
+17 | struct B {
+ | ^
+note: required by a bound in `is_unpin`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:6:16
+ |
+6 | fn is_unpin<T: Unpin>() {}
+ | ^^^^^ required by this bound in `is_unpin`
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:40:22
+ |
+40 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | -------- ^^^^^^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `A`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:10:8
+ |
+10 | struct A {
+ | ^
+note: required by a bound in `Pin::<P>::new`
+ --> $RUST/core/src/pin.rs
+ |
+ | impl<P: Deref<Target: Unpin>> Pin<P> {
+ | ^^^^^ required by this bound in `Pin::<P>::new`
+
+error[E0599]: no method named `project` found for struct `Pin<&mut A>` in the current scope
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:40:30
+ |
+40 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `Pin<&mut A>`
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:43:22
+ |
+43 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | -------- ^^^^^^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `B`
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:17:8
+ |
+17 | struct B {
+ | ^
+note: required by a bound in `Pin::<P>::new`
+ --> $RUST/core/src/pin.rs
+ |
+ | impl<P: Deref<Target: Unpin>> Pin<P> {
+ | ^^^^^ required by this bound in `Pin::<P>::new`
+
+error[E0599]: no method named `project` found for struct `Pin<&mut B>` in the current scope
+ --> tests/ui/pin_project/remove-attr-from-struct.rs:43:30
+ |
+43 | let _ = Pin::new(&mut x).project(); //~ ERROR E0277,E0599
+ | ^^^^^^^ method not found in `Pin<&mut B>`
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs
new file mode 100644
index 0000000000..de8181cb9d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.rs
@@ -0,0 +1,26 @@
+#![deny(renamed_and_removed_lints)]
+#![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references`
+#![allow(unaligned_references)]
+
+// This lint was removed in https://github.com/rust-lang/rust/pull/82525 (nightly-2021-03-28).
+// Refs:
+// - https://github.com/rust-lang/rust/pull/82525
+// - https://github.com/rust-lang/rust/issues/46043
+
+#[repr(packed)]
+struct Packed {
+ f: u32,
+}
+
+#[repr(packed(2))]
+struct PackedN {
+ f: u32,
+}
+
+fn main() {
+ let a = Packed { f: 1 };
+ let _ = &a.f;
+
+ let b = PackedN { f: 1 };
+ let _ = &b.f;
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr
new file mode 100644
index 0000000000..f483b6d3ce
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/safe_packed_borrows.stderr
@@ -0,0 +1,11 @@
+error: lint `safe_packed_borrows` has been renamed to `unaligned_references`
+ --> tests/ui/pin_project/safe_packed_borrows.rs:2:9
+ |
+2 | #![deny(safe_packed_borrows)] //~ ERROR has been renamed to `unaligned_references`
+ | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `unaligned_references`
+ |
+note: the lint level is defined here
+ --> tests/ui/pin_project/safe_packed_borrows.rs:1:9
+ |
+1 | #![deny(renamed_and_removed_lints)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.rs b/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.rs
new file mode 100644
index 0000000000..eaf185d2a3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.rs
@@ -0,0 +1,21 @@
+#![forbid(unaligned_references)]
+
+// Refs: https://github.com/rust-lang/rust/issues/82523
+
+#[repr(packed)]
+struct Packed {
+ f: u32,
+}
+
+#[repr(packed(2))]
+struct PackedN {
+ f: u32,
+}
+
+fn main() {
+ let a = Packed { f: 1 };
+ let _ = &a.f; //~ ERROR reference to packed field is unaligned
+
+ let b = PackedN { f: 1 };
+ let _ = &b.f; //~ ERROR reference to packed field is unaligned
+}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.stderr b/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.stderr
new file mode 100644
index 0000000000..8d5ddfc591
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unaligned_references.stderr
@@ -0,0 +1,26 @@
+error: reference to packed field is unaligned
+ --> tests/ui/pin_project/unaligned_references.rs:17:13
+ |
+17 | let _ = &a.f; //~ ERROR reference to packed field is unaligned
+ | ^^^^
+ |
+note: the lint level is defined here
+ --> tests/ui/pin_project/unaligned_references.rs:1:11
+ |
+1 | #![forbid(unaligned_references)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
+ = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
+error: reference to packed field is unaligned
+ --> tests/ui/pin_project/unaligned_references.rs:20:13
+ |
+20 | let _ = &b.f; //~ ERROR reference to packed field is unaligned
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
+ = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+ = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs
new file mode 100644
index 0000000000..3f5f32be69
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.rs
@@ -0,0 +1,11 @@
+use pin_project::pin_project;
+
+#[pin_project]
+struct S {
+ #[pin]
+ f: u8,
+}
+
+impl Unpin for __S {} //~ ERROR E0412,E0321
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr
new file mode 100644
index 0000000000..82c2aa5b91
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/unpin_sneaky.stderr
@@ -0,0 +1,5 @@
+error[E0412]: cannot find type `__S` in this scope
+ --> tests/ui/pin_project/unpin_sneaky.rs:9:16
+ |
+9 | impl Unpin for __S {} //~ ERROR E0412,E0321
+ | ^^^ not found in this scope
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/visibility.rs b/third_party/rust/pin-project/tests/ui/pin_project/visibility.rs
new file mode 100644
index 0000000000..fdff5a6783
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/visibility.rs
@@ -0,0 +1,49 @@
+/// Only named projected types can be imported.
+/// See import_unnamed.rs for unnamed projected types.
+
+mod pub_ {
+ 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_use {
+ #[rustfmt::skip]
+ pub use crate::pub_::DProj; //~ ERROR E0365
+ #[rustfmt::skip]
+ pub use crate::pub_::DProjRef; //~ ERROR E0365
+ #[rustfmt::skip]
+ pub use crate::pub_::RProj; //~ ERROR E0365
+ #[rustfmt::skip]
+ pub use crate::pub_::RProjOwn; //~ ERROR E0365
+ #[rustfmt::skip]
+ pub use crate::pub_::RProjRef; //~ ERROR E0365
+
+ // Confirm that the visibility of the original type is not changed.
+ pub use crate::pub_::{Default, Replace};
+}
+pub mod pub_use2 {
+ // Ok
+ #[allow(unused_imports)]
+ pub(crate) use crate::pub_::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
+}
+
+mod pub_crate {
+ use pin_project::pin_project;
+
+ #[pin_project(project = DProj, project_ref = DProjRef)]
+ pub(crate) struct Default(());
+
+ #[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::{DProj, DProjRef, RProj, RProjOwn, RProjRef};
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pin_project/visibility.stderr b/third_party/rust/pin-project/tests/ui/pin_project/visibility.stderr
new file mode 100644
index 0000000000..4d1b7229a6
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pin_project/visibility.stderr
@@ -0,0 +1,39 @@
+error[E0365]: `DProj` is only public within the crate, and cannot be re-exported outside
+ --> tests/ui/pin_project/visibility.rs:15:13
+ |
+15 | pub use crate::pub_::DProj; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^ re-export of crate public `DProj`
+ |
+ = note: consider declaring type or module `DProj` with `pub`
+
+error[E0365]: `DProjRef` is only public within the crate, and cannot be re-exported outside
+ --> tests/ui/pin_project/visibility.rs:17:13
+ |
+17 | pub use crate::pub_::DProjRef; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `DProjRef`
+ |
+ = note: consider declaring type or module `DProjRef` with `pub`
+
+error[E0365]: `RProj` is only public within the crate, and cannot be re-exported outside
+ --> tests/ui/pin_project/visibility.rs:19:13
+ |
+19 | pub use crate::pub_::RProj; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^ re-export of crate public `RProj`
+ |
+ = note: consider declaring type or module `RProj` with `pub`
+
+error[E0365]: `RProjOwn` is only public within the crate, and cannot be re-exported outside
+ --> tests/ui/pin_project/visibility.rs:21:13
+ |
+21 | pub use crate::pub_::RProjOwn; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `RProjOwn`
+ |
+ = note: consider declaring type or module `RProjOwn` with `pub`
+
+error[E0365]: `RProjRef` is only public within the crate, and cannot be re-exported outside
+ --> tests/ui/pin_project/visibility.rs:23:13
+ |
+23 | pub use crate::pub_::RProjRef; //~ ERROR E0365
+ | ^^^^^^^^^^^^^^^^^^^^^ re-export of crate public `RProjRef`
+ |
+ = note: consider declaring type or module `RProjRef` with `pub`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.rs
new file mode 100644
index 0000000000..9f89942b21
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.rs
@@ -0,0 +1,17 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+struct Struct {
+ f: bool,
+}
+
+#[pinned_drop]
+impl PinnedDrop for Struct {
+ fn drop(mut self: Pin<&mut Self>) {
+ __drop_inner(__self);
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.stderr
new file mode 100644
index 0000000000..e3ceebd502
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/call-drop-inner.stderr
@@ -0,0 +1,16 @@
+error[E0061]: this function takes 0 arguments but 1 argument was supplied
+ --> tests/ui/pinned_drop/call-drop-inner.rs:13:9
+ |
+13 | __drop_inner(__self);
+ | ^^^^^^^^^^^^ ------ argument of type `Pin<&mut Struct>` unexpected
+ |
+note: function defined here
+ --> tests/ui/pinned_drop/call-drop-inner.rs:10:1
+ |
+10 | #[pinned_drop]
+ | ^^^^^^^^^^^^^^
+ = note: this error originates in the attribute macro `pinned_drop` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: remove the extra argument
+ |
+13 | __drop_inner();
+ | ~~~~~~~~~~~~~~
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.rs
new file mode 100644
index 0000000000..23d756d4dc
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.rs
@@ -0,0 +1,27 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+// In `Drop` impl, the implementor must specify the same requirement as type definition.
+
+struct DropImpl<T> {
+ f: T,
+}
+
+impl<T: Unpin> Drop for DropImpl<T> {
+ //~^ ERROR E0367
+ fn drop(&mut self) {}
+}
+
+#[pin_project(PinnedDrop)] //~ ERROR E0277
+struct PinnedDropImpl<T> {
+ #[pin]
+ f: T,
+}
+
+#[pinned_drop]
+impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.stderr
new file mode 100644
index 0000000000..0587765709
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -0,0 +1,28 @@
+error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:11:9
+ |
+11 | impl<T: Unpin> Drop for DropImpl<T> {
+ | ^^^^^
+ |
+note: the implementor must specify the same requirement
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:7:1
+ |
+7 | struct DropImpl<T> {
+ | ^^^^^^^^^^^^^^^^^^
+
+error[E0277]: `T` cannot be unpinned
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:16:15
+ |
+16 | #[pin_project(PinnedDrop)] //~ ERROR E0277
+ | ^^^^^^^^^^ the trait `Unpin` is not implemented for `T`
+ |
+ = note: consider using `Box::pin`
+note: required because of the requirements on the impl of `PinnedDrop` for `PinnedDropImpl<T>`
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:23:16
+ |
+23 | impl<T: Unpin> PinnedDrop for PinnedDropImpl<T> {
+ | ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
+help: consider restricting type parameter `T`
+ |
+17 | struct PinnedDropImpl<T: std::marker::Unpin> {
+ | ++++++++++++++++++++
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
new file mode 100644
index 0000000000..e31f46f262
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.rs
@@ -0,0 +1,9 @@
+use pin_project::pin_project;
+
+#[pin_project(PinnedDrop)] //~ ERROR E0277
+struct Struct {
+ #[pin]
+ f: u8,
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
new file mode 100644
index 0000000000..ef8a7bf4b4
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/forget-pinned-drop-impl.stderr
@@ -0,0 +1,5 @@
+error[E0277]: the trait bound `Struct: PinnedDrop` is not satisfied
+ --> tests/ui/pinned_drop/forget-pinned-drop-impl.rs:3:15
+ |
+3 | #[pin_project(PinnedDrop)] //~ ERROR E0277
+ | ^^^^^^^^^^ the trait `PinnedDrop` is not implemented for `Struct`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.rs
new file mode 100644
index 0000000000..783167fc0d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.rs
@@ -0,0 +1,14 @@
+// by-ref binding `ref (mut) self` and sub-patterns `@` are not allowed in receivers (rejected by rustc).
+
+use std::pin::Pin;
+
+struct S {}
+
+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 @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.stderr
new file mode 100644
index 0000000000..464be5e5b5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid-self.stderr
@@ -0,0 +1,25 @@
+error: expected identifier, found keyword `self`
+ --> tests/ui/pinned_drop/invalid-self.rs:8:26
+ |
+8 | fn take_ref_self(ref self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+ | ^^^^ expected identifier, found keyword
+
+error: expected identifier, found keyword `self`
+ --> tests/ui/pinned_drop/invalid-self.rs:9:34
+ |
+9 | fn take_ref_mut_self(ref mut self: Pin<&mut Self>) {} //~ ERROR expected identifier, found keyword `self`
+ | ^^^^ expected identifier, found keyword
+
+error: expected parameter name, found `@`
+ --> tests/ui/pinned_drop/invalid-self.rs:11:25
+ |
+11 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+ | ^ expected parameter name
+
+error: expected one of `)`, `,`, or `:`, found `@`
+ --> tests/ui/pinned_drop/invalid-self.rs:11:25
+ |
+11 | fn self_subpat(self @ S {}: Self) {} //~ ERROR expected one of `)`, `,`, or `:`, found `@`
+ | -^ expected one of `)`, `,`, or `:`
+ | |
+ | help: missing `,`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs
new file mode 100644
index 0000000000..fdadf8a516
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.rs
@@ -0,0 +1,231 @@
+mod argument {
+ use std::pin::Pin;
+
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct UnexpectedArg1(());
+
+ #[pinned_drop(foo)] //~ ERROR unexpected token
+ impl PinnedDrop for UnexpectedArg1 {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct UnexpectedArg2(());
+
+ #[pinned_drop()] // Ok
+ impl PinnedDrop for UnexpectedArg2 {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+}
+
+mod attribute {
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct Duplicate(());
+
+ #[pinned_drop]
+ #[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute
+ impl PinnedDrop for Duplicate {
+ fn drop(self: Pin<&mut Self>) {}
+ }
+}
+
+mod item {
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct TraitImpl(());
+
+ #[pinned_drop]
+ impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
+
+ #[pin_project(PinnedDrop)]
+ struct InherentImpl(());
+
+ #[pinned_drop]
+ impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
+
+ #[pinned_drop]
+ fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
+}
+
+mod unsafety {
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct Impl(());
+
+ #[pinned_drop]
+ unsafe impl PinnedDrop for Impl {
+ //~^ ERROR implementing the trait `PinnedDrop` is not unsafe
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Method(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Method {
+ unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
+ }
+}
+
+mod assoc_item {
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct Empty(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop`
+
+ #[pin_project(PinnedDrop)]
+ struct Const1(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Const1 {
+ const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Const2(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Const2 {
+ fn drop(self: Pin<&mut Self>) {}
+ const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Type1(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Type1 {
+ type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Type2(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Type2 {
+ fn drop(self: Pin<&mut Self>) {}
+ type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct Duplicate(());
+
+ #[pinned_drop]
+ impl PinnedDrop for Duplicate {
+ fn drop(self: Pin<&mut Self>) {}
+ fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
+ }
+}
+
+mod method {
+ use std::pin::Pin;
+
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ struct RetUnit(());
+
+ #[pinned_drop]
+ impl PinnedDrop for RetUnit {
+ fn drop(self: Pin<&mut Self>) -> () {} // Ok
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct RetTy(());
+
+ #[pinned_drop]
+ impl PinnedDrop for RetTy {
+ fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct NoArg(());
+
+ #[pinned_drop]
+ impl PinnedDrop for NoArg {
+ fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct MultiArg(());
+
+ #[pinned_drop]
+ impl PinnedDrop for MultiArg {
+ fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct InvalidArg1(());
+
+ #[pinned_drop]
+ impl PinnedDrop for InvalidArg1 {
+ fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct InvalidArg2(());
+
+ #[pinned_drop]
+ impl PinnedDrop for InvalidArg2 {
+ fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct InvalidArg3(());
+
+ #[pinned_drop]
+ impl PinnedDrop for InvalidArg3 {
+ fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct InvalidArg4(());
+
+ #[pinned_drop]
+ impl PinnedDrop for InvalidArg4 {
+ fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ }
+
+ #[pin_project(PinnedDrop)]
+ struct InvalidName(());
+
+ #[pinned_drop]
+ impl PinnedDrop for InvalidName {
+ fn pinned_drop(self: Pin<&mut Self>) {} //~ ERROR method `pinned_drop` is not a member of trait `PinnedDrop
+ }
+}
+
+mod self_ty {
+ use pin_project::pinned_drop;
+
+ #[pinned_drop]
+ impl PinnedDrop for () {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for &mut A {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for [A] {
+ //~^ ERROR implementing the trait `PinnedDrop` on this type is unsupported
+ fn drop(self: Pin<&mut Self>) {}
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr
new file mode 100644
index 0000000000..d509964b24
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/invalid.stderr
@@ -0,0 +1,143 @@
+error: unexpected token: `foo`
+ --> tests/ui/pinned_drop/invalid.rs:9:19
+ |
+9 | #[pinned_drop(foo)] //~ ERROR unexpected token
+ | ^^^
+
+error: duplicate #[pinned_drop] attribute
+ --> tests/ui/pinned_drop/invalid.rs:30:5
+ |
+30 | #[pinned_drop] //~ ERROR duplicate #[pinned_drop] attribute
+ | ^^^^^^^^^^^^^^
+
+error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ --> tests/ui/pinned_drop/invalid.rs:43:10
+ |
+43 | impl Drop for TraitImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
+ | ^^^^
+
+error: #[pinned_drop] may only be used on implementation for the `PinnedDrop` trait
+ --> tests/ui/pinned_drop/invalid.rs:49:10
+ |
+49 | impl InherentImpl {} //~ ERROR may only be used on implementation for the `PinnedDrop` trait
+ | ^^^^^^^^^^^^
+
+error: expected `impl`
+ --> tests/ui/pinned_drop/invalid.rs:52:5
+ |
+52 | fn func(_: Pin<&mut ()>) {} //~ ERROR expected `impl`
+ | ^^
+
+error: implementing the trait `PinnedDrop` is not unsafe
+ --> tests/ui/pinned_drop/invalid.rs:62:5
+ |
+62 | unsafe impl PinnedDrop for Impl {
+ | ^^^^^^
+
+error: implementing the method `drop` is not unsafe
+ --> tests/ui/pinned_drop/invalid.rs:72:9
+ |
+72 | unsafe fn drop(self: Pin<&mut Self>) {} //~ ERROR implementing the method `drop` is not unsafe
+ | ^^^^^^
+
+error: not all trait items implemented, missing: `drop`
+ --> tests/ui/pinned_drop/invalid.rs:83:5
+ |
+83 | impl PinnedDrop for Empty {} //~ ERROR not all trait items implemented, missing: `drop`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: const `A` is not a member of trait `PinnedDrop`
+ --> tests/ui/pinned_drop/invalid.rs:90:9
+ |
+90 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^^^^^
+
+error: const `A` is not a member of trait `PinnedDrop`
+ --> tests/ui/pinned_drop/invalid.rs:100:9
+ |
+100 | const A: u8 = 0; //~ ERROR const `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^^^^^
+
+error: type `A` is not a member of trait `PinnedDrop`
+ --> tests/ui/pinned_drop/invalid.rs:108:9
+ |
+108 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^
+
+error: type `A` is not a member of trait `PinnedDrop`
+ --> tests/ui/pinned_drop/invalid.rs:118:9
+ |
+118 | type A = u8; //~ ERROR type `A` is not a member of trait `PinnedDrop`
+ | ^^^^^^^^^^^^
+
+error: duplicate definitions with name `drop`
+ --> tests/ui/pinned_drop/invalid.rs:127:9
+ |
+127 | fn drop(self: Pin<&mut Self>) {} //~ ERROR duplicate definitions with name `drop`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: method `drop` must return the unit type
+ --> tests/ui/pinned_drop/invalid.rs:149:42
+ |
+149 | fn drop(self: Pin<&mut Self>) -> Self {} //~ ERROR method `drop` must return the unit type
+ | ^^^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:157:16
+ |
+157 | fn drop() {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:165:17
+ |
+165 | fn drop(self: Pin<&mut Self>, _: ()) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:173:17
+ |
+173 | fn drop(&mut self) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:181:17
+ |
+181 | fn drop(_: Pin<&mut Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^^^^^^^^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:189:17
+ |
+189 | fn drop(self: Pin<&Self>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^^^^^^^^
+
+error: method `drop` must take an argument `self: Pin<&mut Self>`
+ --> tests/ui/pinned_drop/invalid.rs:197:17
+ |
+197 | fn drop(self: Pin<&mut ()>) {} //~ ERROR method `drop` must take an argument `self: Pin<&mut Self>`
+ | ^^^^^^^^^^^^^^^^^^
+
+error: method `pinned_drop` is not a member of trait `PinnedDrop
+ --> tests/ui/pinned_drop/invalid.rs:205:12
+ |
+205 | 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
+ --> tests/ui/pinned_drop/invalid.rs:213:25
+ |
+213 | impl PinnedDrop for () {
+ | ^^
+
+error: implementing the trait `PinnedDrop` on this type is unsupported
+ --> tests/ui/pinned_drop/invalid.rs:219:25
+ |
+219 | impl PinnedDrop for &mut A {
+ | ^^^^^^
+
+error: implementing the trait `PinnedDrop` on this type is unsupported
+ --> tests/ui/pinned_drop/invalid.rs:225:25
+ |
+225 | impl PinnedDrop for [A] {
+ | ^^^
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
new file mode 100644
index 0000000000..391f2901ed
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs
@@ -0,0 +1,17 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project]
+struct S {
+ #[pin]
+ f: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for S {
+ //~^ ERROR E0119
+ fn drop(self: Pin<&mut Self>) {}
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
new file mode 100644
index 0000000000..254225454a
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/pinned-drop-no-attr-arg.stderr
@@ -0,0 +1,8 @@
+error[E0119]: conflicting implementations of trait `_::_pin_project::__private::PinnedDrop` for type `S`
+ --> tests/ui/pinned_drop/pinned-drop-no-attr-arg.rs:12:1
+ |
+5 | #[pin_project]
+ | -------------- first implementation here
+...
+12 | impl PinnedDrop for S {
+ | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S`
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs
new file mode 100644
index 0000000000..ff634022e5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/self.rs
@@ -0,0 +1,58 @@
+pub mod self_in_macro_def {
+ use std::pin::Pin;
+
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ pub struct S {
+ f: (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ macro_rules! t {
+ () => {{
+ let _ = self; //~ ERROR E0434
+
+ fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
+ }};
+ }
+ t!();
+ }
+ }
+}
+
+pub mod self_span {
+ use std::pin::Pin;
+
+ use pin_project::{pin_project, pinned_drop};
+
+ #[pin_project(PinnedDrop)]
+ pub struct S {
+ f: (),
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ let _: () = self; //~ ERROR E0308
+ let _: Self = Self; //~ ERROR E0423
+ }
+ }
+
+ #[pin_project(PinnedDrop)]
+ pub enum E {
+ V { f: () },
+ }
+
+ #[pinned_drop]
+ impl PinnedDrop for E {
+ fn drop(self: Pin<&mut Self>) {
+ let _: () = self; //~ ERROR E0308
+ let _: Self = Self::V; //~ ERROR E0533
+ }
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr
new file mode 100644
index 0000000000..a19d5a0db3
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/self.stderr
@@ -0,0 +1,62 @@
+error: `self` parameter is only allowed in associated functions
+ --> tests/ui/pinned_drop/self.rs:18:26
+ |
+18 | fn f(self: ()) {} //~ ERROR `self` parameter is only allowed in associated functions
+ | ^^^^ not semantically valid as function parameter
+...
+21 | t!();
+ | ---- in this macro invocation
+ |
+ = note: associated functions are those in `impl` or `trait` definitions
+ = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0434]: can't capture dynamic environment in a fn item
+ --> tests/ui/pinned_drop/self.rs:16:29
+ |
+16 | let _ = self; //~ ERROR E0434
+ | ^^^^
+...
+21 | t!();
+ | ---- in this macro invocation
+ |
+ = help: use the `|| { ... }` closure form instead
+ = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found struct `S`
+ --> tests/ui/pinned_drop/self.rs:40:27
+ |
+32 | / pub struct S {
+33 | | f: (),
+34 | | }
+ | |_____- `S` defined here
+...
+40 | let _: Self = Self; //~ ERROR E0423
+ | ^^^^ help: use struct literal syntax instead: `S { f: val }`
+
+error[E0308]: mismatched types
+ --> tests/ui/pinned_drop/self.rs:39:25
+ |
+39 | let _: () = self; //~ ERROR E0308
+ | -- ^^^^ expected `()`, found struct `Pin`
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found struct `Pin<&mut self_span::S>`
+
+error[E0308]: mismatched types
+ --> tests/ui/pinned_drop/self.rs:52:25
+ |
+52 | let _: () = self; //~ ERROR E0308
+ | -- ^^^^ expected `()`, found struct `Pin`
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found struct `Pin<&mut E>`
+
+error[E0533]: expected unit struct, unit variant or constant, found struct variant `E::V`
+ --> tests/ui/pinned_drop/self.rs:53:27
+ |
+53 | let _: Self = Self::V; //~ ERROR E0533
+ | ^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.rs b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.rs
new file mode 100644
index 0000000000..3ee2b56c37
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.rs
@@ -0,0 +1,18 @@
+use std::pin::Pin;
+
+use pin_project::{pin_project, pinned_drop};
+
+#[pin_project(PinnedDrop)]
+struct S {
+ #[pin]
+ f: u8,
+}
+
+#[pinned_drop]
+impl PinnedDrop for S {
+ fn drop(self: Pin<&mut Self>) {
+ self.project().f.get_unchecked_mut(); //~ ERROR call to unsafe function is unsafe and requires unsafe function or block [E0133]
+ }
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.stderr b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.stderr
new file mode 100644
index 0000000000..9f7dd440a5
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/pinned_drop/unsafe-call.stderr
@@ -0,0 +1,7 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+ --> tests/ui/pinned_drop/unsafe-call.rs:14:9
+ |
+14 | 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/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.rs b/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.rs
new file mode 100644
index 0000000000..ac9d1f8682
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.rs
@@ -0,0 +1,30 @@
+use pin_project::pin_project;
+
+#[pin_project(UnsafeUnpin)] //~ ERROR E0119
+struct Foo<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
+
+#[pin_project(UnsafeUnpin)] //~ ERROR E0119
+struct Bar<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T, U> Unpin for Bar<T, U> {}
+
+#[pin_project(UnsafeUnpin)] //~ ERROR E0119
+struct Baz<T, U> {
+ #[pin]
+ f1: T,
+ f2: U,
+}
+
+impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.stderr b/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.stderr
new file mode 100644
index 0000000000..0e89b03a28
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unsafe_unpin/conflict-unpin.stderr
@@ -0,0 +1,32 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
+ --> tests/ui/unsafe_unpin/conflict-unpin.rs:3:15
+ |
+3 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
+...
+10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
+ | ------------------------------ first implementation here
+ |
+ = note: upstream crates may add a new impl of trait `_::_pin_project::UnsafeUnpin` for type `_::_pin_project::__private::Wrapper<'_, Foo<_, _>>` in future versions
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
+ --> tests/ui/unsafe_unpin/conflict-unpin.rs:12:15
+ |
+12 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
+...
+19 | impl<T, U> Unpin for Bar<T, U> {}
+ | ------------------------------ first implementation here
+ |
+ = note: upstream crates may add a new impl of trait `_::_pin_project::UnsafeUnpin` for type `_::_pin_project::__private::Wrapper<'_, Bar<_, _>>` in future versions
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
+ --> tests/ui/unsafe_unpin/conflict-unpin.rs:21:15
+ |
+21 | #[pin_project(UnsafeUnpin)] //~ ERROR E0119
+ | ^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
+...
+28 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
+ | -------------------------------------------- first implementation here
+ |
+ = note: upstream crates may add a new impl of trait `_::_pin_project::UnsafeUnpin` for type `_::_pin_project::__private::Wrapper<'_, Baz<_, _>>` in future versions
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/README.md b/third_party/rust/pin-project/tests/ui/unstable-features/README.md
new file mode 100644
index 0000000000..96f370ca77
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/README.md
@@ -0,0 +1,7 @@
+# UI tests for unstable features
+
+These tests check how the guarantees and features provided by pin-project
+interact with unstable language features.
+
+The names of the files contained in this directory need to begin with the name
+of the feature.
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
new file mode 100644
index 0000000000..542250bd90
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
@@ -0,0 +1,20 @@
+// Note: If you change this test, change 'marker_trait_attr.rs' at the same time.
+
+use std::marker::PhantomPinned;
+
+use pin_project::pin_project;
+
+#[pin_project] //~ ERROR E0119
+struct Struct<T> {
+ #[pin]
+ f: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr
new file mode 100644
index 0000000000..3412f2e224
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`
+ --> tests/ui/unstable-features/marker_trait_attr-feature-gate.rs:7:1
+ |
+7 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+14 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs
new file mode 100644
index 0000000000..9c8e6643e0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.rs
@@ -0,0 +1,26 @@
+// Note: If you change this test, change 'marker_trait_attr-feature-gate.rs' at the same time.
+
+// marker_trait_attr
+// Tracking issue: https://github.com/rust-lang/rust/issues/29864
+#![feature(marker_trait_attr)]
+
+// See https://github.com/taiki-e/pin-project/issues/105#issuecomment-535355974
+
+use std::marker::PhantomPinned;
+
+use pin_project::pin_project;
+
+#[pin_project] //~ ERROR E0119
+struct Struct<T> {
+ #[pin]
+ f: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr
new file mode 100644
index 0000000000..2b68c80ffb
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/marker_trait_attr.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`
+ --> tests/ui/unstable-features/marker_trait_attr.rs:13:1
+ |
+13 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+20 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs
new file mode 100644
index 0000000000..96056423a0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs
@@ -0,0 +1,23 @@
+#![feature(negative_impls)]
+#![deny(suspicious_auto_trait_impls)]
+
+// https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.3A.20backlog.20bonanza/near/269471299
+// https://github.com/taiki-e/pin-project/issues/340
+
+#[pin_project::pin_project]
+struct Foo<Pinned, Unpinned> {
+ #[pin]
+ pinned: Pinned,
+
+ unpinned: Unpinned,
+}
+
+struct MyPhantomPinned {}
+impl !Unpin for MyPhantomPinned {}
+impl Unpin for Foo<MyPhantomPinned, ()> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Foo<MyPhantomPinned, ()>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr
new file mode 100644
index 0000000000..0d99e2bf69
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.stderr
@@ -0,0 +1,19 @@
+error: cross-crate traits with a default impl, like `Unpin`, should not be specialized
+ --> tests/ui/unstable-features/negative_impls.rs:17:1
+ |
+17 | impl Unpin for Foo<MyPhantomPinned, ()> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> tests/ui/unstable-features/negative_impls.rs:2:9
+ |
+2 | #![deny(suspicious_auto_trait_impls)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this will change its meaning in a future release!
+ = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
+ = note: `MyPhantomPinned` is not a generic parameter
+note: try using the same sequence of generic parameters as the struct definition
+ --> tests/ui/unstable-features/negative_impls.rs:8:1
+ |
+8 | struct Foo<Pinned, Unpinned> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
new file mode 100644
index 0000000000..012c8709bd
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs
@@ -0,0 +1,20 @@
+// Note: If you change this test, change 'overlapping_marker_traits.rs' at the same time.
+
+use std::marker::PhantomPinned;
+
+use pin_project::pin_project;
+
+#[pin_project] //~ ERROR E0119
+struct Struct<T> {
+ #[pin]
+ f: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr
new file mode 100644
index 0000000000..918d804d0e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits-feature-gate.stderr
@@ -0,0 +1,10 @@
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`
+ --> tests/ui/unstable-features/overlapping_marker_traits-feature-gate.rs:7:1
+ |
+7 | #[pin_project] //~ ERROR E0119
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+14 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs
new file mode 100644
index 0000000000..8dc27c1dba
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.rs
@@ -0,0 +1,30 @@
+// Note: If you change this test, change 'overlapping_marker_traits-feature-gate.rs' at the same time.
+
+// This feature could break the guarantee for Unpin provided by pin-project,
+// but was removed in https://github.com/rust-lang/rust/pull/68544 (nightly-2020-02-06).
+// Refs:
+// - https://github.com/rust-lang/rust/issues/29864#issuecomment-515780867
+// - https://github.com/taiki-e/pin-project/issues/105
+
+// overlapping_marker_traits
+// Tracking issue: https://github.com/rust-lang/rust/issues/29864
+#![feature(overlapping_marker_traits)]
+
+use std::marker::PhantomPinned;
+
+use pin_project::pin_project;
+
+#[pin_project]
+struct Struct<T> {
+ #[pin]
+ f: T,
+}
+
+// unsound Unpin impl
+impl<T> Unpin for Struct<T> {}
+
+fn is_unpin<T: Unpin>() {}
+
+fn main() {
+ is_unpin::<Struct<PhantomPinned>>()
+}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr
new file mode 100644
index 0000000000..3e8411d4b0
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/overlapping_marker_traits.stderr
@@ -0,0 +1,18 @@
+error[E0557]: feature has been removed
+ --> tests/ui/unstable-features/overlapping_marker_traits.rs:11:12
+ |
+11 | #![feature(overlapping_marker_traits)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
+ |
+ = note: removed in favor of `#![feature(marker_trait_attr)]`
+
+error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Struct<_>`
+ --> tests/ui/unstable-features/overlapping_marker_traits.rs:17:1
+ |
+17 | #[pin_project]
+ | ^^^^^^^^^^^^^^ conflicting implementation for `Struct<_>`
+...
+24 | impl<T> Unpin for Struct<T> {}
+ | --------------------------- first implementation here
+ |
+ = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
new file mode 100644
index 0000000000..f8467b082e
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.rs
@@ -0,0 +1,53 @@
+// Note: If you change this test, change 'trivial_bounds.rs' at the same time.
+
+mod phantom_pinned {
+ use std::marker::{PhantomData, PhantomPinned};
+
+ struct A(PhantomPinned);
+
+ impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
+
+ struct Wrapper<T>(T);
+
+ impl<T> Unpin for Wrapper<T> where T: Unpin {}
+
+ struct B(PhantomPinned);
+
+ impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
+
+ struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
+
+ impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
+
+ struct C(PhantomPinned);
+
+ impl<'a> Unpin for C where WrapperWithLifetime<'a, PhantomPinned>: Unpin {} // Ok
+}
+
+mod inner {
+ use std::marker::{PhantomData, PhantomPinned};
+
+ struct Inner(PhantomPinned);
+
+ struct A(Inner);
+
+ impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
+
+ struct Wrapper<T>(T);
+
+ impl<T> Unpin for Wrapper<T> where T: Unpin {}
+
+ struct B(Inner);
+
+ impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
+
+ struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
+
+ impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
+
+ struct C(Inner);
+
+ impl<'a> Unpin for C where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
new file mode 100644
index 0000000000..2e316585ed
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
@@ -0,0 +1,59 @@
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:8:28
+ |
+8 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:16:28
+ |
+16 | impl Unpin for B where Wrapper<PhantomPinned>: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because of the requirements on the impl of `Unpin` for `phantom_pinned::Wrapper<PhantomPinned>`
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:12:13
+ |
+12 | impl<T> Unpin for Wrapper<T> where T: Unpin {}
+ | ^^^^^ ^^^^^^^^^^
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:34:28
+ |
+34 | impl Unpin for A where Inner: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `Inner`
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:30:12
+ |
+30 | struct Inner(PhantomPinned);
+ | ^^^^^
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error[E0277]: `PhantomPinned` cannot be unpinned
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:42:28
+ |
+42 | impl Unpin for B where Wrapper<Inner>: Unpin {} //~ ERROR E0277
+ | ^^^^^^^^^^^^^^^^^^^^^ within `Inner`, the trait `Unpin` is not implemented for `PhantomPinned`
+ |
+ = note: consider using `Box::pin`
+note: required because it appears within the type `Inner`
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:30:12
+ |
+30 | struct Inner(PhantomPinned);
+ | ^^^^^
+note: required because of the requirements on the impl of `Unpin` for `inner::Wrapper<Inner>`
+ --> tests/ui/unstable-features/trivial_bounds-feature-gate.rs:38:13
+ |
+38 | impl<T> Unpin for Wrapper<T> where T: Unpin {}
+ | ^^^^^ ^^^^^^^^^^
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs
new file mode 100644
index 0000000000..41f885d4e7
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs
@@ -0,0 +1,38 @@
+// Note: If you change this test, change 'trivial_bounds-feature-gate.rs' at the same time.
+
+// trivial_bounds
+// Tracking issue: https://github.com/rust-lang/rust/issues/48214
+#![feature(trivial_bounds)]
+#![deny(trivial_bounds)]
+
+use std::marker::{PhantomData, PhantomPinned};
+
+fn inner() {
+ struct Inner(PhantomPinned);
+
+ struct A(PhantomPinned);
+
+ impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
+
+ struct B(Inner);
+
+ impl Unpin for B where Inner: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
+
+ struct Wrapper<T>(T);
+
+ impl<T> Unpin for Wrapper<T> where T: Unpin {}
+
+ struct C(Inner);
+
+ impl Unpin for C where Wrapper<Inner>: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
+
+ struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
+
+ impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
+
+ struct D(Inner);
+
+ impl<'a> Unpin for D where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
+}
+
+fn main() {}
diff --git a/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr
new file mode 100644
index 0000000000..23f45c738d
--- /dev/null
+++ b/third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.stderr
@@ -0,0 +1,23 @@
+error: trait bound PhantomPinned: Unpin does not depend on any type or lifetime parameters
+ --> tests/ui/unstable-features/trivial_bounds.rs:15:43
+ |
+15 | impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
+ | ^^^^^
+ |
+note: the lint level is defined here
+ --> tests/ui/unstable-features/trivial_bounds.rs:6:9
+ |
+6 | #![deny(trivial_bounds)]
+ | ^^^^^^^^^^^^^^
+
+error: trait bound Inner: Unpin does not depend on any type or lifetime parameters
+ --> tests/ui/unstable-features/trivial_bounds.rs:19:35
+ |
+19 | impl Unpin for B where Inner: Unpin {} //~ ERROR 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
+ --> tests/ui/unstable-features/trivial_bounds.rs:27:44
+ |
+27 | impl Unpin for C where Wrapper<Inner>: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
+ | ^^^^^
diff --git a/third_party/rust/pin-project/tests/unsafe_unpin.rs b/third_party/rust/pin-project/tests/unsafe_unpin.rs
new file mode 100644
index 0000000000..8b6411c775
--- /dev/null
+++ b/third_party/rust/pin-project/tests/unsafe_unpin.rs
@@ -0,0 +1,50 @@
+#![warn(rust_2018_idioms, single_use_lifetimes)]
+#![allow(dead_code)]
+
+#[macro_use]
+mod auxiliary;
+
+use std::marker::PhantomPinned;
+
+use pin_project::{pin_project, UnsafeUnpin};
+
+#[pin_project(UnsafeUnpin)]
+pub struct Blah<T, U> {
+ f1: U,
+ #[pin]
+ 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)]
+struct OverlappingLifetimeNames<'pin, T, U> {
+ #[pin]
+ f1: U,
+ #[pin]
+ f2: Option<T>,
+ f3: &'pin (),
+}
+
+unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for OverlappingLifetimeNames<'_, T, U> {}
+
+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]
+ f: PhantomPinned,
+ }
+
+ assert_not_unpin!(NotImplementUnsafUnpin);
+}