Skip to content

Commit 38c4caf

Browse files
authored
[turbopack] Don't execute inventory_submit in rust analyzer (#83447)
### What? In #83074 we changed how turbo task objects were registered to use the `inventory` crate. This PR adds a new `inventory_submit!` macro that wraps the existing `inventory::submit` function with a `#[cfg(not(rust_analyzer))]` attribute to prevent Rust Analyzer choking on the generated code. See example error ![image.png](https://app.graphite.dev/user-attachments/assets/2fe87f23-8717-4615-a86d-94c1b19ae099.png) Because the inventory code does not affect any API surfaces this is safe and if anything should improve rust-analyzer performance
1 parent a270b00 commit 38c4caf

24 files changed

+59
-25
lines changed

turbopack/crates/turbo-tasks-backend/fuzz/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ path = "afl_targets/graph.rs"
3232
test = false
3333
doc = false
3434
bench = false
35+
36+
37+
[lints]
38+
workspace = true

turbopack/crates/turbo-tasks-macros-tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ turbo-tasks = { workspace = true }
1414
turbo-tasks-testing = { workspace = true }
1515
turbo-tasks-backend = { workspace = true }
1616

17+
[lints]
18+
workspace = true

turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_attribute_invalid_args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(arbitrary_self_types)]
22
#![feature(arbitrary_self_types_pointers)]
3+
#![allow(unexpected_cfgs)]
34

45
use turbo_tasks::{ResolvedVc, Vc};
56

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unexpected token, expected one of: "fs", "network", "operation", "local"
2-
--> tests/function/fail_attribute_invalid_args.rs:9:25
3-
|
4-
9 | #[turbo_tasks::function(invalid_argument)]
5-
| ^^^^^^^^^^^^^^^^
2+
--> tests/function/fail_attribute_invalid_args.rs:10:25
3+
|
4+
10 | #[turbo_tasks::function(invalid_argument)]
5+
| ^^^^^^^^^^^^^^^^

turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_attribute_invalid_args_inherent_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(arbitrary_self_types)]
22
#![feature(arbitrary_self_types_pointers)]
3+
#![allow(unexpected_cfgs)]
34

45
use turbo_tasks::{ResolvedVc, Vc};
56

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unexpected token, expected one of: "fs", "network", "operation", "local"
2-
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:14:29
2+
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:15:29
33
|
4-
14 | #[turbo_tasks::function(invalid_argument)]
4+
15 | #[turbo_tasks::function(invalid_argument)]
55
| ^^^^^^^^^^^^^^^^

turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_ref.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(dead_code)]
22
#![feature(arbitrary_self_types)]
33
#![feature(arbitrary_self_types_pointers)]
4+
#![allow(unexpected_cfgs)]
45

56
use turbo_tasks::Vc;
67

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: methods taking `self` are not supported with `operation`
2-
--> tests/function/fail_operation_method_self_ref.rs:13:17
2+
--> tests/function/fail_operation_method_self_ref.rs:14:17
33
|
4-
13 | fn self_ref(&self) -> Vc<()> {
4+
14 | fn self_ref(&self) -> Vc<()> {
55
| ^^^^^

turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(dead_code)]
22
#![feature(arbitrary_self_types)]
33
#![feature(arbitrary_self_types_pointers)]
4+
#![allow(unexpected_cfgs)]
45

56
use turbo_tasks::{OperationVc, Vc};
67

turbopack/crates/turbo-tasks-macros-tests/tests/function/fail_operation_method_self_type.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
error: methods taking `self` are not supported with `operation`
2-
--> tests/function/fail_operation_method_self_type.rs:13:28
2+
--> tests/function/fail_operation_method_self_type.rs:14:28
33
|
4-
13 | fn arbitrary_self_type(self: OperationVc<Self>) -> Vc<()> {
4+
14 | fn arbitrary_self_type(self: OperationVc<Self>) -> Vc<()> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0307]: invalid `self` parameter type: `OperationVc<Foobar>`
8-
--> tests/function/fail_operation_method_self_type.rs:13:34
8+
--> tests/function/fail_operation_method_self_type.rs:14:34
99
|
10-
13 | fn arbitrary_self_type(self: OperationVc<Self>) -> Vc<()> {
10+
14 | fn arbitrary_self_type(self: OperationVc<Self>) -> Vc<()> {
1111
| ^^^^^^^^^^^^^^^^^
1212
|
1313
= note: type of `self` must be `Self` or some type implementing `Receiver`
1414
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
1515

1616
error[E0277]: the trait bound `fn(OperationVc<Foobar>) -> Vc<()> {Foobar::arbitrary_self_type_turbo_tasks_function_inline}: turbo_tasks::task::function::IntoTaskFnWithThis<_, _, _>` is not satisfied
17-
--> tests/function/fail_operation_method_self_type.rs:10:1
17+
--> tests/function/fail_operation_method_self_type.rs:11:1
1818
|
19-
10 | #[turbo_tasks::value_impl]
19+
11 | #[turbo_tasks::value_impl]
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
2121
|
2222
= help: the trait `turbo_tasks::task::function::TaskFnInputFunctionWithThis<_, _, _>` is not implemented for fn item `fn(OperationVc<Foobar>) -> Vc<()> {Foobar::arbitrary_self_type_turbo_tasks_function_inline}`

0 commit comments

Comments
 (0)