Skip to content

Commit

Permalink
Merge pull request #69 from alex/fix-ci
Browse files Browse the repository at this point in the history
Attempt to fix CI and test on multiple rustc versions
  • Loading branch information
someguynamedjosh authored Aug 22, 2022
2 parents 7728ea2 + c28ba73 commit 027f840
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 42 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ env:
CARGO_TERM_COLOR: always

jobs:
stable-test:
test:
runs-on: ubuntu-latest
strategy:
matrix:
RUST: ["1.48", stable, beta, nightly]
steps:
- uses: actions/checkout@v2
- name: Set Rust version
run: rustup default 1.48.0
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v2
- name: Set Rust version
run: rustup default ${{ matrix.RUST }}
- name: Build
run: cargo build --verbose ${{ matrix.RUST != '1.48' && '--features=__tokio' || '' }}
- name: Run tests
run: cargo test --verbose ${{ matrix.RUST != '1.48' && '--features=__tokio' || '' }}

no-std-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Rust version
run: rustup default 1.60.0
- name: Build
run: cargo build --verbose --no-default-features
- name: Check under no_std
Expand Down
4 changes: 3 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ rustdoc-args = ["--document-private-items"]
default = []
# Disables any tests that are not compatible or not intended to run under Miri
miri = []
__tokio = ["tokio"]

[dependencies]
ouroboros = { version = "0.15.2", path = "../ouroboros" }
tokio = { version = "1", features = [ "macros", "rt" ], optional = true }

[dev-dependencies]
rustversion = "1.0"
trybuild = "1.0"
tokio = { version = "1", features = [ "macros", "rt" ] }
19 changes: 6 additions & 13 deletions examples/src/fail_tests/auto_covariant.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
error: Ouroboros cannot automatically determine if this type is covariant.

