diff options
Diffstat (limited to 'tests/ui')
28 files changed, 587 insertions, 413 deletions
diff --git a/tests/ui/invalid-bounds.stderr b/tests/ui/invalid-bounds.stderr deleted file mode 100644 index a565cce..0000000 --- a/tests/ui/invalid-bounds.stderr +++ /dev/null @@ -1,176 +0,0 @@ -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:3:1 - | -3 | / pin_project! { -4 | | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:` -5 | | field: T, -6 | | } -7 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:9:1 - | -9 | / pin_project! { -10 | | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:` -11 | | field: T, -12 | | } -13 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected one of `+`, `,`, `=`, or `>`, found `:` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:33:1 - | -33 | / pin_project! { -34 | | struct Generics6<T: ?Sized : Sized> { //~ ERROR no rules expected the token `Sized` -35 | | field: T, -36 | | } -37 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:39:1 - | -39 | / pin_project! { -40 | | struct WhereClause1<T> -41 | | where -42 | | T: 'static : Sized //~ ERROR no rules expected the token `:` -... | -45 | | } -46 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:48:1 - | -48 | / pin_project! { -49 | | struct WhereClause2<T> -50 | | where -51 | | T: 'static : ?Sized //~ ERROR no rules expected the token `:` -... | -54 | | } -55 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (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 - | -57 | / pin_project! { -58 | | struct WhereClause3<T> -59 | | where -60 | | T: Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:` -... | -63 | | } -64 | | } - | | ^ - | | | - | |_expected `where`, or `{` after struct name - | in this macro invocation - | - = note: this error originates in a macro (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 - | -66 | / pin_project! { -67 | | struct WhereClause4<T> -68 | | where -69 | | T: ?Sized : 'static //~ ERROR expected `where`, or `{` after struct name, found `:` -... | -72 | | } -73 | | } - | | ^ - | | | - | |_expected `where`, or `{` after struct name - | in this macro invocation - | - = note: this error originates in a macro (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 - | -75 | / pin_project! { -76 | | struct WhereClause5<T> -77 | | where -78 | | T: Sized : ?Sized //~ ERROR expected `where`, or `{` after struct name, found `:` -... | -81 | | } -82 | | } - | | ^ - | | | - | |_expected `where`, or `{` after struct name - | in this macro invocation - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/invalid-bounds.rs:84:1 - | -84 | / pin_project! { -85 | | struct WhereClause6<T> -86 | | where -87 | | T: ?Sized : Sized //~ ERROR no rules expected the token `Sized` -... | -90 | | } -91 | | } - | |_^ no rules expected this token in macro call - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/overlapping_lifetime_names.stderr b/tests/ui/overlapping_lifetime_names.stderr deleted file mode 100644 index 8a9bb4f..0000000 --- a/tests/ui/overlapping_lifetime_names.stderr +++ /dev/null @@ -1,75 +0,0 @@ -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 E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ------ first declared here -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_^ lifetime `'__pin` already in scope - | - = note: this error originates in a macro (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 - | -3 | / pin_project! { //~ ERROR E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ------ first declared here -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_^ lifetime `'__pin` already in scope - | - = note: this error originates in a macro (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 E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ^^^^^^ 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 E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ^^^^^^ 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 E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ^^^^^^ 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 E0496 -4 | | pub struct Foo<'__pin, T> { //~ ERROR E0263 - | | ^^^^^^ declared twice -5 | | #[pin] -6 | | field: &'__pin mut T, -7 | | } -8 | | } - | |_- previous declaration here diff --git a/tests/ui/overlapping_unpin_struct.stderr b/tests/ui/overlapping_unpin_struct.stderr deleted file mode 100644 index ab76f81..0000000 --- a/tests/ui/overlapping_unpin_struct.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `PhantomPinned` cannot be unpinned - --> $DIR/overlapping_unpin_struct.rs:18:5 - | -15 | fn is_unpin<T: Unpin>() {} - | ----- required by this bound in `is_unpin` -... -18 | is_unpin::<Foo<PhantomPinned>>(); //~ ERROR E0277 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `_::__Origin<'_, PhantomPinned>`, the trait `Unpin` is not implemented for `PhantomPinned` - | - = note: required because it appears within the type `_::__Origin<'_, PhantomPinned>` - = note: required because of the requirements on the impl of `Unpin` for `Foo<PhantomPinned>` diff --git a/tests/ui/packed.rs b/tests/ui/packed.rs deleted file mode 100644 index 0bccc1f..0000000 --- a/tests/ui/packed.rs +++ /dev/null @@ -1,19 +0,0 @@ -use pin_project_lite::pin_project; - -pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block - #[repr(packed, C)] - struct A { - #[pin] - field: u16, - } -} - -pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block - #[repr(packed(2))] - struct C { - #[pin] - field: u32, - } -} - -fn main() {} diff --git a/tests/ui/packed.stderr b/tests/ui/packed.stderr deleted file mode 100644 index a976163..0000000 --- a/tests/ui/packed.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error: borrow of packed field is unsafe and requires unsafe function or block (error E0133) - --> $DIR/packed.rs:3:1 - | -3 | / pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block -4 | | #[repr(packed, C)] -5 | | struct A { -6 | | #[pin] -7 | | field: u16, -8 | | } -9 | | } - | |_^ - | -note: the lint level is defined here - --> $DIR/packed.rs:3:1 - | -3 | / pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block -4 | | #[repr(packed, C)] -5 | | struct A { -6 | | #[pin] -7 | | field: u16, -8 | | } -9 | | } - | |_^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> - = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: borrow of packed field is unsafe and requires unsafe function or block (error E0133) - --> $DIR/packed.rs:11:1 - | -11 | / pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block -12 | | #[repr(packed(2))] -13 | | struct C { -14 | | #[pin] -15 | | field: u32, -16 | | } -17 | | } - | |_^ - | -note: the lint level is defined here - --> $DIR/packed.rs:11:1 - | -11 | / pin_project! { //~ ERROR borrow of packed field is unsafe and requires unsafe function or block -12 | | #[repr(packed(2))] -13 | | struct C { -14 | | #[pin] -15 | | field: u32, -16 | | } -17 | | } - | |_^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> - = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/conflict-drop.rs b/tests/ui/pin_project/conflict-drop.rs index 870059d..870059d 100644 --- a/tests/ui/conflict-drop.rs +++ b/tests/ui/pin_project/conflict-drop.rs diff --git a/tests/ui/conflict-drop.stderr b/tests/ui/pin_project/conflict-drop.stderr index f97c92b..8531d08 100644 --- a/tests/ui/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 +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> { @@ -13,4 +13,4 @@ error[E0119]: conflicting implementations of trait `_::MustNotImplDrop` for type | |_first implementation here | conflicting implementation for `Foo<_, _>` | - = note: this error originates in a macro (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/conflict-unpin.rs b/tests/ui/pin_project/conflict-unpin.rs index f702f06..f702f06 100644 --- a/tests/ui/conflict-unpin.rs +++ b/tests/ui/pin_project/conflict-unpin.rs diff --git a/tests/ui/conflict-unpin.stderr b/tests/ui/pin_project/conflict-unpin.stderr index 546dafd..0c3141c 100644 --- a/tests/ui/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 +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> { @@ -13,10 +13,10 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type 14 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl | --------------------------------------------- first implementation here | - = note: this error originates in a macro (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[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`: - --> $DIR/conflict-unpin.rs:18:1 +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> { @@ -30,10 +30,10 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type 27 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl | ------------------------------ first implementation here | - = note: this error originates in a macro (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[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`: - --> $DIR/conflict-unpin.rs:29:1 +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> { @@ -47,4 +47,4 @@ error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type 38 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl | -------------------------------------------- first implementation here | - = note: this error originates in a macro (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/invalid-bounds.rs b/tests/ui/pin_project/invalid-bounds.rs index 64b397a..64b397a 100644 --- a/tests/ui/invalid-bounds.rs +++ b/tests/ui/pin_project/invalid-bounds.rs diff --git a/tests/ui/pin_project/invalid-bounds.stderr b/tests/ui/pin_project/invalid-bounds.stderr new file mode 100644 index 0000000..e179565 --- /dev/null +++ b/tests/ui/pin_project/invalid-bounds.stderr @@ -0,0 +1,272 @@ +error: no rules expected the token `[` + --> tests/ui/pin_project/invalid-bounds.rs:3:1 + | +3 | / pin_project! { +4 | | struct Generics1<T: 'static : Sized> { //~ ERROR no rules expected the token `:` +5 | | field: T, +6 | | } +7 | | } + | |_^ no rules expected this token in macro call + | + = 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 `[` + --> tests/ui/pin_project/invalid-bounds.rs:9:1 + | +9 | / pin_project! { +10 | | struct Generics2<T: 'static : ?Sized> { //~ ERROR no rules expected the token `:` +11 | | field: T, +12 | | } +13 | | } + | |_^ no rules expected this token in macro call + | + = 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: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_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: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 `:` +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_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 `:` +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 `:` +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_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 `[` + --> 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` +35 | | field: T, +36 | | } +37 | | } + | |_^ no rules expected this token in macro call + | + = 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 `[` + --> tests/ui/pin_project/invalid-bounds.rs:39:1 + | +39 | / pin_project! { +40 | | struct WhereClause1<T> +41 | | where +42 | | T: 'static : Sized //~ ERROR no rules expected the token `:` +... | +45 | | } +46 | | } + | |_^ no rules expected this token in macro call + | + = 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 `[` + --> tests/ui/pin_project/invalid-bounds.rs:48:1 + | +48 | / pin_project! { +49 | | struct WhereClause2<T> +50 | | where +51 | | T: 'static : ?Sized //~ ERROR no rules expected the token `:` +... | +54 | | } +55 | | } + | |_^ no rules expected this token in macro call + | + = 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 `:` + --> 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 `where`, or `{` after struct name + | in this macro invocation + | + = 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 `:` + --> 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 `where`, or `{` after struct name + | in this macro invocation + | + = 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 `:` + --> 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 `where`, or `{` after struct name + | in this macro invocation + | + = 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 `[` + --> tests/ui/pin_project/invalid-bounds.rs:84:1 + | +84 | / pin_project! { +85 | | struct WhereClause6<T> +86 | | where +87 | | T: ?Sized : Sized //~ ERROR no rules expected the token `Sized` +... | +90 | | } +91 | | } + | |_^ no rules expected this token in macro call + | + = 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/invalid.rs b/tests/ui/pin_project/invalid.rs index e0ea61d..e0ea61d 100644 --- a/tests/ui/invalid.rs +++ b/tests/ui/pin_project/invalid.rs diff --git a/tests/ui/invalid.stderr b/tests/ui/pin_project/invalid.stderr index 06f2d79..1e363d7 100644 --- a/tests/ui/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 a macro (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 a macro (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/overlapping_lifetime_names.rs b/tests/ui/pin_project/overlapping_lifetime_names.rs index 87a737e..117c18d 100644 --- a/tests/ui/overlapping_lifetime_names.rs +++ b/tests/ui/pin_project/overlapping_lifetime_names.rs @@ -1,7 +1,7 @@ use pin_project_lite::pin_project; -pin_project! { //~ ERROR E0496 - pub struct Foo<'__pin, T> { //~ ERROR E0263 +pin_project! { //~ ERROR E0263,E0496 + pub struct Foo<'__pin, T> { #[pin] field: &'__pin mut T, } diff --git a/tests/ui/pin_project/overlapping_lifetime_names.stderr b/tests/ui/pin_project/overlapping_lifetime_names.stderr new file mode 100644 index 0000000..dfd4235 --- /dev/null +++ b/tests/ui/pin_project/overlapping_lifetime_names.stderr @@ -0,0 +1,25 @@ +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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/overlapping_unpin_struct.rs b/tests/ui/pin_project/overlapping_unpin_struct.rs index 1338524..25131d1 100644 --- a/tests/ui/overlapping_unpin_struct.rs +++ b/tests/ui/pin_project/overlapping_unpin_struct.rs @@ -1,6 +1,7 @@ -use pin_project_lite::pin_project; use std::marker::PhantomPinned; +use pin_project_lite::pin_project; + pin_project! { struct Foo<T> { #[pin] diff --git a/tests/ui/pin_project/overlapping_unpin_struct.stderr b/tests/ui/pin_project/overlapping_unpin_struct.stderr new file mode 100644 index 0000000..1049879 --- /dev/null +++ b/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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pin_project/packed.rs b/tests/ui/pin_project/packed.rs new file mode 100644 index 0000000..50afb11 --- /dev/null +++ b/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/tests/ui/pin_project/packed.stderr b/tests/ui/pin_project/packed.stderr new file mode 100644 index 0000000..40a955e --- /dev/null +++ b/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_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unpin_sneaky.rs b/tests/ui/pin_project/unpin_sneaky.rs index 984cc2a..984cc2a 100644 --- a/tests/ui/unpin_sneaky.rs +++ b/tests/ui/pin_project/unpin_sneaky.rs diff --git a/tests/ui/unpin_sneaky.stderr b/tests/ui/pin_project/unpin_sneaky.stderr index 39a7745..4eb6eff 100644 --- a/tests/ui/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/unsupported.rs b/tests/ui/pin_project/unsupported.rs index 2f80836..2f80836 100644 --- a/tests/ui/unsupported.rs +++ b/tests/ui/pin_project/unsupported.rs diff --git a/tests/ui/pin_project/unsupported.stderr b/tests/ui/pin_project/unsupported.stderr new file mode 100644 index 0000000..d95f455 --- /dev/null +++ b/tests/ui/pin_project/unsupported.stderr @@ -0,0 +1,53 @@ +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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: no rules expected the token `[` + --> 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 `$crate::__pin_project_internal` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: no rules expected the token `[` + --> 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 `$crate::__pin_project_internal` (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_internal` (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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pinned_drop/call-drop-inner.rs b/tests/ui/pinned_drop/call-drop-inner.rs new file mode 100644 index 0000000..609b3be --- /dev/null +++ b/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/tests/ui/pinned_drop/call-drop-inner.stderr b/tests/ui/pinned_drop/call-drop-inner.stderr new file mode 100644 index 0000000..5bcb728 --- /dev/null +++ b/tests/ui/pinned_drop/call-drop-inner.stderr @@ -0,0 +1,20 @@ +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); + | ^^^^^^^^^^^^ ---- supplied 1 argument + | | + | expected 0 arguments + | +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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pinned_drop/conditional-drop-impl.rs b/tests/ui/pinned_drop/conditional-drop-impl.rs new file mode 100644 index 0000000..68b01b2 --- /dev/null +++ b/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/tests/ui/pinned_drop/conditional-drop-impl.stderr b/tests/ui/pinned_drop/conditional-drop-impl.stderr new file mode 100644 index 0000000..f6c2075 --- /dev/null +++ b/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_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unsupported.stderr b/tests/ui/unsupported.stderr deleted file mode 100644 index 2cd17df..0000000 --- a/tests/ui/unsupported.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error: no rules expected the token `[` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: no rules expected the token `[` - --> $DIR/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 a macro (in Nightly builds, run with -Z macro-backtrace for more info) |