don't double-derive ::bok::Repository and Debug
Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
parent
9a83bf0dfa
commit
96ac418e2f
@ -13,7 +13,7 @@ categories = [ "config" ]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { version = "2.0", features = [ "full" ] }
|
||||
syn = { version = "2.0", features = [ "full", "extra-traits" ] }
|
||||
quote = { version = "1.0" }
|
||||
proc-macro2 = "1.0"
|
||||
macro_magic = { version = "0.5", features = [ "proc_support" ] }
|
||||
|
@ -102,17 +102,43 @@ pub(crate) fn repository(
|
||||
};
|
||||
|
||||
let local_attrs = local.attrs.iter().filter(|&x| {
|
||||
// don't export the same thing multiple times
|
||||
if let ::syn::Meta::Path(p) = &x.meta {
|
||||
if p.segments.len() == 2
|
||||
&& p.segments[0].ident == "macro_magic"
|
||||
&& p.segments[1].ident == "export_tokens"
|
||||
{
|
||||
return false;
|
||||
match &x.meta {
|
||||
::syn::Meta::Path(p) => {
|
||||
// looking for:
|
||||
// #[::macro_magic::export_tokens]
|
||||
if p.segments.len() == 2
|
||||
&& p.segments[0].ident == "macro_magic"
|
||||
&& p.segments[1].ident == "export_tokens"
|
||||
{
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
true
|
||||
::syn::Meta::List(ml) => {
|
||||
// looking for:
|
||||
// #[derive(::bok::Repository, Debug)]
|
||||
if ml.path.segments.len() > 0 && ml.path.is_ident("derive") {
|
||||
use ::syn::{punctuated::Punctuated, *};
|
||||
if let Ok(v) = ml.parse_args_with(
|
||||
Punctuated::<::syn::Path, Token![,]>::parse_terminated,
|
||||
) {
|
||||
if v.len() == 2
|
||||
&& v[0].segments.len() == 2
|
||||
&& v[0].segments[0].ident.to_string() == "bok"
|
||||
&& v[0].segments[1].ident.to_string()
|
||||
== "Repository"
|
||||
&& v[1].segments.len() == 1
|
||||
&& v[1].segments[0].ident.to_string() == "Debug"
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
});
|
||||
let generics = local.generics;
|
||||
let ident = local.ident;
|
||||
@ -134,7 +160,6 @@ pub(crate) fn repository(
|
||||
.named
|
||||
.iter()
|
||||
.find(|&x| {
|
||||
//
|
||||
let Some(id) = &x.ident else {
|
||||
return false;
|
||||
};
|
||||
|
@ -17,5 +17,5 @@ macro_magic = { version = "0.5" }
|
||||
prettyplease = "0.2"
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "2", features = [ "full", "parsing" ] }
|
||||
syn = { version = "2", features = [ "full", "parsing", "extra-traits" ] }
|
||||
sha3 = { version = "0.10" }
|
||||
|
@ -73,7 +73,7 @@ impl Pkgs2 {
|
||||
}
|
||||
}
|
||||
/// This repository extends both Pkgs1 and Pkgs2
|
||||
#[::bok::repository(Pkgs1)]
|
||||
#[::bok::repository(Pkgs2)]
|
||||
#[::bok::repository(Pkgs1)]
|
||||
#[derive(::std::default::Default)]
|
||||
pub struct Pkgs3 {}
|
||||
|
Loading…
Reference in New Issue
Block a user