/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use proc_macro2::TokenStream; use quote::{quote, quote_spanned}; use syn::{visit_mut::VisitMut, Item, Type};
mod attributes; mod callback_interface; mod item; mod scaffolding; mod trait_interface; mod utrait;
// TODO(jplatte): Ensure no generics, … // TODO(jplatte): Aggregate errors instead of short-circuiting, wherever possible
pub(crate) fn expand_export( mut item: Item,
all_args: proc_macro::TokenStream,
udl_mode: bool,
) -> syn::Result<TokenStream> { let mod_path = mod_path()?; // If the input is an `impl` block, rewrite any uses of the `Self` type // alias to the actual type, so we don't have to special-case it in the // metadata collection or scaffolding code generation (which generates // new functions outside of the `impl`).
rewrite_self_type(&mut item);
let metadata = ExportItem::new(item, all_args)?;
match metadata {
ExportItem::Function { sig, args } => {
gen_fn_scaffolding(sig, args.async_runtime.as_ref(), udl_mode)
}
ExportItem::Impl {
items,
self_ident,
args,
} => { iflet Some(rt) = &args.async_runtime { if items
.iter()
.all(|item| !matches!(item, ImplItem::Method(sig) if sig.is_async))
{ return Err(syn::Error::new_spanned(
rt, "no async methods in this impl block",
));
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.