-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from madsmtm/trybuild
Use `trybuild` for testing compilation failures
- Loading branch information
Showing
29 changed files
with
470 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Test that AutoreleasePool is not Send and Sync, because it internally | ||
//! works with thread locals. | ||
|
||
use objc2::rc::AutoreleasePool; | ||
|
||
fn needs_sync<T: ?Sized + Sync>() {} | ||
fn needs_send<T: ?Sized + Send>() {} | ||
|
||
fn main() { | ||
needs_sync::<AutoreleasePool>(); | ||
needs_send::<AutoreleasePool>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
error[E0277]: `*mut c_void` cannot be shared between threads safely | ||
--> ui/autoreleasepool_not_send_sync.rs:10:5 | ||
| | ||
10 | needs_sync::<AutoreleasePool>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut c_void` cannot be shared between threads safely | ||
| | ||
= help: within `AutoreleasePool`, the trait `Sync` is not implemented for `*mut c_void` | ||
= note: required because it appears within the type `AutoreleasePool` | ||
note: required by a bound in `needs_sync` | ||
--> ui/autoreleasepool_not_send_sync.rs:6:27 | ||
| | ||
6 | fn needs_sync<T: ?Sized + Sync>() {} | ||
| ^^^^ required by this bound in `needs_sync` | ||
|
||
error[E0277]: `*mut UnsafeCell<c_void>` cannot be shared between threads safely | ||
--> ui/autoreleasepool_not_send_sync.rs:10:5 | ||
| | ||
10 | needs_sync::<AutoreleasePool>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut UnsafeCell<c_void>` cannot be shared between threads safely | ||
| | ||
= help: within `AutoreleasePool`, the trait `Sync` is not implemented for `*mut UnsafeCell<c_void>` | ||
= note: required because it appears within the type `PhantomData<*mut UnsafeCell<c_void>>` | ||
= note: required because it appears within the type `AutoreleasePool` | ||
note: required by a bound in `needs_sync` | ||
--> ui/autoreleasepool_not_send_sync.rs:6:27 | ||
| | ||
6 | fn needs_sync<T: ?Sized + Sync>() {} | ||
| ^^^^ required by this bound in `needs_sync` | ||
|
||
error[E0277]: `*mut c_void` cannot be sent between threads safely | ||
--> ui/autoreleasepool_not_send_sync.rs:11:5 | ||
| | ||
11 | needs_send::<AutoreleasePool>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut c_void` cannot be sent between threads safely | ||
| | ||
= help: within `AutoreleasePool`, the trait `Send` is not implemented for `*mut c_void` | ||
= note: required because it appears within the type `AutoreleasePool` | ||
note: required by a bound in `needs_send` | ||
--> ui/autoreleasepool_not_send_sync.rs:7:27 | ||
| | ||
7 | fn needs_send<T: ?Sized + Send>() {} | ||
| ^^^^ required by this bound in `needs_send` | ||
|
||
error[E0277]: `*mut UnsafeCell<c_void>` cannot be sent between threads safely | ||
--> ui/autoreleasepool_not_send_sync.rs:11:5 | ||
| | ||
11 | needs_send::<AutoreleasePool>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut UnsafeCell<c_void>` cannot be sent between threads safely | ||
| | ||
= help: within `AutoreleasePool`, the trait `Send` is not implemented for `*mut UnsafeCell<c_void>` | ||
= note: required because it appears within the type `PhantomData<*mut UnsafeCell<c_void>>` | ||
= note: required because it appears within the type `AutoreleasePool` | ||
note: required by a bound in `needs_send` | ||
--> ui/autoreleasepool_not_send_sync.rs:7:27 | ||
| | ||
7 | fn needs_send<T: ?Sized + Send>() {} | ||
| ^^^^ required by this bound in `needs_send` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use block2::global_block; | ||
|
||
global_block! { | ||
pub static BLOCK = |_b: Box<i32>| {}; | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0277]: the trait bound `Box<i32>: objc2_encode::encode::Encode` is not satisfied | ||
--> ui/global_block_not_encode.rs:3:1 | ||
| | ||
3 | / global_block! { | ||
4 | | pub static BLOCK = |_b: Box<i32>| {}; | ||
5 | | } | ||
| |_^ the trait `objc2_encode::encode::Encode` is not implemented for `Box<i32>` | ||
| | ||
= note: required because of the requirements on the impl of `objc2_encode::encode::EncodeArguments` for `(Box<i32>,)` | ||
= note: required because of the requirements on the impl of `Sync` for `GlobalBlock<(Box<i32>,)>` | ||
= note: shared static variables must have a type that implements `Sync` | ||
= note: this error originates in the macro `global_block` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! Test that forgetting to annotate the return type fails | ||
//! See https://github.com/SSheldon/rust-objc/issues/62 | ||
use objc2::{class, msg_send}; | ||
|
||
fn main() { | ||
unsafe { | ||
let cls = class!(NSObject); | ||
msg_send![cls, new]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error[E0282]: type annotations needed | ||
--> ui/msg_send_no_return_type.rs:8:9 | ||
| | ||
8 | msg_send![cls, new]; | ||
| ^^^^^^^^^^^^^^^^^^^ consider giving `result` a type | ||
| | ||
= note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//! Test that return types that are not `Encode` are not accepted. | ||
use objc2::{class, msg_send}; | ||
|
||
fn main() { | ||
unsafe { | ||
let cls = class!(NSData); | ||
let _: Vec<u8> = msg_send![cls, new]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0277]: the trait bound `Vec<u8>: Encode` is not satisfied | ||
--> ui/msg_send_not_encode.rs:7:26 | ||
| | ||
7 | let _: Vec<u8> = msg_send![cls, new]; | ||
| ^^^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `Vec<u8>` | ||
| | ||
note: required by a bound in `send_message` | ||
--> $WORKSPACE/objc2/src/message/mod.rs | ||
| | ||
| R: Encode, | ||
| ^^^^^^ required by this bound in `send_message` | ||
= note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//! Test that messages can only be sent to objects. | ||
use objc2::msg_send; | ||
|
||
fn main() { | ||
unsafe { msg_send![1, new] }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0277]: the trait bound `{integer}: MessageReceiver` is not satisfied | ||
--> ui/msg_send_only_message.rs:5:14 | ||
| | ||
5 | unsafe { msg_send![1, new] }; | ||
| ^^^^^^^^^^^^^^^^^ the trait `MessageReceiver` is not implemented for `{integer}` | ||
| | ||
= help: the following implementations were found: | ||
<&'a T as MessageReceiver> | ||
<&'a mut T as MessageReceiver> | ||
<*const T as MessageReceiver> | ||
<*mut T as MessageReceiver> | ||
and 3 others | ||
= note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use objc2::rc::Shared; | ||
use objc2::runtime::Object; | ||
use objc2_foundation::NSArray; | ||
|
||
fn needs_sync<T: ?Sized + Sync>() {} | ||
fn needs_send<T: ?Sized + Send>() {} | ||
|
||
fn main() { | ||
needs_sync::<NSArray<Object, Shared>>(); | ||
needs_send::<NSArray<Object, Shared>>(); | ||
} |
Oops, something went wrong.