turbo_tasks_macros/
lib.rs

1#![allow(internal_features)]
2#![feature(proc_macro_diagnostic)]
3#![feature(allow_internal_unstable)]
4#![feature(box_patterns)]
5
6mod assert_fields;
7mod derive;
8mod func;
9mod function_macro;
10mod generic_type_macro;
11mod global_name;
12mod primitive_macro;
13mod value_impl_macro;
14mod value_macro;
15mod value_trait_macro;
16
17extern crate proc_macro;
18
19use proc_macro::TokenStream;
20use proc_macro_error::proc_macro_error;
21
22#[proc_macro_derive(TraceRawVcs, attributes(turbo_tasks))]
23pub fn derive_trace_raw_vcs_attr(input: TokenStream) -> TokenStream {
24    derive::derive_trace_raw_vcs(input)
25}
26
27#[proc_macro_derive(NonLocalValue, attributes(turbo_tasks))]
28pub fn derive_non_local_value_attr(input: TokenStream) -> TokenStream {
29    derive::derive_non_local_value(input)
30}
31
32#[proc_macro_derive(OperationValue, attributes(turbo_tasks))]
33pub fn derive_operation_value_attr(input: TokenStream) -> TokenStream {
34    derive::derive_operation_value(input)
35}
36
37#[proc_macro_derive(ValueDebug, attributes(turbo_tasks))]
38pub fn derive_value_debug_attr(input: TokenStream) -> TokenStream {
39    derive::derive_value_debug(input)
40}
41
42#[proc_macro_derive(ValueDebugFormat, attributes(turbo_tasks))]
43pub fn derive_value_debug_format_attr(input: TokenStream) -> TokenStream {
44    derive::derive_value_debug_format(input)
45}
46
47#[proc_macro_derive(DeterministicHash, attributes(turbo_tasks))]
48pub fn derive_deterministic_hash(input: TokenStream) -> TokenStream {
49    derive::derive_deterministic_hash(input)
50}
51
52#[proc_macro_derive(TaskInput, attributes(turbo_tasks))]
53pub fn derive_task_input(input: TokenStream) -> TokenStream {
54    derive::derive_task_input(input)
55}
56
57/// <!--
58/// Documentation for this macro is available on the re-export:
59/// <https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/derive.KeyValuePair.html>
60/// -->
61#[proc_macro_derive(KeyValuePair)]
62pub fn derive_key_value_pair(input: TokenStream) -> TokenStream {
63    derive::derive_key_value_pair(input)
64}
65
66/// <!--
67/// Documentation for this macro is available on the re-export:
68/// <https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/attr.value.html>
69/// -->
70#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
71#[proc_macro_error]
72#[proc_macro_attribute]
73pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
74    value_macro::value(args, input)
75}
76
77/// <!--
78/// Documentation for this macro is available on the re-export:
79/// <https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/attr.value_trait.html>
80/// -->
81#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
82#[proc_macro_error]
83#[proc_macro_attribute]
84pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
85    value_trait_macro::value_trait(args, input)
86}
87
88#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
89#[proc_macro_error]
90#[proc_macro_attribute]
91pub fn function(args: TokenStream, input: TokenStream) -> TokenStream {
92    function_macro::function(args, input)
93}
94
95#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
96#[proc_macro_error]
97#[proc_macro_attribute]
98pub fn test_tt(_args: TokenStream, input: TokenStream) -> TokenStream {
99    derive::derive_value_debug(input)
100}
101
102#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
103#[proc_macro_error]
104#[proc_macro_attribute]
105pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream {
106    value_impl_macro::value_impl(args, input)
107}
108
109#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
110#[proc_macro_error]
111#[proc_macro]
112pub fn primitive(input: TokenStream) -> TokenStream {
113    primitive_macro::primitive(input)
114}
115
116/// Registers a value type that is generic over the `Vc` it contains.
117///
118/// # Example
119///
120/// ```
121/// use crate::generic_type as __turbo_tasks_internal_generic_type;
122///
123/// __turbo_tasks_internal_generic_type!(<A, B>, GenericType<Vc<A>, Vc<B>>);
124///
125/// // Now you can do the following, for any `A` and `B` value types:
126///
127/// let vc: Vc<GenericType<Vc<u32>, Vc<RcStr>>> = Vc::cell(
128///     GenericType::new(
129///         Vc::cell(42),
130///         Vc::cell("hello".to_string())
131///     )
132/// );
133/// ```
134#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
135#[proc_macro_error]
136#[proc_macro]
137pub fn generic_type(input: TokenStream) -> TokenStream {
138    generic_type_macro::generic_type(input)
139}