aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/README.md46
-rw-r--r--tests/compiletest.rs4
-rw-r--r--tests/expand/README.md17
-rw-r--r--tests/expand/default/enum.expanded.rs10
-rw-r--r--tests/expand/multifields/enum.expanded.rs12
-rw-r--r--tests/expand/multifields/struct.expanded.rs12
-rw-r--r--tests/expand/naming/enum-all.expanded.rs10
-rw-r--r--tests/expand/naming/struct-all.expanded.rs10
-rw-r--r--tests/lint.rs26
-rw-r--r--tests/test.rs27
-rw-r--r--tests/ui/pin_project/conflict-drop.stderr2
-rw-r--r--tests/ui/pin_project/conflict-unpin.stderr6
-rw-r--r--tests/ui/pin_project/invalid-bounds.stderr132
-rw-r--r--tests/ui/pin_project/invalid.stderr14
-rw-r--r--tests/ui/pin_project/overlapping_lifetime_names.stderr54
-rw-r--r--tests/ui/pin_project/overlapping_unpin_struct.stderr23
-rw-r--r--tests/ui/pin_project/packed.stderr10
-rw-r--r--tests/ui/pin_project/unpin_sneaky.stderr4
-rw-r--r--tests/ui/pin_project/unsupported.stderr26
-rw-r--r--tests/ui/pinned_drop/call-drop-inner.stderr4
-rw-r--r--tests/ui/pinned_drop/conditional-drop-impl.stderr8
21 files changed, 286 insertions, 171 deletions
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 0000000..4721616
--- /dev/null
+++ b/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/tests/compiletest.rs b/tests/compiletest.rs
index 8970215..70d2358 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -3,7 +3,7 @@
use std::env;
-#[rustversion::attr(before(2021-05-15), ignore)] // Note: This date is commit-date and the day before the toolchain date.
+#[rustversion::attr(not(nightly), ignore)]
#[test]
fn ui() {
if env::var_os("CI").is_none() {
@@ -11,5 +11,5 @@ fn ui() {
}
let t = trybuild::TestCases::new();
- t.compile_fail("tests/ui/*/*.rs");
+ t.compile_fail("tests/ui/**/*.rs");
}
diff --git a/tests/expand/README.md b/tests/expand/README.md
deleted file mode 100644
index 1f7dcfb..0000000
--- a/tests/expand/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Expansion tests
-
-Similar to ui tests, but instead of checking the compiler output, this checks
-the code generated by macros.
-
-See [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.
diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs
index df005ad..eae0aac 100644
--- a/tests/expand/default/enum.expanded.rs
+++ b/tests/expand/default/enum.expanded.rs
@@ -86,10 +86,10 @@ const _: () = {
) -> EnumProjReplace<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
- let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard {
- target: __self_ptr,
- value: ::pin_project_lite::__private::ManuallyDrop::new(replacement),
- };
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let result = EnumProjReplace::Struct {
@@ -98,7 +98,7 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
(),
);
}
diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs
index a0b17cb..fca0feb 100644
--- a/tests/expand/multifields/enum.expanded.rs
+++ b/tests/expand/multifields/enum.expanded.rs
@@ -33,10 +33,10 @@ const _: () = {
) -> EnumProjReplace<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
- let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard {
- target: __self_ptr,
- value: ::pin_project_lite::__private::ManuallyDrop::new(replacement),
- };
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
match &mut *__self_ptr {
Self::Struct {
pinned1,
@@ -52,8 +52,8 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned1),
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned2),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
(),
(),
);
diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs
index 638bf56..4320f68 100644
--- a/tests/expand/multifields/struct.expanded.rs
+++ b/tests/expand/multifields/struct.expanded.rs
@@ -97,10 +97,10 @@ const _: () = {
) -> StructProjReplace<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
- let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard {
- target: __self_ptr,
- value: ::pin_project_lite::__private::ManuallyDrop::new(replacement),
- };
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
let Self {
pinned1,
pinned2,
@@ -115,8 +115,8 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned1),
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned2),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned1),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned2),
(),
(),
);
diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs
index df005ad..eae0aac 100644
--- a/tests/expand/naming/enum-all.expanded.rs
+++ b/tests/expand/naming/enum-all.expanded.rs
@@ -86,10 +86,10 @@ const _: () = {
) -> EnumProjReplace<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
- let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard {
- target: __self_ptr,
- value: ::pin_project_lite::__private::ManuallyDrop::new(replacement),
- };
+ let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard::new(
+ __self_ptr,
+ replacement,
+ );
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let result = EnumProjReplace::Struct {
@@ -98,7 +98,7 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
(),
);
}
diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs
index 5d2f135..b91c24e 100644
--- a/tests/expand/naming/struct-all.expanded.rs
+++ b/tests/expand/naming/struct-all.expanded.rs
@@ -75,10 +75,10 @@ const _: () = {
) -> StructProjReplace<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
- let __guard = ::pin_project_lite::__private::UnsafeOverwriteGuard {
- target: __self_ptr,
- value: ::pin_project_lite::__private::ManuallyDrop::new(replacement),
- };
+ 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,
@@ -86,7 +86,7 @@ const _: () = {
};
{
(
- ::pin_project_lite::__private::UnsafeDropInPlaceGuard(pinned),
+ ::pin_project_lite::__private::UnsafeDropInPlaceGuard::new(pinned),
(),
);
}
diff --git a/tests/lint.rs b/tests/lint.rs
index 2324cd5..792adce 100644
--- a/tests/lint.rs
+++ b/tests/lint.rs
@@ -1,15 +1,22 @@
// 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)]
-#![allow(unknown_lints)] // for old compilers
-#![forbid(unsafe_code)]
+#![forbid(future_incompatible, rust_2018_compatibility, rust_2021_compatibility)]
+// lints forbidden as a part of future_incompatible, rust_2018_compatibility, and rust_2021_compatibility are not included in the list below.
+// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: as a part of rust_2018_idioms
+// unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn.
+// non_exhaustive_omitted_patterns: unstable
+// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features
+// unused_crate_dependencies: unrelated
+// unsafe_code: checked in forbid_unsafe module
#![warn(
box_pointers,
deprecated_in_future,
- disjoint_capture_migration,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
@@ -28,14 +35,7 @@
unused_results,
variant_size_differences
)]
-// rust_2018_compatibility, rust_2021_compatibility, absolute_paths_not_starting_with_crate, etc.: forbidden as a part of future_incompatible
-// elided_lifetimes_in_paths, explicit_outlives_requirements, unused_extern_crates: warned as a part of rust_2018_idioms
-// unsafe_block_in_unsafe_fn: unsafe_block_in_unsafe_fn: requires Rust 1.52. and, we don't generate unsafe fn.
-// unstable_features: no way to generate #![feature(..)] by macros, expect for unstable inner attribute. and this lint is deprecated: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features
-// unused_crate_dependencies: unrelated
-// unsafe_code: forbidden
-#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
-#![warn(clippy::restriction)]
+#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)]
#![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] // TODO
@@ -161,7 +161,6 @@ mod clippy_redundant_pub_crate {
}
}
- #[allow(dead_code)]
pin_project! {
#[project = EnumProj]
#[project_ref = EnumProjRef]
@@ -177,6 +176,7 @@ mod clippy_redundant_pub_crate {
}
}
+#[allow(clippy::use_self)]
pub mod clippy_type_repetition_in_bounds {
use pin_project_lite::pin_project;
diff --git a/tests/test.rs b/tests/test.rs
index 162fc20..ed9b75c 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -665,4 +665,31 @@ fn pinned_drop() {
}
}
}
+
+ 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/tests/ui/pin_project/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr
index bbfc910..8531d08 100644
--- a/tests/ui/pin_project/conflict-drop.stderr
+++ b/tests/ui/pin_project/conflict-drop.stderr
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type `Foo<_, _>`
- --> $DIR/conflict-drop.rs:3:1
+ --> tests/ui/pin_project/conflict-drop.rs:3:1
|
3 | / pin_project! { //~ ERROR E0119
4 | | struct Foo<T, U> {
diff --git a/tests/ui/pin_project/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr
index 18bdd92..0c3141c 100644
--- a/tests/ui/pin_project/conflict-unpin.stderr
+++ b/tests/ui/pin_project/conflict-unpin.stderr
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
- --> $DIR/conflict-unpin.rs:5:1
+ --> tests/ui/pin_project/conflict-unpin.rs:5:1
|
5 | / pin_project! { //~ ERROR E0119
6 | | struct Foo<T, U> {
@@ -16,7 +16,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type
= note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
- --> $DIR/conflict-unpin.rs:18:1
+ --> tests/ui/pin_project/conflict-unpin.rs:18:1
|
18 | / pin_project! { //~ ERROR E0119
19 | | struct Bar<T, U> {
@@ -33,7 +33,7 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type
= note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
- --> $DIR/conflict-unpin.rs:29:1
+ --> tests/ui/pin_project/conflict-unpin.rs:29:1
|
29 | / pin_project! { //~ ERROR E0119
30 | | struct Baz<T, U> {
diff --git a/tests/ui/pin_project/invalid-bounds.stderr b/tests/ui/pin_project/invalid-bounds.stderr
index b276989..e179565 100644
--- a/tests/ui/pin_project/invalid-bounds.stderr
+++ b/tests/ui/pin_project/invalid-bounds.stderr
@@ -1,5 +1,5 @@
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:3:1
+ --> tests/ui/pin_project/invalid-bounds.rs:3:1
|
3 | / pin_project! {
4 | | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:`
@@ -8,10 +8,10 @@ error: no rules expected the token `[`
7 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:9:1
+ --> tests/ui/pin_project/invalid-bounds.rs:9:1
|
9 | / pin_project! {
10 | | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:`
@@ -20,10 +20,10 @@ error: no rules expected the token `[`
13 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
- --> $DIR/invalid-bounds.rs:15:1
+ --> tests/ui/pin_project/invalid-bounds.rs:15:1
|
15 | / pin_project! {
16 | | struct Generics3<T: Sized : 'static> { //~ ERROR expected one of `+`, `,`, `=`, or `>`, found `:`
@@ -39,7 +39,22 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
= note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
- --> $DIR/invalid-bounds.rs:21:1
+ --> 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_internal` (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 `:`
@@ -55,7 +70,22 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
= note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `+`, `,`, `=`, or `>`, found `:`
- --> $DIR/invalid-bounds.rs:27:1
+ --> 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_internal` (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 `:`
@@ -70,8 +100,23 @@ error: expected one of `+`, `,`, `=`, or `>`, found `:`
|
= note: this error originates in the macro `$crate::__pin_project_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:33:1
+ --> tests/ui/pin_project/invalid-bounds.rs:33:1
|
33 | / pin_project! {
34 | | struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized`
@@ -80,10 +125,10 @@ error: no rules expected the token `[`
37 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:39:1
+ --> tests/ui/pin_project/invalid-bounds.rs:39:1
|
39 | / pin_project! {
40 | | struct WhereClause1<T>
@@ -94,10 +139,10 @@ error: no rules expected the token `[`
46 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:48:1
+ --> tests/ui/pin_project/invalid-bounds.rs:48:1
|
48 | / pin_project! {
49 | | struct WhereClause2<T>
@@ -108,10 +153,10 @@ error: no rules expected the token `[`
55 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected `where`, or `{` after struct name, found `:`
- --> $DIR/invalid-bounds.rs:57:1
+ --> tests/ui/pin_project/invalid-bounds.rs:57:1
|
57 | / pin_project! {
58 | | struct WhereClause3<T>
@@ -127,8 +172,25 @@ error: expected `where`, or `{` after struct name, found `:`
|
= note: this error originates in the macro `$crate::__pin_project_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: expected `where`, or `{` after struct name, found `:`
- --> $DIR/invalid-bounds.rs:66:1
+ --> tests/ui/pin_project/invalid-bounds.rs:66:1
|
66 | / pin_project! {
67 | | struct WhereClause4<T>
@@ -144,8 +206,25 @@ error: expected `where`, or `{` after struct name, found `:`
|
= note: this error originates in the macro `$crate::__pin_project_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: expected `where`, or `{` after struct name, found `:`
- --> $DIR/invalid-bounds.rs:75:1
+ --> tests/ui/pin_project/invalid-bounds.rs:75:1
|
75 | / pin_project! {
76 | | struct WhereClause5<T>
@@ -161,8 +240,25 @@ error: expected `where`, or `{` after struct name, found `:`
|
= note: this error originates in the macro `$crate::__pin_project_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: no rules expected the token `[`
- --> $DIR/invalid-bounds.rs:84:1
+ --> tests/ui/pin_project/invalid-bounds.rs:84:1
|
84 | / pin_project! {
85 | | struct WhereClause6<T>
@@ -173,4 +269,4 @@ error: no rules expected the token `[`
91 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/invalid.stderr b/tests/ui/pin_project/invalid.stderr
index 38df517..1e363d7 100644
--- a/tests/ui/pin_project/invalid.stderr
+++ b/tests/ui/pin_project/invalid.stderr
@@ -1,5 +1,5 @@
-error: no rules expected the token `[`
- --> $DIR/invalid.rs:3:1
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:3:1
|
3 | / pin_project! {
4 | | struct A<T> {
@@ -9,10 +9,10 @@ error: no rules expected the token `[`
8 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: no rules expected the token `[`
- --> $DIR/invalid.rs:17:1
+error: no rules expected the token `struct`
+ --> tests/ui/pin_project/invalid.rs:17:1
|
17 | / pin_project! {
18 | | struct C<T> {
@@ -23,10 +23,10 @@ error: no rules expected the token `[`
23 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: cannot find attribute `pin` in this scope
- --> $DIR/invalid.rs:11:7
+ --> tests/ui/pin_project/invalid.rs:11:7
|
11 | #[pin] //~ ERROR cannot find attribute `pin` in this scope
| ^^^
diff --git a/tests/ui/pin_project/overlapping_lifetime_names.stderr b/tests/ui/pin_project/overlapping_lifetime_names.stderr
index f87875d..dfd4235 100644
--- a/tests/ui/pin_project/overlapping_lifetime_names.stderr
+++ b/tests/ui/pin_project/overlapping_lifetime_names.stderr
@@ -1,5 +1,5 @@
error[E0263]: lifetime name `'__pin` declared twice in the same scope
- --> $DIR/overlapping_lifetime_names.rs:4:20
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:4:20
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
@@ -10,46 +10,8 @@ error[E0263]: lifetime name `'__pin` declared twice in the same scope
8 | | }
| |_- previous declaration here
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
- --> $DIR/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
- --> $DIR/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
- --> $DIR/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_internal` (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
- --> $DIR/overlapping_lifetime_names.rs:3:1
+ --> tests/ui/pin_project/overlapping_lifetime_names.rs:3:1
|
3 | / pin_project! { //~ ERROR E0263,E0496
4 | | pub struct Foo<'__pin, T> {
@@ -61,15 +23,3 @@ error[E0496]: lifetime name `'__pin` shadows a lifetime name that is already in
| |_^ lifetime `'__pin` already in scope
|
= note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error[E0263]: lifetime name `'__pin` declared twice in the same scope
- --> $DIR/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/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr
index 9486f9d..1049879 100644
--- a/tests/ui/pin_project/overlapping_unpin_struct.stderr
+++ b/tests/ui/pin_project/overlapping_unpin_struct.stderr
@@ -1,15 +1,12 @@
error[E0277]: `PhantomPinned` cannot be unpinned
- --> $DIR/overlapping_unpin_struct.rs:19:5
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:19:5
|
-16 | fn is_unpin<T: Unpin>() {}
- | ----- required by this bound in `is_unpin`
-...
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>`
- --> $DIR/overlapping_unpin_struct.rs:5:1
+ --> tests/ui/pin_project/overlapping_unpin_struct.rs:5:1
|
5 | / pin_project! {
6 | | struct Foo<T> {
@@ -18,5 +15,19 @@ note: required because it appears within the type `_::__Origin<'_, PhantomPinned
9 | | }
10 | | }
| |_^
- = note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>`
+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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/packed.stderr b/tests/ui/pin_project/packed.stderr
index 85f84c2..40a955e 100644
--- a/tests/ui/pin_project/packed.stderr
+++ b/tests/ui/pin_project/packed.stderr
@@ -1,5 +1,5 @@
error: reference to packed field is unaligned
- --> $DIR/packed.rs:5:1
+ --> tests/ui/pin_project/packed.rs:5:1
|
5 | / pin_project! { //~ ERROR reference to packed field is unaligned
6 | | #[repr(packed, C)]
@@ -11,7 +11,7 @@ error: reference to packed field is unaligned
| |_^
|
note: the lint level is defined here
- --> $DIR/packed.rs:5:1
+ --> tests/ui/pin_project/packed.rs:5:1
|
5 | / pin_project! { //~ ERROR reference to packed field is unaligned
6 | | #[repr(packed, C)]
@@ -24,10 +24,11 @@ note: the lint level is defined here
= 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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: reference to packed field is unaligned
- --> $DIR/packed.rs:13:1
+ --> tests/ui/pin_project/packed.rs:13:1
|
13 | / pin_project! { //~ ERROR reference to packed field is unaligned
14 | | #[repr(packed(2))]
@@ -39,7 +40,7 @@ error: reference to packed field is unaligned
| |_^
|
note: the lint level is defined here
- --> $DIR/packed.rs:13:1
+ --> tests/ui/pin_project/packed.rs:13:1
|
13 | / pin_project! { //~ ERROR reference to packed field is unaligned
14 | | #[repr(packed(2))]
@@ -52,4 +53,5 @@ note: the lint level is defined here
= 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_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pin_project/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr
index 39a7745..4eb6eff 100644
--- a/tests/ui/pin_project/unpin_sneaky.stderr
+++ b/tests/ui/pin_project/unpin_sneaky.stderr
@@ -1,11 +1,11 @@
error[E0412]: cannot find type `__Origin` in this scope
- --> $DIR/unpin_sneaky.rs:10:16
+ --> 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]`
- --> $DIR/unpin_sneaky.rs:10:1
+ --> 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/tests/ui/pin_project/unsupported.stderr b/tests/ui/pin_project/unsupported.stderr
index 892e57c..d95f455 100644
--- a/tests/ui/pin_project/unsupported.stderr
+++ b/tests/ui/pin_project/unsupported.stderr
@@ -1,35 +1,35 @@
-error: no rules expected the token `[`
- --> $DIR/unsupported.rs:3:1
+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 `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `[`
- --> $DIR/unsupported.rs:7:1
+ --> tests/ui/pin_project/unsupported.rs:7:1
|
7 | / pin_project! {
8 | | struct Struct2(); //~ ERROR no rules expected the token `(`
9 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: no rules expected the token `[`
- --> $DIR/unsupported.rs:11:1
+ --> tests/ui/pin_project/unsupported.rs:11:1
|
11 | / pin_project! {
12 | | struct Struct3; //~ ERROR no rules expected the token `;`
13 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: no rules expected the token `[`
- --> $DIR/unsupported.rs:15:1
+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`
@@ -38,10 +38,10 @@ error: no rules expected the token `[`
19 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: no rules expected the token `[`
- --> $DIR/unsupported.rs:21:1
+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`
@@ -50,4 +50,4 @@ error: no rules expected the token `[`
25 | | }
| |_^ no rules expected this token in macro call
|
- = note: this error originates in the macro `pin_project` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr
index 576e417..5bcb728 100644
--- a/tests/ui/pinned_drop/call-drop-inner.stderr
+++ b/tests/ui/pinned_drop/call-drop-inner.stderr
@@ -1,5 +1,5 @@
error[E0061]: this function takes 0 arguments but 1 argument was supplied
- --> $DIR/call-drop-inner.rs:10:13
+ --> tests/ui/pinned_drop/call-drop-inner.rs:10:13
|
10 | __drop_inner(this);
| ^^^^^^^^^^^^ ---- supplied 1 argument
@@ -7,7 +7,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
| expected 0 arguments
|
note: function defined here
- --> $DIR/call-drop-inner.rs:3:1
+ --> tests/ui/pinned_drop/call-drop-inner.rs:3:1
|
3 | / pin_project! {
4 | | pub struct S {
diff --git a/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr
index a67bc8d..f6c2075 100644
--- a/tests/ui/pinned_drop/conditional-drop-impl.stderr
+++ b/tests/ui/pinned_drop/conditional-drop-impl.stderr
@@ -1,11 +1,11 @@
error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
- --> $DIR/conditional-drop-impl.rs:9:9
+ --> 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
- --> $DIR/conditional-drop-impl.rs:5:1
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:5:1
|
5 | / struct DropImpl<T> {
6 | | f: T,
@@ -13,7 +13,7 @@ note: the implementor must specify the same requirement
| |_^
error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented for does not
- --> $DIR/conditional-drop-impl.rs:14:1
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
|
14 | / pin_project! {
15 | | //~^ ERROR E0367
@@ -25,7 +25,7 @@ error[E0367]: `Drop` impl requires `T: Unpin` but the struct it is implemented f
| |_^
|
note: the implementor must specify the same requirement
- --> $DIR/conditional-drop-impl.rs:14:1
+ --> tests/ui/pinned_drop/conditional-drop-impl.rs:14:1
|
14 | / pin_project! {
15 | | //~^ ERROR E0367