From 98941f953e368bc626bf1b6c2c7738070288c341 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 18:42:19 +0100 Subject: [PATCH] config macros: Make per-field skl variable an Option So far, we never set it to None. But this will allow us to abolish the default, after we have srranged to always set it to Some. Signed-off-by: Ian Jackson --- macros/macros.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/macros/macros.rs b/macros/macros.rs index 9d64c24..1233b41 100644 --- a/macros/macros.rs +++ b/macros/macros.rs @@ -62,16 +62,16 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { //dbg!(field); let fname = &field.ident.as_ref().unwrap(); let fname_span = fname.span(); - let mut skl = quote_spanned!{fname_span=> SectionKindList::PerClient }; + let mut skl = Some(quote_spanned!{fname_span=> SectionKindList::PerClient }); let mut method = quote_spanned!{fname_span=> ordinary }; for attr in &field.attrs { let atspan = attr.path.segments.last().unwrap().ident.span(); if attr.tokens.is_empty() { method = attr.path.to_token_stream(); if &attr.path == &parse_quote!{ limited } { - skl = quote_spanned!{atspan=> SectionKindList::Limited }; + skl = Some(quote_spanned!{atspan=> SectionKindList::Limited }); } else if &attr.path == &parse_quote!{ computed } { - skl = quote_spanned!{atspan=> SectionKindList::None }; + skl = Some(quote_spanned!{atspan=> SectionKindList::None }); } } else if &attr.path == &parse_quote!{ special } { let meta = match attr.parse_meta().unwrap() { @@ -86,11 +86,12 @@ pub fn resolve(input: proc_macro::TokenStream) -> proc_macro::TokenStream { } } method = get_path(tmethod); - skl = get_path(tskl); + skl = Some(get_path(tskl)); } } let fname_string = fname.to_string(); let fname_lit = Literal::string( &fname_string ); + let skl = skl.expect(&format!("SKL not specified! (field {:?})!", fname)); names.push(quote!{ (#fname_lit, #skl), -- 2.30.2