Skip to content

Commit 5414c1b

Browse files
committed
macros: Bump versions of remaining dependencies. NFC intended.
1 parent d38a664 commit 5414c1b

File tree

2 files changed

+53
-48
lines changed

2 files changed

+53
-48
lines changed

macros/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ edition = "2018"
1414
proc-macro = true
1515

1616
[dependencies]
17-
quote = "0.6.10"
18-
proc-macro2 = "0.4.23"
17+
quote = "1.0.14"
18+
proc-macro2 = "1.0.36"
1919
rand_xoshiro = "0.6.0"
2020

2121
[dependencies.rand]
@@ -24,7 +24,7 @@ version = "0.8.4"
2424

2525
[dependencies.syn]
2626
features = ["extra-traits", "full"]
27-
version = "0.15.20"
27+
version = "1.0.85"
2828

2929
[features]
3030
device = []

macros/src/lib.rs

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use quote::quote;
1717
use rand::Rng;
1818
use rand_xoshiro::rand_core::SeedableRng;
1919
use syn::{
20-
parse, parse_macro_input, punctuated::Punctuated, spanned::Spanned, ArgCaptured, FnArg, Ident,
20+
parse, parse_macro_input, punctuated::Punctuated, spanned::Spanned, FnArg, Ident,
2121
Item, ItemFn, ItemStatic, Pat, PatIdent, PathArguments, PathSegment, ReturnType, Stmt, Token,
2222
Type, TypePath, Visibility,
2323
};
@@ -84,22 +84,22 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
8484
let f = parse_macro_input!(input as ItemFn);
8585

