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