Skip to content

Commit

Permalink
Merge #110
Browse files Browse the repository at this point in the history
110: Add ui test for marker_trait_attr feature r=taiki-e a=taiki-e

cc #105 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Sep 26, 2019
2 parents 04ba1a9 + 09137b2 commit 0cf5990
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ members = ["pin-project-internal"]
pin-project-internal = { version = "=0.4.0", path = "pin-project-internal", default-features = false }

[dev-dependencies]
compiletest = { version = "0.3.21", package = "compiletest_rs", features = ["stable", "tmp"] }
compiletest = { version = "=0.3.22", package = "compiletest_rs", features = ["stable", "tmp"] }
23 changes: 23 additions & 0 deletions tests/ui/unstable-features/marker_trait_attr-feature-gate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// compile-fail

// NB: If you change this test, change 'marker_trait_attr.rs' at the same time.

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

#[pin_project] //~ ERROR E0119
struct Foo<T> {
#[pin]
x: T,
}

// unsound Unpin impl
impl<T> Unpin for Foo<T> {}

fn is_unpin<T: Unpin>() {}

fn foo_is_unpin() {
is_unpin::<Foo<PhantomPinned>>()
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/unstable-features/marker_trait_attr-feature-gate.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_>`:
--> $DIR/marker_trait_attr-feature-gate.rs:8:1
|
8 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_>`
...
15 | impl<T> Unpin for Foo<T> {}
| ------------------------ first implementation here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
29 changes: 29 additions & 0 deletions tests/ui/unstable-features/marker_trait_attr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// compile-fail

// NB: If you change this test, change 'marker_trait_attr-feature-gate.rs' at the same time.

// marker_trait_attr
// Tracking issue: https://github.com/rust-lang/rust/issues/29864
#![feature(marker_trait_attr)]

// See https://github.com/taiki-e/pin-project/issues/105#issuecomment-535355974

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

#[pin_project] //~ ERROR E0119
struct Foo<T> {
#[pin]
x: T,
}

// unsound Unpin impl
impl<T> Unpin for Foo<T> {}

fn is_unpin<T: Unpin>() {}

fn foo_is_unpin() {
is_unpin::<Foo<PhantomPinned>>()
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/unstable-features/marker_trait_attr.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_>`:
--> $DIR/marker_trait_attr.rs:14:1
|
14 | #[pin_project] //~ ERROR E0119
| ^^^^^^^^^^^^^^ conflicting implementation for `Foo<_>`
...
21 | impl<T> Unpin for Foo<T> {}
| ------------------------ first implementation here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.

0 comments on commit 0cf5990

Please sign in to comment.