Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed May 12, 2023
1 parent 201a158 commit 217e2ec
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trybuild = "=1.0.67"

# For test on MSRV.
once_cell = "=1.14"
serde = "=1.0.159"
serde = "1.0.159"
toml = "=0.5.9"

[patch.crates-io]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/pin_project/add-attr-to-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use auxiliary_macro::add_pin_attr;
use pin_project::pin_project;

#[pin_project]
#[pin] //~ ERROR duplicate #[pin] attribute
struct Foo {
#[pin]
#[pin] //~ ERROR duplicate #[pin] attribute
f: PhantomPinned,
}

Expand Down
16 changes: 12 additions & 4 deletions tests/ui/pin_project/add-attr-to-struct.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: duplicate #[pin] attribute
--> tests/ui/pin_project/add-attr-to-struct.rs:9:5
error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/add-attr-to-struct.rs:7:1
|
9 | #[pin] //~ ERROR duplicate #[pin] attribute
| ^^^^^^
7 | #[pin] //~ ERROR duplicate #[pin] attribute
| ^^^^^^

error: #[pin] attribute may only be used on fields of structs or variants
--> tests/ui/pin_project/add-attr-to-struct.rs:13:1
Expand All @@ -11,3 +11,11 @@ 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)

warning: unused import: `std::marker::PhantomPinned`
--> tests/ui/pin_project/add-attr-to-struct.rs:1:5
|
1 | use std::marker::PhantomPinned;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
3 changes: 2 additions & 1 deletion tests/ui/pin_project/packed_sneaky-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ error[E0793]: reference to packed field is unaligned
10 | f: u32,
| ^
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: 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[E0793]: reference to packed field is unaligned
Expand Down
13 changes: 5 additions & 8 deletions tests/ui/pin_project/project_replace_unsized.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,12 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
| ^ 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 `read`
--> /rustc/cba14074bb4cc12bfe918eabd0d52a3999b2a461/library/core/src/ptr/mod.rs:1139:1
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
4 - struct Struct<T: ?Sized> {
4 + struct Struct<T> {
|
|
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
Expand Down
13 changes: 5 additions & 8 deletions tests/ui/pin_project/project_replace_unsized_fn_params.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
| ^ 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 `read`
--> /rustc/cba14074bb4cc12bfe918eabd0d52a3999b2a461/library/core/src/ptr/mod.rs:1139:1
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
6 - struct Struct<T: ?Sized> {
6 + struct Struct<T> {
|
|
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
Expand Down
22 changes: 10 additions & 12 deletions tests/ui/pin_project/remove-attr-from-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ error[E0277]: `PhantomPinned` cannot be unpinned
35 | is_unpin::<A>(); //~ ERROR E0277
| ^ within `A`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `A`
--> tests/ui/pin_project/remove-attr-from-struct.rs:10:8
|
Expand All @@ -42,7 +43,8 @@ error[E0277]: `PhantomPinned` cannot be unpinned
36 | is_unpin::<B>(); //~ ERROR E0277
| ^ within `B`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `B`
--> tests/ui/pin_project/remove-attr-from-struct.rs:17:8
|
Expand All @@ -62,17 +64,15 @@ error[E0277]: `PhantomPinned` cannot be unpinned
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
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`
--> /rustc/cba14074bb4cc12bfe918eabd0d52a3999b2a461/library/core/src/pin.rs:501:5

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
Expand All @@ -88,17 +88,15 @@ error[E0277]: `PhantomPinned` cannot be unpinned
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
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`
--> /rustc/cba14074bb4cc12bfe918eabd0d52a3999b2a461/library/core/src/pin.rs:501:5

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
Expand Down

0 comments on commit 217e2ec

Please sign in to comment.