You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/encore/tsparser/litparser-derive/src
    
    the code of the file until where you have to start completion: extern crate proc_macro;

use quote::{format_ident, quote, quote_spanned};
use syn::spanned::Spanned;
use syn::{parse_macro_input, parse_quote, Data, DeriveInput, Fields, GenericParam, Generics};

#[proc_macro_derive(LitParser)]
pub fn derive_lit_parser(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    // Parse the input tokens into a syntax tree
    let input = parse_macro_input!(input as DeriveInput);

    let name = input.ident;

    // Add a bound `T: LitParser` to every type parameter T.
    let generics = add_trait_bounds(input.generics);
    let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

    let input_ident = format_ident!("input");
    let impl_stream = generate_impl(&input.data, &input_ident);

    // Build the output, possibly using quasi-quotation
    let expanded = quote! {
        /
    
fn gen_return(data: &Data) -> proc_macro2::TokenStream {
    match *data {
        Data::Struct(ref data) => match data.fields {
            Fields::Named(ref fields) => {
                let field_names = fields.named.iter().map(|f| {
                    let name = &f.ident;

                    if is_optional(&f.ty) {
                        quote_spanned! {f.span() =>
                            #name: #name.flatten()
                        }
                    } else {
                        quote_spanned! {f.span() =>
                            #name: #name.ok_or_else(|| anyhow::anyhow!(concat!(stringify!(#name), " not set")))?
                        }
                    }
                });
                quote! {
                    Ok(Self {
                        #(#field_names),*
                    })
                }
            }
            Fields::Unnamed(_) => {
                todo!()
            }
            Fields::Unit => {
                todo!()
            }
        },
        Data::Enum(_) | Data::Union(_) => unimplemented!(),
    }
}