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