If it is covariant, it should be legal to convert any instance of that type to an instance of that type where all usages of 'this are replaced with a smaller lifetime. For example, Box<&'this i32> is covariant because it is legal to use it as a Box<&'a i32> where 'this: 'a. In contrast, Fn(&'this i32) cannot be used as Fn(&'a i32).
If it is covariant, it should be legal to convert any instance of that type to an instance of that type where all usages of 'this are replaced with a smaller lifetime. For example, Box<&'this i32> is covariant because it is legal to use it as a Box<&'a i32> where 'this: 'a. In contrast, Fn(&'this i32) cannot be used as Fn(&'a i32).

To resolve this error, add #[covariant] or #[not_covariant] to the field.

--> $DIR/auto_covariant.rs:11:12
To resolve this error, add #[covariant] or #[not_covariant] to the field.
--> src/fail_tests/auto_covariant.rs:11:12
|
11 | field: NotGuaranteedCovariant<'this>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0601]: `main` function not found in crate `$CRATE`
--> $DIR/auto_covariant.rs:1:1
--> src/fail_tests/auto_covariant.rs:12:2
|
1 | / use ouroboros::self_referencing;
2 | |
3 | | struct NotGuaranteedCovariant<'a> {
4 | | data: &'a (),
... |
11 | | field: NotGuaranteedCovariant<'this>
12 | | }
| |_^ consider adding a `main` function to `$DIR/src/fail_tests/auto_covariant.rs`
12 | }
| ^ consider adding a `main` function to `$DIR/src/fail_tests/auto_covariant.rs`
4 changes: 2 additions & 2 deletions examples/src/fail_tests/borrowchk_custom_drop.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: `bar` does not live long enough
--> $DIR/borrowchk_custom_drop.rs:7:1
--> src/fail_tests/borrowchk_custom_drop.rs:7:1
|
7 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^-
Expand All @@ -8,4 +8,4 @@ error[E0597]: `bar` does not live long enough
| | borrow might be used here, when `bar` is dropped and runs the `Drop` code for type `Bar`
| borrowed value does not live long enough
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 2 additions & 2 deletions examples/src/fail_tests/borrowchk_external_lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: `o` does not live long enough
--> $DIR/borrowchk_external_lifetime.rs:3:1
--> src/fail_tests/borrowchk_external_lifetime.rs:3:1
|
3 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^-
Expand All @@ -10,4 +10,4 @@ error[E0597]: `o` does not live long enough
4 | pub struct S<'a> {
| -- lifetime `'a` defined here
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
10 changes: 5 additions & 5 deletions examples/src/fail_tests/move_ref_outside_closure.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/move_ref_outside_closure.rs:16:48
--> src/fail_tests/move_ref_outside_closure.rs:16:48
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| ^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:28...
--> $DIR/move_ref_outside_closure.rs:16:28
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here...
--> src/fail_tests/move_ref_outside_closure.rs:16:28
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/move_ref_outside_closure.rs:16:53
--> src/fail_tests/move_ref_outside_closure.rs:16:53
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| ^^^^^
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that the expression is assignable
--> $DIR/move_ref_outside_closure.rs:16:48
--> src/fail_tests/move_ref_outside_closure.rs:16:48
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| ^^^^^^^^^^^
Expand Down
6 changes: 4 additions & 2 deletions examples/src/fail_tests/refuse_non_std_box.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
error[E0599]: no function or associated item named `is_std_box_type` found for struct `CheckIfTypeIsStd<Box<String>>` in the current scope
--> $DIR/refuse_non_std_box.rs:19:1
--> src/fail_tests/refuse_non_std_box.rs:19:1
|
19 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^^ function or associated item not found in `CheckIfTypeIsStd<Box<String>>`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: the function or associated item was found for
- `CheckIfTypeIsStd<std::boxed::Box<T>>`
= note: this error originates in the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 2 additions & 2 deletions examples/src/fail_tests/use_after_free.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0505]: cannot move out of `instance` because it is borrowed
--> $DIR/use_after_free.rs:16:10
--> src/fail_tests/use_after_free.rs:16:10
|
15 | let data_ref = instance.with_data_ref(|dref| *dref);
| -------- borrow of `instance` occurs here
| ------------------------------------ borrow of `instance` occurs here
16 | drop(instance);
| ^^^^^^^^ move out of `instance` occurs here
17 | println!("{:?}", data_ref);
Expand Down
4 changes: 2 additions & 2 deletions examples/src/fail_tests/use_moved_ref_after_free.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0505]: cannot move out of `instance` because it is borrowed
--> $DIR/use_moved_ref_after_free.rs:17:10
--> src/fail_tests/use_moved_ref_after_free.rs:17:10
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| -------- borrow of `instance` occurs here
| ------------------------------------------------------- borrow of `instance` occurs here
17 | drop(instance);
| ^^^^^^^^ move out of `instance` occurs here
18 | println!("{:?}", stored_ref);
Expand Down
7 changes: 4 additions & 3 deletions examples/src/ok_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn box_and_ref() {

// Miri crashes with Pin<Box<Future>> types due to
// https://github.com/rust-lang/miri/issues/1038
#[cfg(not(feature = "miri"))]
#[cfg(all(not(feature = "miri"), feature = "tokio"))]
#[tokio::test]
async fn async_new() {
let bar = BoxAndRefAsyncBuilder {
Expand All @@ -106,7 +106,7 @@ async fn async_new() {

// Miri crashes with Pin<Box<Future>> types due to
// https://github.com/rust-lang/miri/issues/1038
#[cfg(not(feature = "miri"))]
#[cfg(all(not(feature = "miri"), feature = "tokio"))]
#[tokio::test]
async fn async_try_new() {
let bar = BoxAndRefAsyncTryBuilder {
Expand All @@ -122,7 +122,7 @@ async fn async_try_new() {

// Miri crashes with Pin<Box<Future>> types due to
// https://github.com/rust-lang/miri/issues/1038
#[cfg(not(feature = "miri"))]
#[cfg(all(not(feature = "miri"), feature = "tokio"))]
#[tokio::test]
async fn async_try_new_err() {
let result = BoxAndRefAsyncTryBuilder {
Expand Down Expand Up @@ -259,6 +259,7 @@ fn double_lifetime() {
}

#[cfg(not(feature = "miri"))]
#[rustversion::stable(1.62)]
mod compile_tests {
/// Tests that all files in fail_tests fail to compile.
#[test]
Expand Down

0 comments on commit 027f840

Please sign in to comment.