Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(turbo-tasks-macros): Strip (already hidden) doc attributes f…
…rom inline function signatures (#73931) A minor optimization to the generated code. We were duplicating doc comments on the hidden `_turbo_tasks_function_inline` versions of functions. We only need the docs on the public function. This change should mean *slightly* less code for the macro to emit, and *slightly* less code for rustc to parse. ## Before ``` // =========================================== // Recursive expansion of the value_impl macro // =========================================== impl Completion { #[doc = " This will always be the same and never invalidates the reading task."] pub fn immutable() -> Vc<Self> { let inputs = std::boxed::Box::new(()); let persistence = turbo_tasks::macro_helpers::get_non_local_persistence_from_inputs(&*inputs); <Vc<Self> as turbo_tasks::task::TaskOutput>::try_from_raw_vc(turbo_tasks::dynamic_call( *COMPLETION_IMPL_IMMUTABLE_FUNCTION_ID, inputs as std::boxed::Box<dyn turbo_tasks::MagicAny>, persistence, )) } } #[doc(hidden)] impl Completion { #[doc = " This will always be the same and never invalidates the reading task."] #[doc(hidden)] #[deprecated( note = "This function is only exposed for use in macros. Do not call it directly." )] pub(self) fn immutable_turbo_tasks_function_inline() -> Vc<Self> { Completion::cell(Completion) } } #[doc(hidden)] pub(crate) static COMPLETION_IMPL_IMMUTABLE_FUNCTION: turbo_tasks::macro_helpers::Lazy< turbo_tasks::NativeFunction, > = turbo_tasks::macro_helpers::Lazy::new(|| { #[allow(deprecated)] turbo_tasks::NativeFunction::new_function( "Completion::immutable".to_owned(), turbo_tasks::FunctionMeta { local_cells: false }, <Completion>::immutable_turbo_tasks_function_inline, ) }); #[doc(hidden)] pub(crate) static COMPLETION_IMPL_IMMUTABLE_FUNCTION_ID: turbo_tasks::macro_helpers::Lazy< turbo_tasks::FunctionId, > = turbo_tasks::macro_helpers::Lazy::new(|| { turbo_tasks::registry::get_function_id(&*COMPLETION_IMPL_IMMUTABLE_FUNCTION) }); ``` ## After ``` // =========================================== // Recursive expansion of the value_impl macro // =========================================== impl Completion { #[doc = " This will always be the same and never invalidates the reading task."] pub fn immutable() -> Vc<Self> { let inputs = std::boxed::Box::new(()); let persistence = turbo_tasks::macro_helpers::get_non_local_persistence_from_inputs(&*inputs); <Vc<Self> as turbo_tasks::task::TaskOutput>::try_from_raw_vc(turbo_tasks::dynamic_call( *COMPLETION_IMPL_IMMUTABLE_FUNCTION_ID, inputs as std::boxed::Box<dyn turbo_tasks::MagicAny>, persistence, )) } } #[doc(hidden)] impl Completion { #[doc(hidden)] #[deprecated( note = "This function is only exposed for use in macros. Do not call it directly." )] pub(self) fn immutable_turbo_tasks_function_inline() -> Vc<Self> { Completion::cell(Completion) } } #[doc(hidden)] pub(crate) static COMPLETION_IMPL_IMMUTABLE_FUNCTION: turbo_tasks::macro_helpers::Lazy< turbo_tasks::NativeFunction, > = turbo_tasks::macro_helpers::Lazy::new(|| { #[allow(deprecated)] turbo_tasks::NativeFunction::new_function( "Completion::immutable".to_owned(), turbo_tasks::FunctionMeta { local_cells: false }, <Completion>::immutable_turbo_tasks_function_inline, ) }); #[doc(hidden)] pub(crate) static COMPLETION_IMPL_IMMUTABLE_FUNCTION_ID: turbo_tasks::macro_helpers::Lazy< turbo_tasks::FunctionId, > = turbo_tasks::macro_helpers::Lazy::new(|| { turbo_tasks::registry::get_function_id(&*COMPLETION_IMPL_IMMUTABLE_FUNCTION) }); ```
- Loading branch information