Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
someguynamedjosh committed Aug 8, 2022
1 parent d5fc224 commit c3164f1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
17 changes: 12 additions & 5 deletions examples/src/fail_tests/auto_covariant.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
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.

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

error[E0601]: `main` function not found in crate `$CRATE`
--> $DIR/auto_covariant.rs:12:2
--> $DIR/auto_covariant.rs:1:1
|
12 | }
| ^ consider adding a `main` function to `$DIR/src/fail_tests/auto_covariant.rs`
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`
2 changes: 1 addition & 1 deletion examples/src/fail_tests/borrowchk_custom_drop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion examples/src/fail_tests/borrowchk_external_lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 the attribute macro `self_referencing` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion examples/src/fail_tests/move_ref_outside_closure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
| ^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here...
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
|
16 | instance.with_data_ref(|dref| stored_ref = Some(*dref));
Expand Down
4 changes: 1 addition & 3 deletions examples/src/fail_tests/refuse_non_std_box.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ error[E0599]: no function or associated item named `is_std_box_type` found for s
19 | #[self_referencing]
| ^^^^^^^^^^^^^^^^^^^ function or associated item not found in `CheckIfTypeIsStd<Box<String>>`
|
= 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)
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion examples/src/fail_tests/use_after_free.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0505]: cannot move out of `instance` because it is borrowed
--> $DIR/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
2 changes: 1 addition & 1 deletion examples/src/fail_tests/use_moved_ref_after_free.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0505]: cannot move out of `instance` because it is borrowed
--> $DIR/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

0 comments on commit c3164f1

Please sign in to comment.