-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ResolvedVc arguments to operations
- Loading branch information
Showing
14 changed files
with
185 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../turbo-tasks-testing/tests/operation_vc.rs |
48 changes: 0 additions & 48 deletions
48
turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method.stderr
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_ref.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,18 @@ | ||
#![allow(dead_code)] | ||
#![feature(arbitrary_self_types)] | ||
#![feature(arbitrary_self_types_pointers)] | ||
|
||
use turbo_tasks::Vc; | ||
|
||
#[turbo_tasks::value] | ||
struct Foobar; | ||
|
||
#[turbo_tasks::value_impl] | ||
impl Foobar { | ||
#[turbo_tasks::function(operation)] | ||
fn self_ref(&self) -> Vc<()> { | ||
Vc::cell(()) | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
...pack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_ref.stderr
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
37 changes: 37 additions & 0 deletions
37
...ack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_type.stderr
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
...crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_type_base_vc.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,18 @@ | ||
#![allow(dead_code)] | ||
#![feature(arbitrary_self_types)] | ||
#![feature(arbitrary_self_types_pointers)] | ||
|
||
use turbo_tasks::Vc; | ||
|
||
#[turbo_tasks::value] | ||
struct Foobar; | ||
|
||
#[turbo_tasks::value_impl] | ||
impl Foobar { | ||
#[turbo_tasks::function(operation)] | ||
fn arbitrary_self_type_base_vc(self: Vc<Self>) -> Vc<()> { | ||
Vc::cell(()) | ||
} | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
...es/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_type_base_vc.stderr
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
34 changes: 6 additions & 28 deletions
34
turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_vc_arg.stderr
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
turbopack/crates/turbo-tasks-macros-tests/tests/function/pass_operation_accepts_resolved.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,21 @@ | ||
use anyhow::Result; | ||
use turbo_tasks::{OperationVc, ResolvedVc, Vc}; | ||
|
||
#[turbo_tasks::function(operation)] | ||
fn bare_op_fn() -> Vc<i32> { | ||
Vc::cell(21) | ||
} | ||
|
||
// operations can take `ResolvedVc`s too (anything that's a `NonLocalValue`). | ||
#[turbo_tasks::function(operation)] | ||
async fn multiply(value: OperationVc<i32>, coefficient: ResolvedVc<i32>) -> Result<Vc<i32>> { | ||
Ok(Vc::cell((*value.connect().await?) * (*coefficient.await?))) | ||
} | ||
|
||
#[allow(dead_code)] | ||
fn use_operations() { | ||
let twenty_one: OperationVc<i32> = bare_op_fn(); | ||
let _fourty_two: OperationVc<i32> = multiply(twenty_one, ResolvedVc::cell(2)); | ||
} | ||
|
||
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
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 @@ | ||
../../turbo-tasks-testing/tests/operation_vc.rs |
36 changes: 36 additions & 0 deletions
36
turbopack/crates/turbo-tasks-testing/tests/operation_vc.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,36 @@ | ||
#![feature(arbitrary_self_types)] | ||
#![feature(arbitrary_self_types_pointers)] | ||
#![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this | ||
|
||
use anyhow::Result; | ||
use turbo_tasks::{OperationVc, ResolvedVc, Vc}; | ||
use turbo_tasks_testing::{register, run, Registration}; | ||
|
||
static REGISTRATION: Registration = register!(); | ||
|
||
#[turbo_tasks::function(operation)] | ||
fn bare_op_fn() -> Vc<i32> { | ||
Vc::cell(21) | ||
} | ||
|
||
// operations can take `ResolvedVc`s too (anything that's a `NonLocalValue`). | ||
#[turbo_tasks::function(operation)] | ||
async fn multiply(value: OperationVc<i32>, coefficient: ResolvedVc<i32>) -> Result<Vc<i32>> { | ||
Ok(Vc::cell((*value.connect().await?) * (*coefficient.await?))) | ||
} | ||
|
||
#[turbo_tasks::function] | ||
fn use_operations() -> Vc<i32> { | ||
let twenty_one: OperationVc<i32> = bare_op_fn(); | ||
let fourty_two: OperationVc<i32> = multiply(twenty_one, ResolvedVc::cell(2)); | ||
fourty_two.connect() | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_use_operations() -> Result<()> { | ||
run(®ISTRATION, || async { | ||
assert_eq!(*use_operations().await?, 42); | ||
Ok(()) | ||
}) | ||
.await | ||
} |
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