Skip to content

Commit

Permalink
Merge #119
Browse files Browse the repository at this point in the history
119: Add more tests for trivial_bounds r=taiki-e a=taiki-e

Add more tests about the current behavior of `trivial_bounds`.

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Oct 9, 2019
2 parents 2d7e4d0 + 3f73e34 commit 317b335
Show file tree
Hide file tree
Showing 76 changed files with 409 additions and 324 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
build:
# This is the minimum Rust version supported by pin-project.
Expand Down Expand Up @@ -117,7 +116,7 @@ jobs:
run: |
set -e
rustup update nightly && rustup default nightly
- name: Install ${{ matrix.component }}
- name: Install component
if: matrix.component != 'rustdoc'
run: |
set +e
Expand All @@ -138,12 +137,10 @@ jobs:
- name: cargo clippy
if: matrix.component == 'clippy'
run: |
cargo clippy -V
cargo clippy --all --all-features
- name: cargo fmt -- --check
if: matrix.component == 'rustfmt'
run: |
rustfmt -V
cargo fmt --all -- --check
- name: cargo doc
if: matrix.component == 'rustdoc'
Expand Down
6 changes: 3 additions & 3 deletions pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#![warn(unsafe_code)]
#![warn(rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::use_self)]
#![allow(clippy::use_self, clippy::needless_doctest_main)]
#![cfg_attr(proc_macro_def_site, feature(proc_macro_def_site))]

extern crate proc_macro;
Expand Down Expand Up @@ -216,7 +216,7 @@ use utils::{Immutable, Mutable};
/// }
///
/// fn main() {
/// Foo { pinned_field: true, unpin_field: 40 };
/// let _x = Foo { pinned_field: true, unpin_field: 40 };
/// }
/// ```
///
Expand Down Expand Up @@ -352,7 +352,7 @@ pub fn pin_project(args: TokenStream, input: TokenStream) -> TokenStream {
/// }
///
/// fn main() {
/// Foo { field: 50 };
/// let _x = Foo { field: 50 };
/// }
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#![warn(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms, single_use_lifetimes, unreachable_pub)]
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::use_self)]
#![allow(clippy::use_self, clippy::needless_doctest_main)]

#[doc(inline)]
pub use pin_project_internal::pin_project;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/field_sneaky.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

#![feature(optin_builtin_traits)]
#![feature(trivial_bounds)]

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cfg/field_sneaky.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0027]: pattern does not mention field `__field`
--> $DIR/field_sneaky.rs:11:14
|
11 | #[pin_project] //~ ERROR pattern does not mention field `__field`
| ^ missing field `__field`
--> $DIR/field_sneaky.rs:9:14
|
9 | #[pin_project] //~ ERROR pattern does not mention field `__field`
| ^ missing field `__field`
2 changes: 0 additions & 2 deletions tests/ui/cfg/packed_sneaky-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

#[macro_use]
extern crate auxiliary_macros;

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cfg/packed_sneaky-1.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
--> $DIR/packed_sneaky-1.rs:19:1
--> $DIR/packed_sneaky-1.rs:17:1
|
19 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
17 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/packed_sneaky-1.rs:19:1
--> $DIR/packed_sneaky-1.rs:17:1
|
19 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
17 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
| ^^^^^^^^^^^^^^
= 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>
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/packed_sneaky-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

#[macro_use]
extern crate auxiliary_macros;

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cfg/packed_sneaky-2.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
--> $DIR/packed_sneaky-2.rs:9:1
--> $DIR/packed_sneaky-2.rs:7:1
|
9 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
7 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/packed_sneaky-2.rs:9:1
--> $DIR/packed_sneaky-2.rs:7:1
|
9 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
7 | #[pin_project] //~ ERROR borrow of packed field is unsafe and requires unsafe function or block
| ^^^^^^^^^^^^^^
= 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>
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/proper_unpin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;
use std::marker::PhantomPinned;

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/cfg/proper_unpin.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied in `UnpinStructBar<'_, std::marker::PhantomPinned>`
--> $DIR/proper_unpin.rs:29:5
--> $DIR/proper_unpin.rs:27:5
|
24 | fn is_unpin<T: Unpin>() {}
22 | fn is_unpin<T: Unpin>() {}
| -------- ----- required by this bound in `is_unpin`
...
29 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
27 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `UnpinStructBar<'_, std::marker::PhantomPinned>`, the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned`
|
= help: the following implementations were found:
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/run-pass/packed_sneaky.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// run-pass

#[macro_use]
extern crate auxiliary_macros;

Expand Down
2 changes: 0 additions & 2 deletions tests/ui/cfg/tuple-struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

#[cfg(not(any()))]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cfg/tuple-struct.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `cfg` attributes on the field of tuple structs are not supported
--> $DIR/tuple-struct.rs:12:5
--> $DIR/tuple-struct.rs:10:5
|
12 | #[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple structs are not supported
10 | #[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple structs are not supported
| ^^^^^^^^^^^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/cfg/tuple-variant.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

#[cfg(not(any()))]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cfg/tuple-variant.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `cfg` attributes on the field of tuple variants are not supported
--> $DIR/tuple-variant.rs:13:9
--> $DIR/tuple-variant.rs:11:9
|
13 | #[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple variants are not supported
11 | #[cfg(not(any()))] //~ ERROR `cfg` attributes on the field of tuple variants are not supported
| ^^^^^^^^^^^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/cfg/unsupported.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

#[pin_project]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cfg/unsupported.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error: #[pin_project] attribute may not be used on structs with zero fields

error[E0392]: parameter `'_pin` is never used
--> $DIR/unsupported.rs:5:1
--> $DIR/unsupported.rs:3:1
|
5 | #[pin_project]
3 | #[pin_project]
| ^^^^^^^^^^^^^^ unused parameter
|
= help: consider removing `'_pin`, referring to it in a field, or using a marker such as `std::marker::PhantomData`
2 changes: 0 additions & 2 deletions tests/ui/pin_project/conflict-drop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/pin_project/conflict-drop.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0119]: conflicting implementations of trait `FooMustNotImplDrop` for type `Foo<_, _>`:
--> $DIR/conflict-drop.rs:6:1
--> $DIR/conflict-drop.rs:4:1
|
6 | #[pin_project] //~ ERROR E0119
4 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `Foo<_, _>`

