Skip to content

Commit aeceef3

Browse files
committed
Move assert_returns_resolved_value into helper module
This avoids re-creating the function for every assertion we make on function return values, potentially slightly speeding up the macro compilation. This shouldn't make much/any difference right now because nothing (outside of a few tests) uses resolved functions yet.
1 parent 5b26882 commit aeceef3

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

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

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbopack/crates/turbo-tasks-macros/src/func.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,7 @@ impl TurboFn {
338338
quote_spanned! {
339339
span =>
340340
{
341-
fn assert_returns_resolved_value<
342-
ReturnType,
343-
Rv,
344-
>() where
345-
ReturnType: turbo_tasks::task::TaskOutput<Return = Vc<Rv>>,
346-
Rv: turbo_tasks::ResolvedValue + Send,
347-
{}
348-
assert_returns_resolved_value::<#return_type, _>()
341+
turbo_tasks::macro_helpers::assert_returns_resolved_value::<#return_type, _>()
349342
}
350343
}
351344
} else {

turbopack/crates/turbo-tasks/src/macro_helpers.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ pub use super::{
88
magic_any::MagicAny,
99
manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing},
1010
};
11-
use crate::{debug::ValueDebugFormatString, TaskInput, TaskPersistence};
11+
use crate::{
12+
debug::ValueDebugFormatString, task::TaskOutput, ResolvedValue, TaskInput, TaskPersistence, Vc,
13+
};
1214

1315
#[inline(never)]
1416
pub async fn value_debug_format_field(value: ValueDebugFormatString<'_>) -> String {
@@ -29,6 +31,13 @@ pub fn get_non_local_persistence_from_inputs(inputs: &impl TaskInput) -> TaskPer
2931
}
3032
}
3133

34+
pub fn assert_returns_resolved_value<ReturnType, Rv>()
35+
where
36+
ReturnType: TaskOutput<Return = Vc<Rv>>,
37+
Rv: ResolvedValue + Send,
38+
{
39+
}
40+
3241
#[macro_export]
3342
macro_rules! stringify_path {
3443
($path:path) => {

0 commit comments

Comments
 (0)