remove unused macros
This commit is contained in:
@@ -36,18 +36,6 @@ pub(super) fn commit(_args: TokenStream) -> TokenStream {
|
||||
ret.into()
|
||||
}
|
||||
|
||||
pub(super) fn describe(_args: TokenStream) -> TokenStream {
|
||||
static ARGS: &[&str] =
|
||||
&["describe", "--dirty", "--tags", "--always", "--broken", "--abbrev=10"];
|
||||
|
||||
let output = git(ARGS);
|
||||
let ret = quote! {
|
||||
static GIT_DESCRIBE: &'static str = #output;
|
||||
};
|
||||
|
||||
ret.into()
|
||||
}
|
||||
|
||||
fn git(args: &[&str]) -> String {
|
||||
Command::new("git")
|
||||
.args(args)
|
||||
|
||||
@@ -6,7 +6,6 @@ mod config;
|
||||
mod debug;
|
||||
mod git;
|
||||
mod implement;
|
||||
mod refutable;
|
||||
mod rustc;
|
||||
mod utils;
|
||||
|
||||
@@ -45,11 +44,6 @@ pub fn rustc_flags_capture(args: TokenStream) -> TokenStream { rustc::flags_capt
|
||||
#[proc_macro]
|
||||
pub fn rustc_version(args: TokenStream) -> TokenStream { rustc::version(args) }
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn refutable(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
attribute_macro::<ItemFn, _>(args, input, refutable::refutable)
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn implement(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
attribute_macro::<ItemFn, _>(args, input, implement::implement)
|
||||
@@ -66,9 +60,6 @@ pub fn git_semantic(args: TokenStream) -> TokenStream { git::semantic(args) }
|
||||
#[proc_macro]
|
||||
pub fn git_commit(args: TokenStream) -> TokenStream { git::commit(args) }
|
||||
|
||||
#[proc_macro]
|
||||
pub fn git_describe(args: TokenStream) -> TokenStream { git::describe(args) }
|
||||
|
||||
fn attribute_macro<I, F>(args: TokenStream, input: TokenStream, func: F) -> TokenStream
|
||||
where
|
||||
F: Fn(I, &[Meta]) -> Result<TokenStream>,
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
use proc_macro::{Span, TokenStream};
|
||||
use quote::{ToTokens, quote};
|
||||
use syn::{FnArg::Typed, Ident, ItemFn, Meta, Pat, PatIdent, PatType, Stmt};
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub(super) fn refutable(mut item: ItemFn, _args: &[Meta]) -> Result<TokenStream> {
|
||||
let inputs = item.sig.inputs.clone();
|
||||
let stmt = &mut item.block.stmts;
|
||||
let sig = &mut item.sig;
|
||||
for (i, input) in inputs.iter().enumerate() {
|
||||
let Typed(PatType { pat, .. }) = input else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let Pat::Struct(ref pat) = **pat else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let variant = &pat.path;
|
||||
let fields = &pat.fields;
|
||||
|
||||
let Some(Typed(PatType { pat, .. })) = sig.inputs.get_mut(i) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let name = format!("_args_{i}");
|
||||
*pat = Box::new(Pat::Ident(PatIdent {
|
||||
ident: Ident::new(&name, Span::call_site().into()),
|
||||
attrs: Vec::new(),
|
||||
by_ref: None,
|
||||
mutability: None,
|
||||
subpat: None,
|
||||
}));
|
||||
|
||||
let field = fields.iter();
|
||||
let refute = quote! {
|
||||
let #variant { #( #field ),*, .. } = #name else { panic!("incorrect variant passed to function argument {i}"); };
|
||||
};
|
||||
|
||||
stmt.insert(0, syn::parse2::<Stmt>(refute)?);
|
||||
}
|
||||
|
||||
Ok(item.into_token_stream().into())
|
||||
}
|
||||
Reference in New Issue
Block a user