-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hydroflow_plus): restrict lifetime parameters to be actually inva…
…riant (#1559) Our lifetimes were accidentally made covariant when the lifetime `'a` was removed from the process/cluster tag type. This fixes that typing hole, and also loosens some restrictions on the lifetime of deploy environments.
- Loading branch information
Showing
23 changed files
with
127 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
10 changes: 10 additions & 0 deletions
10
hydroflow_plus/tests/compile-fail/send_bincode_lifetime.rs
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 @@ | ||
use hydroflow_plus::*; | ||
|
||
struct P1 {} | ||
struct P2 {} | ||
|
||
fn test<'a, 'b>(p1: &Process<'a, P1>, p2: &Process<'b, P2>) { | ||
p1.source_iter(q!(0..10)).send_bincode(p2).for_each(q!(|n| println!("{}", n))); | ||
} | ||
|
||
fn main() {} |
31 changes: 31 additions & 0 deletions
31
hydroflow_plus/tests/compile-fail/send_bincode_lifetime.stderr
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,31 @@ | ||
error: lifetime may not live long enough | ||
--> tests/compile-fail/send_bincode_lifetime.rs:7:5 | ||
| | ||
6 | fn test<'a, 'b>(p1: &Process<'a, P1>, p2: &Process<'b, P2>) { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
7 | p1.source_iter(q!(0..10)).send_bincode(p2).for_each(q!(|n| println!("{}", n))); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` | ||
| | ||
= help: consider adding the following bound: `'a: 'b` | ||
= note: requirement occurs because of the type `hydroflow_plus::Process<'_, P1>`, which makes the generic argument `'_` invariant | ||
= note: the struct `hydroflow_plus::Process<'a, P>` is invariant over the parameter `'a` | ||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance | ||
|
||
error: lifetime may not live long enough | ||
--> tests/compile-fail/send_bincode_lifetime.rs:7:5 | ||
| | ||
6 | fn test<'a, 'b>(p1: &Process<'a, P1>, p2: &Process<'b, P2>) { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
7 | p1.source_iter(q!(0..10)).send_bincode(p2).for_each(q!(|n| println!("{}", n))); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` | ||
| | ||
= help: consider adding the following bound: `'b: 'a` | ||
= note: requirement occurs because of the type `hydroflow_plus::Process<'_, P2>`, which makes the generic argument `'_` invariant | ||
= note: the struct `hydroflow_plus::Process<'a, P>` is invariant over the parameter `'a` | ||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance | ||
|
||
help: `'a` and `'b` must be the same: replace one with the other |
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,5 @@ | ||
#[test] | ||
fn test_all() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/compile-fail/*.rs"); | ||
} |
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
Oops, something went wrong.