Skip to content

Commit dfe5373

Browse files
committed
add a try build test for our newly required annotations
1 parent bc6a38a commit dfe5373

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#![feature(arbitrary_self_types)]
2+
#![feature(arbitrary_self_types_pointers)]
3+
4+
use turbo_tasks::Vc;
5+
6+
#[turbo_tasks::value_trait]
7+
trait MyTrait {
8+
fn item(&self) -> bool;
9+
10+
#[turbo_tasks::function]
11+
fn item2(&self) -> Vc<bool>;
12+
13+
#[turbo_tasks::function(operation)]
14+
fn item3(&self) -> Vc<bool>;
15+
}
16+
17+
#[turbo_tasks::value]
18+
struct MyStruct;
19+
20+
#[turbo_tasks::value_impl]
21+
impl MyTrait for MyStruct {
22+
#[turbo_tasks::function]
23+
fn item(&self) -> bool {
24+
true
25+
}
26+
27+
#[turbo_tasks::function]
28+
fn item2(&self) -> Vc<bool> {
29+
Vc::cell(true)
30+
}
31+
32+
#[turbo_tasks::function]
33+
fn item3(&self) -> Vc<bool> {
34+
Vc::cell(true)
35+
}
36+
}
37+
38+
fn expects_my_trait(_x: impl MyTrait) {}
39+
40+
fn main() {
41+
expects_my_trait(MyStruct {});
42+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
error: Expected return type to be `turbo_tasks::Vc<T>` or `anyhow::Result<Vc<T>>`. Unable to process type.
2+
--> tests/value_trait/fail_missing_function_annotation.rs:8:23
3+
|
4+
8 | fn item(&self) -> bool;
5+
| ^^^^
6+
7+
error: trait items cannot be operations
8+
--> tests/value_trait/fail_missing_function_annotation.rs:13:29
9+
|
10+
13 | #[turbo_tasks::function(operation)]
11+
| ^^^^^^^^^
12+
13+
error: #[turbo_tasks::function] attribute missing
14+
--> tests/value_trait/fail_missing_function_annotation.rs:8:5
15+
|
16+
8 | fn item(&self) -> bool;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: Expected return type to be `turbo_tasks::Vc<T>` or `anyhow::Result<Vc<T>>`. Unable to process type.
20+
--> tests/value_trait/fail_missing_function_annotation.rs:23:23
21+
|
22+
23 | fn item(&self) -> bool {
23+
| ^^^^
24+
25+
error[E0277]: the trait bound `bool: turbo_tasks::task::TaskOutput` is not satisfied
26+
--> tests/value_trait/fail_missing_function_annotation.rs:8:23
27+
|
28+
8 | fn item(&self) -> bool;
29+
| ^^^^ the trait `turbo_tasks::task::TaskOutput` is not implemented for `bool`
30+
|
31+
= help: the following other types implement trait `turbo_tasks::task::TaskOutput`:
32+
()
33+
Result<T, turbo_tasks::Error>
34+
Vc<T>
35+
36+
error[E0277]: the trait bound `bool: turbo_tasks::task::TaskOutput` is not satisfied
37+
--> tests/value_trait/fail_missing_function_annotation.rs:6:1
38+
|
39+
6 | #[turbo_tasks::value_trait]
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `turbo_tasks::task::TaskOutput` is not implemented for `bool`
41+
|
42+
= help: the following other types implement trait `turbo_tasks::task::TaskOutput`:
43+
()
44+
Result<T, turbo_tasks::Error>
45+
Vc<T>
46+
= note: this error originates in the attribute macro `turbo_tasks::value_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
47+
48+
error[E0277]: the trait bound `bool: turbo_tasks::task::TaskOutput` is not satisfied
49+
--> tests/value_trait/fail_missing_function_annotation.rs:23:23
50+
|
51+
23 | fn item(&self) -> bool {
52+
| ^^^^ the trait `turbo_tasks::task::TaskOutput` is not implemented for `bool`
53+
|
54+
= help: the following other types implement trait `turbo_tasks::task::TaskOutput`:
55+
()
56+
Result<T, turbo_tasks::Error>
57+
Vc<T>
58+
59+
error[E0277]: the trait bound `bool: turbo_tasks::task::TaskOutput` is not satisfied
60+
--> tests/value_trait/fail_missing_function_annotation.rs:20:1
61+
|
62+
20 | #[turbo_tasks::value_impl]
63+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `turbo_tasks::task::TaskOutput` is not implemented for `bool`
64+
|
65+
= help: the following other types implement trait `turbo_tasks::task::TaskOutput`:
66+
()
67+
Result<T, turbo_tasks::Error>
68+
Vc<T>
69+
= note: this error originates in the attribute macro `turbo_tasks::value_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
70+
71+
error[E0277]: the trait bound `fn() -> bool {<MyStruct as MyStruct_MyTrait_item_inline>::item_turbo_tasks_function_inline}: IntoTaskFn<_, _>` is not satisfied
72+
--> tests/value_trait/fail_missing_function_annotation.rs:20:1
73+
|
74+
20 | #[turbo_tasks::value_impl]
75+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
76+
|
77+
= help: the trait `turbo_tasks::task::function::TaskFnInputFunction<_, _>` is not implemented for fn item `fn() -> bool {<MyStruct as MyStruct_MyTrait_item_inline>::item_turbo_tasks_function_inline}`
78+
= note: required for `fn() -> bool {<MyStruct as MyStruct_MyTrait_item_inline>::item_turbo_tasks_function_inline}` to implement `IntoTaskFn<_, _>`
79+
note: required by a bound in `NativeFunction::new_method_without_this`
80+
--> $WORKSPACE/turbopack/crates/turbo-tasks/src/native_function.rs
81+
|
82+
| pub fn new_method_without_this<Mode, Inputs, I>(
83+
| ----------------------- required by a bound in this associated function
84+
...
85+
| I: IntoTaskFn<Mode, Inputs>,
86+
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `NativeFunction::new_method_without_this`
87+
= note: this error originates in the attribute macro `turbo_tasks::value_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#![feature(arbitrary_self_types)]
2+
#![feature(arbitrary_self_types_pointers)]
3+
4+
use turbo_tasks::Vc;
5+
6+
#[turbo_tasks::value_trait]
7+
trait MyTrait {
8+
#[turbo_tasks::function]
9+
fn item(&self) -> Vc<bool>;
10+
11+
#[turbo_tasks::function]
12+
fn item2(&self) -> Vc<bool>;
13+
14+
#[turbo_tasks::function]
15+
fn item3(&self) -> Vc<bool>;
16+
}
17+
18+
#[turbo_tasks::value]
19+
struct MyStruct;
20+
21+
#[turbo_tasks::value_impl]
22+
impl MyTrait for MyStruct {
23+
#[turbo_tasks::function]
24+
fn item(&self) -> Vc<bool> {
25+
Vc::cell(true)
26+
}
27+
28+
#[turbo_tasks::function]
29+
fn item2(&self) -> Vc<bool> {
30+
Vc::cell(true)
31+
}
32+
33+
#[turbo_tasks::function]
34+
fn item3(&self) -> Vc<bool> {
35+
Vc::cell(true)
36+
}
37+
}
38+
39+
fn expects_my_trait(_x: impl MyTrait) {}
40+
41+
fn main() {
42+
expects_my_trait(MyStruct {});
43+
}

0 commit comments

Comments
 (0)