Cleanup
This commit is contained in:
parent
0d5a87f64f
commit
0502619259
|
@ -1,5 +1,5 @@
|
||||||
use crate::parser::{ImplBlockDef, FuncDef};
|
use crate::parser::{ImplBlockDef, FuncDef};
|
||||||
use proc_macro2::{Ident, Literal, Span, TokenStream};
|
use proc_macro2::{Ident, Span, TokenStream};
|
||||||
use quote::{quote, quote_spanned, ToTokens};
|
use quote::{quote, quote_spanned, ToTokens};
|
||||||
|
|
||||||
pub fn codegen(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
pub fn codegen(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
||||||
|
@ -9,7 +9,7 @@ pub fn codegen(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
||||||
derive_externals(ext_def, &mut externals);
|
derive_externals(ext_def, &mut externals);
|
||||||
derive_module_resolver(ext_def, &mut module_resolver);
|
derive_module_resolver(ext_def, &mut module_resolver);
|
||||||
|
|
||||||
let (impl_generics, ty_generics, where_clause) = ext_def.generics.split_for_impl();
|
let (impl_generics, _, where_clause) = ext_def.generics.split_for_impl();
|
||||||
let ty = &ext_def.ty;
|
let ty = &ext_def.ty;
|
||||||
|
|
||||||
(quote! {
|
(quote! {
|
||||||
|
@ -49,7 +49,7 @@ fn emit_dispatch_func_arm(func: &FuncDef) -> TokenStream {
|
||||||
let return_ty_span = func.return_ty.clone().unwrap_or_else(|| Span::call_site());
|
let return_ty_span = func.return_ty.clone().unwrap_or_else(|| Span::call_site());
|
||||||
|
|
||||||
let mut unmarshall_args = TokenStream::new();
|
let mut unmarshall_args = TokenStream::new();
|
||||||
for (i, param) in func.params.iter().enumerate() {
|
for param in &func.params {
|
||||||
let param_span = param.ident.span();
|
let param_span = param.ident.span();
|
||||||
let ident = ¶m.ident;
|
let ident = ¶m.ident;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ fn emit_dispatch_func_arm(func: &FuncDef) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_externals(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
fn derive_externals(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
||||||
let (impl_generics, ty_generics, where_clause) = ext_def.generics.split_for_impl();
|
let (impl_generics, _, where_clause) = ext_def.generics.split_for_impl();
|
||||||
let ty = &ext_def.ty;
|
let ty = &ext_def.ty;
|
||||||
|
|
||||||
let mut match_arms = vec![];
|
let mut match_arms = vec![];
|
||||||
|
@ -182,7 +182,7 @@ fn emit_resolve_func_arm(func: &FuncDef) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_module_resolver(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
fn derive_module_resolver(ext_def: &ImplBlockDef, to: &mut TokenStream) {
|
||||||
let (impl_generics, ty_generics, where_clause) = ext_def.generics.split_for_impl();
|
let (impl_generics, _, where_clause) = ext_def.generics.split_for_impl();
|
||||||
let ty = &ext_def.ty;
|
let ty = &ext_def.ty;
|
||||||
|
|
||||||
let mut match_arms = vec![];
|
let mut match_arms = vec![];
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod parser;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn derive_externals(attr: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn derive_externals(_attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let mut input: proc_macro2::TokenStream = input.into();
|
let mut input: proc_macro2::TokenStream = input.into();
|
||||||
|
|
||||||
let ext_def = parser::parse(input.clone()).unwrap();
|
let ext_def = parser::parse(input.clone()).unwrap();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use syn::{spanned::Spanned, FnArg, Ident, ImplItem, ImplItemMethod, ItemImpl, ReturnType};
|
use syn::{spanned::Spanned, Ident, ImplItem, ImplItemMethod, ReturnType};
|
||||||
|
|
||||||
/// A parameter.
|
/// A parameter.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
Loading…
Reference in New Issue