Skip to content

Commit 1e36d29

Browse files
committed
Clean up some debugging leftovers add docs
1 parent 97eb25d commit 1e36d29

File tree

6 files changed

+29
-43
lines changed

6 files changed

+29
-43
lines changed

turbopack/crates/turbo-tasks-fs/src/watcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
time::Duration,
1010
};
1111

12-
use anyhow::Result;
12+
use anyhow::{Context, Result};
1313
use notify::{
1414
event::{MetadataKind, ModifyKind, RenameMode},
1515
Config, EventKind, PollWatcher, RecommendedWatcher, RecursiveMode, Watcher,

turbopack/crates/turbo-tasks-macros-shared/src/primitive_input.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use proc_macro2::Span;
22
use syn::{
33
parse::{Parse, ParseStream},
4-
punctuated::Punctuated,
54
spanned::Spanned,
65
Meta, Result, Token, Type,
76
};
@@ -20,8 +19,7 @@ impl Parse for PrimitiveInput {
2019
manual_shrink_to_fit: None,
2120
};
2221
if input.parse::<Option<Token![,]>>()?.is_some() {
23-
let punctuated: Punctuated<Meta, Token![,]> =
24-
input.parse_terminated(Meta::parse, Token![,])?;
22+
let punctuated = input.parse_terminated(Meta::parse, Token![,])?;
2523
for meta in punctuated {
2624
match (
2725
meta.path()

turbopack/crates/turbo-tasks-macros/src/func.rs

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -317,32 +317,6 @@ impl TurboFn<'_> {
317317
orig_block: &'a Block,
318318
) -> (Signature, Cow<'a, Block>) {
319319
let mut shadow_self = None;
320-
321-
fn transform_from_task_input(
322-
span: Span,
323-
arg_id: Cow<'_, Ident>,
324-
orig_ty: &Type,
325-
pat: Pat,
326-
) -> Stmt {
327-
Stmt::Local(Local {
328-
attrs: Vec::new(),
329-
let_token: Default::default(),
330-
pat,
331-
init: Some(LocalInit {
332-
eq_token: Default::default(),
333-
// we know the argument implements `FromTaskInput` because
334-
// `expand_task_input_type` returned `Cow::Owned`
335-
expr: parse_quote_spanned! {
336-
span =>
337-
<#orig_ty as turbo_tasks::task::FromTaskInput>::from_task_input(
338-
#arg_id
339-
)
340-
},
341-
diverge: None,
342-
}),
343-
semi_token: Default::default(),
344-
})
345-
}
346320
let (inputs, transform_stmts): (Punctuated<_, _>, Vec<Option<_>>) = self
347321
.orig_signature
348322
.inputs
@@ -368,6 +342,27 @@ impl TurboFn<'_> {
368342
// common-case: skip if no type conversion is needed
369343
return (arg.clone(), None);
370344
};
345+
// Helper to produce the transform statement
346+
let transform_from_task_input = |arg_id: Cow<'_, Ident>, pat: Pat| {
347+
Stmt::Local(Local {
348+
attrs: Vec::new(),
349+
let_token: Default::default(),
350+
pat,
351+
init: Some(LocalInit {
352+
eq_token: Default::default(),
353+
// we know the argument implements `FromTaskInput` because
354+
// `expand_task_input_type` returned `Cow::Owned`
355+
expr: parse_quote_spanned! {
356+
arg.span() =>
357+
<#ty as turbo_tasks::task::FromTaskInput>::from_task_input(
358+
#arg_id
359+
)
360+
},
361+
diverge: None,
362+
}),
363+
semi_token: Default::default(),
364+
})
365+
};
371366
match arg {
372367
FnArg::Receiver(
373368
receiver @ Receiver {
@@ -400,12 +395,8 @@ impl TurboFn<'_> {
400395
subpat: None,
401396
});
402397
let self_ident = Cow::Owned(Ident::new("self", self_token.span()));
403-
let transform_stmt = transform_from_task_input(
404-
receiver.span(),
405-
self_ident,
406-
ty,
407-
shadow_self_pattern,
408-
);
398+
let transform_stmt =
399+
transform_from_task_input(self_ident, shadow_self_pattern);
409400

410401
(arg, Some(transform_stmt))
411402
}
@@ -435,10 +426,8 @@ impl TurboFn<'_> {
435426

436427
// convert an argument of type `FromTaskInput<T>::TaskInput` into `T`.
437428
// essentially, replace any instances of `Vc` with `ResolvedVc`.
438-
let orig_ty = &*pat_type.ty;
439429
let pat = (&*pat_type.pat).clone();
440-
let transform_stmt =
441-
transform_from_task_input(pat_type.span(), arg_id, orig_ty, pat);
430+
let transform_stmt = transform_from_task_input(arg_id, pat);
442431

443432
(arg, Some(transform_stmt))
444433
}
@@ -716,6 +705,7 @@ enum IoMarker {
716705
Network,
717706
}
718707

708+
// Optionally parses `T` from a parethensized attributes, returns `T::default` otherwise.
719709
pub fn parse_with_optional_parens<T: Parse + Default>(attr: &Attribute) -> syn::Result<T> {
720710
match &attr.meta {
721711
Meta::Path(_) => Ok(T::default()),

turbopack/crates/turbo-tasks-macros/src/function_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use crate::func::{
2929
pub fn function(args: TokenStream, input: TokenStream) -> TokenStream {
3030
let mut errors = Vec::new();
3131

32-
// log_syntax!(args);
3332
let ItemFn {
3433
attrs,
3534
vis,

turbopack/crates/turbo-tasks-macros/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(proc_macro_diagnostic)]
33
#![feature(allow_internal_unstable)]
44
#![feature(box_patterns)]
5-
#![feature(log_syntax)]
65

76
mod assert_fields;
87
mod derive;

turbopack/crates/turbo-tasks-macros/src/value_impl_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syn::{
66
parse_macro_input, parse_quote,
77
spanned::Spanned,
88
Attribute, Error, Expr, ExprLit, Generics, ImplItem, ImplItemFn, ItemImpl, Lit, LitStr, Meta,
9-
MetaNameValue, Path, Result, Token, Type,
9+
MetaNameValue, Path, Token, Type,
1010
};
1111
use turbo_tasks_macros_shared::{
1212
get_inherent_impl_function_id_ident, get_inherent_impl_function_ident, get_path_ident,
@@ -65,7 +65,7 @@ struct ValueImplArguments {
6565
}
6666

6767
impl Parse for ValueImplArguments {
68-
fn parse(input: ParseStream) -> Result<Self> {
68+
fn parse(input: ParseStream) -> syn::Result<Self> {
6969
let mut result = ValueImplArguments { ident: None };
7070
let punctuated = input.parse_terminated(Meta::parse, Token![,])?;
7171
for meta in punctuated {

0 commit comments

Comments
 (0)