Skip to content

Commit

Permalink
Move assert_returns_resolved_value into helper module
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bgw committed Aug 15, 2024
1 parent bb0ed86 commit 12355ee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions turbopack/crates/turbo-tasks-macros/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,7 @@ impl TurboFn {
quote_spanned! {
span =>
{
fn assert_returns_resolved_value<
ReturnType,
Rv,
>() where
ReturnType: turbo_tasks::task::TaskOutput<Return = Vc<Rv>>,
Rv: turbo_tasks::ResolvedValue + Send,
{}
assert_returns_resolved_value::<#return_type, _>()
turbo_tasks::macro_helpers::assert_returns_resolved_value::<#return_type, _>()
}
}
} else {
Expand Down
11 changes: 10 additions & 1 deletion turbopack/crates/turbo-tasks/src/macro_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ pub use super::{
magic_any::MagicAny,
manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing},
};
use crate::{debug::ValueDebugFormatString, TaskInput, TaskPersistence};
use crate::{
debug::ValueDebugFormatString, task::TaskOutput, ResolvedValue, TaskInput, TaskPersistence, Vc,
};

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

pub fn assert_returns_resolved_value<ReturnType, Rv>()
where
ReturnType: TaskOutput<Return = Vc<Rv>>,
Rv: ResolvedValue + Send,
{
}

#[macro_export]
macro_rules! stringify_path {
($path:path) => {
Expand Down

0 comments on commit 12355ee

Please sign in to comment.