8686
// check the function signature
87-
let valid_signature = f.constness.is_none()
87+
let valid_signature = f.sig.constness.is_none()
8888
&& f.vis == Visibility::Inherited
89-
&& f.abi.is_none()
90-
&& f.decl.generics.params.is_empty()
91-
&& f.decl.generics.where_clause.is_none()
92-
&& f.decl.variadic.is_none()
93-
&& match f.decl.output {
89+
&& f.sig.abi.is_none()
90+
&& f.sig.generics.params.is_empty()
91+
&& f.sig.generics.where_clause.is_none()
92+
&& f.sig.variadic.is_none()
93+
&& match f.sig.output {
9494
ReturnType::Default => false,
9595
ReturnType::Type(_, ref ty) => matches!(**ty, Type::Never(_)),
9696
};
97-
let cs_decl = extract_critical_section_arg(&f.decl.inputs);
97+
let cs_decl = extract_critical_section_arg(&f.sig.inputs);
9898

9999
if let (true, Ok((cs_param, cs_arg))) = (valid_signature, cs_decl) {
100100
// XXX should we blacklist other attributes?
101101
let attrs = f.attrs;
102-
let unsafety = f.unsafety;
102+
let unsafety = f.sig.unsafety;
103103
let hash = random_ident();
104104
let (statics, stmts) = match extract_static_muts(f.block.stmts) {
105105
Err(e) => return e.to_compile_error().into(),
@@ -228,7 +228,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
228228
}
229229

230230
let fspan = f.span();
231-
let ident = f.ident;
231+
let ident = f.sig.ident;
232232
let ident_s = ident.to_string();
233233

234234
let check = if ident == "DefaultHandler" {
@@ -248,23 +248,23 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
248248
let attrs = f.attrs;
249249
let block = f.block;
250250
let stmts = block.stmts;
251-
let unsafety = f.unsafety;
251+
let unsafety = f.sig.unsafety;
252252

253-
let valid_signature = f.constness.is_none()
253+
let valid_signature = f.sig.constness.is_none()
254254
&& f.vis == Visibility::Inherited
255-
&& f.abi.is_none()
256-
&& f.decl.generics.params.is_empty()
257-
&& f.decl.generics.where_clause.is_none()
258-
&& f.decl.variadic.is_none()
259-
&& match f.decl.output {
255+
&& f.sig.abi.is_none()
256+
&& f.sig.generics.params.is_empty()
257+
&& f.sig.generics.where_clause.is_none()
258+
&& f.sig.variadic.is_none()
259+
&& match f.sig.output {
260260
ReturnType::Default => true,
261261
ReturnType::Type(_, ref ty) => match **ty {
262262
Type::Tuple(ref tuple) => tuple.elems.is_empty(),
263263
Type::Never(..) => true,
264264
_ => false,
265265
},
266266
};
267-
let cs_decl = extract_critical_section_arg(&f.decl.inputs);
267+
let cs_decl = extract_critical_section_arg(&f.sig.inputs);
268268

269269
if let (true, Ok((cs_param, cs_arg))) = (valid_signature, cs_decl) {
270270
let (statics, stmts) = match extract_static_muts(stmts) {
@@ -292,7 +292,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
292292
})
293293
.collect::<Vec<_>>();
294294

295-
let output = f.decl.output;
295+
let output = f.sig.output;
296296
let hash = random_ident();
297297
quote!(
298298
#[export_name = #ident_s]
@@ -343,15 +343,15 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
343343
let f = parse_macro_input!(input as ItemFn);
344344

345345
// check the function signature
346-
let valid_signature = f.constness.is_none()
346+
let valid_signature = f.sig.constness.is_none()
347347
&& f.vis == Visibility::Inherited
348-
&& f.unsafety.is_some()
349-
&& f.abi.is_none()
350-
&& f.decl.inputs.is_empty()
351-
&& f.decl.generics.params.is_empty()
352-
&& f.decl.generics.where_clause.is_none()
353-
&& f.decl.variadic.is_none()
354-
&& match f.decl.output {
348+
&& f.sig.unsafety.is_some()
349+
&& f.sig.abi.is_none()
350+
&& f.sig.inputs.is_empty()
351+
&& f.sig.generics.params.is_empty()
352+
&& f.sig.generics.where_clause.is_none()
353+
&& f.sig.variadic.is_none()
354+
&& match f.sig.output {
355355
ReturnType::Default => true,
356356
ReturnType::Type(_, ref ty) => match **ty {
357357
Type::Tuple(ref tuple) => tuple.elems.is_empty(),
@@ -376,7 +376,7 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
376376

377377
// XXX should we blacklist other attributes?
378378
let attrs = f.attrs;
379-
let ident = f.ident;
379+
let ident = f.sig.ident;
380380
let block = f.block;
381381

382382
quote!(
@@ -402,31 +402,36 @@ fn extract_critical_section_arg(
402402
if num_args == 0 {
403403
Ok((None, None))
404404
} else if num_args == 1 {
405-
match list.first().unwrap().into_value() {
406-
FnArg::Captured(ArgCaptured {
407-
pat:
405+
if let FnArg::Typed(pat_type) = list.first().unwrap() {
406+
match (&*pat_type.pat, &*pat_type.ty, pat_type.colon_token, &*pat_type.attrs) {
407+
(
408408
Pat::Ident(PatIdent {
409409
ident: name,
410410
by_ref: None,
411411
mutability: None,
412412
subpat: None,
413+
attrs,
413414
}),
414-
ty: Type::Path(TypePath { qself: None, path }),
415-
colon_token: _,
416-
}) if path.segments.len() == 1 => {
417-
let seg = path.segments.first().unwrap();
418-
match seg.into_value() {
419-
PathSegment {
420-
ident: tname,
421-
arguments: PathArguments::None,
422-
} if tname == "CriticalSection" => Ok((
423-
Some(quote! { #name: msp430::interrupt::CriticalSection<'a> }),
424-
Some(quote! { unsafe { msp430::interrupt::CriticalSection::new() } }),
425-
)),
426-
_ => Err(()),
415+
Type::Path(TypePath { qself: None, path }),
416+
_,
417+
[]
418+
) if path.segments.len() == 1 && attrs.len() == 0 => {
419+
let seg = path.segments.first().unwrap();
420+
match seg {
421+
PathSegment {
422+
ident: tname,
423+
arguments: PathArguments::None,
424+
} if tname == "CriticalSection" => Ok((
425+
Some(quote! { #name: msp430::interrupt::CriticalSection<'a> }),
426+
Some(quote! { unsafe { msp430::interrupt::CriticalSection::new() } }),
427+
)),
428+
_ => Err(()),
429+
}
427430
}
431+
_ => Err(()),
428432
}
429-
_ => Err(()),
433+
} else {
434+
Err(())
430435
}
431436
} else {
432437
Err(())

0 commit comments

Comments
 (0)