error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `Bar<_, _>`:
--> $DIR/conflict-drop.rs:17:1
--> $DIR/conflict-drop.rs:15:1
|
17 | #[pin_project(PinnedDrop)] //~ ERROR E0119
15 | #[pin_project(PinnedDrop)] //~ ERROR E0119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
29 | impl<T, U> Drop for Bar<T, U> {
27 | impl<T, U> Drop for Bar<T, U> {
| ----------------------------- first implementation here
2 changes: 0 additions & 2 deletions tests/ui/pin_project/conflict-unpin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

// The same implementation.
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/pin_project/conflict-unpin.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`:
--> $DIR/conflict-unpin.rs:7:1
--> $DIR/conflict-unpin.rs:5:1
|
7 | #[pin_project] //~ ERROR E0119
5 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_, _>`
...
15 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
13 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {} // Conditional Unpin impl
| --------------------------------------------- first implementation here

error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`:
--> $DIR/conflict-unpin.rs:19:1
--> $DIR/conflict-unpin.rs:17:1
|
19 | #[pin_project] //~ ERROR E0119
17 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Bar<_, _>`
...
27 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
25 | impl<T, U> Unpin for Bar<T, U> {} // Non-conditional Unpin impl
| ------------------------------ first implementation here

error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`:
--> $DIR/conflict-unpin.rs:29:1
--> $DIR/conflict-unpin.rs:27:1
|
29 | #[pin_project] //~ ERROR E0119
27 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Baz<_, _>`
...
37 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
35 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {} // Conditional Unpin impl
| -------------------------------------------- first implementation here
2 changes: 0 additions & 2 deletions tests/ui/pin_project/invalid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

#[pin_project]
Expand Down
36 changes: 18 additions & 18 deletions tests/ui/pin_project/invalid.stderr
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
error: unexpected token
--> $DIR/invalid.rs:7:10
--> $DIR/invalid.rs:5:10
|
7 | #[pin()] //~ ERROR unexpected token
5 | #[pin()] //~ ERROR unexpected token
| ^

error: unexpected token
--> $DIR/invalid.rs:12:18
--> $DIR/invalid.rs:10:18
|
12 | struct B<T>(#[pin(foo)] T); //~ ERROR unexpected token
10 | struct B<T>(#[pin(foo)] T); //~ ERROR unexpected token
| ^

error: unexpected token
--> $DIR/invalid.rs:16:12
--> $DIR/invalid.rs:14:12
|
16 | A(#[pin(foo)] T), //~ ERROR unexpected token
14 | A(#[pin(foo)] T), //~ ERROR unexpected token
| ^

error: unexpected token
--> $DIR/invalid.rs:22:14
--> $DIR/invalid.rs:20:14
|
22 | #[pin(foo)] //~ ERROR unexpected token
20 | #[pin(foo)] //~ ERROR unexpected token
| ^

error: expected identifier
--> $DIR/invalid.rs:27:27
--> $DIR/invalid.rs:25:27
|
27 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
25 | #[pin_project(UnsafeUnpin,,)] //~ ERROR expected identifier
| ^

error: duplicate `UnsafeUnpin` argument
--> $DIR/invalid.rs:33:28
--> $DIR/invalid.rs:31:28
|
33 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
31 | #[pin_project(UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^

error: duplicate `PinnedDrop` argument
--> $DIR/invalid.rs:39:27
--> $DIR/invalid.rs:37:27
|
39 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
37 | #[pin_project(PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^

error: duplicate `UnsafeUnpin` argument
--> $DIR/invalid.rs:45:40
--> $DIR/invalid.rs:43:40
|
45 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
43 | #[pin_project(PinnedDrop, UnsafeUnpin, UnsafeUnpin)] //~ ERROR duplicate `UnsafeUnpin` argument
| ^^^^^^^^^^^

error: duplicate `PinnedDrop` argument
--> $DIR/invalid.rs:51:40
--> $DIR/invalid.rs:49:40
|
51 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
49 | #[pin_project(PinnedDrop, UnsafeUnpin, PinnedDrop, PinnedDrop)] //~ ERROR duplicate `PinnedDrop` argument
| ^^^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/pin_project/packed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

use pin_project::pin_project;

#[pin_project]
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/pin_project/packed.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> $DIR/packed.rs:6:8
--> $DIR/packed.rs:4:8
|
6 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
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
--> $DIR/packed.rs:13:8
--> $DIR/packed.rs:11:8
|
13 | #[repr(packed, C)] //~ ERROR may not be used on #[repr(packed)] types
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
--> $DIR/packed.rs:21:8
--> $DIR/packed.rs:19:8
|
21 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
19 | #[repr(packed(2))] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/pin_project/packed_sneaky-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-fail

#[macro_use]
extern crate auxiliary_macros;

Expand Down
Loading

0 comments on commit 317b335

Please sign in to comment.