Merge pull request #2 from dtolnay/local

Replace local_inner_macros
This commit is contained in:
Diggory Blake 2019-04-03 17:52:19 +01:00 committed by GitHub
commit bea12b8e2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 32 deletions

View file

@ -1,6 +1,5 @@
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! private_define_context { macro_rules! private_define_context {
{ {
$caller:tt $caller:tt
@ -11,9 +10,9 @@ macro_rules! private_define_context {
}] }]
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ private_define_context }] macro = [{ $crate::private_define_context }]
rest = [{ $($body)* }] rest = [{ $($body)* }]
~~> private_define_context! { ~~> $crate::private_define_context! {
$caller $caller
name = [{ $name }] name = [{ $name }]
} }
@ -84,7 +83,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty [ ($($f_args:ident),*) $factory:ty ], $($rest:tt)* }] rest = [{ $field_name:ident: $t:ty [ ($($f_args:ident),*) $factory:ty ], $($rest:tt)* }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
auto_field = [{ $field_name, $t, $factory, ($($f_args,)*) }] auto_field = [{ $field_name, $t, $factory, ($($f_args,)*) }]
@ -98,7 +97,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty [ ($($f_args:ident),*) $factory:ty ] }] rest = [{ $field_name:ident: $t:ty [ ($($f_args:ident),*) $factory:ty ] }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
auto_field = [{ $field_name, $t, $factory, ($($f_args,)*) }] auto_field = [{ $field_name, $t, $factory, ($($f_args,)*) }]
@ -112,7 +111,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty [ $factory:ty ], $($rest:tt)* }] rest = [{ $field_name:ident: $t:ty [ $factory:ty ], $($rest:tt)* }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
auto_field = [{ $field_name, $t, $factory, () }] auto_field = [{ $field_name, $t, $factory, () }]
@ -126,7 +125,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty [ $factory:ty ] }] rest = [{ $field_name:ident: $t:ty [ $factory:ty ] }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
auto_field = [{ $field_name, $t, $factory, () }] auto_field = [{ $field_name, $t, $factory, () }]
@ -140,7 +139,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty, $($rest:tt)* }] rest = [{ $field_name:ident: $t:ty, $($rest:tt)* }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
$(field = [{ $($field)* }])* $(field = [{ $($field)* }])*
@ -154,7 +153,7 @@ macro_rules! private_define_context {
$(field = [{ $($field:tt)* }])* $(field = [{ $($field:tt)* }])*
rest = [{ $field_name:ident: $t:ty }] rest = [{ $field_name:ident: $t:ty }]
} => { } => {
private_define_context! { $crate::private_define_context! {
$caller $caller
$(auto_field = [{ $($auto_field)* }])* $(auto_field = [{ $($auto_field)* }])*
$(field = [{ $($field)* }])* $(field = [{ $($field)* }])*
@ -268,11 +267,11 @@ macro_rules! private_define_context {
/// ``` /// ```
/// ///
/// ///
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! define_context { macro_rules! define_context {
($($input:tt)*) => ( ($($input:tt)*) => (
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ private_define_context }] macro = [{ $crate::private_define_context }]
input = [{ $($input)* }] input = [{ $($input)* }]
} }
); );

View file

@ -1,5 +1,5 @@
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! generate_trait_def { macro_rules! generate_trait_def {
{ {
$caller:tt $caller:tt
@ -21,7 +21,7 @@ macro_rules! generate_trait_def {
} }
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! generate_trait_impl { macro_rules! generate_trait_impl {
{ {
$caller:tt $caller:tt
@ -45,16 +45,16 @@ macro_rules! generate_trait_impl {
} }
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! private_define_interface { macro_rules! private_define_interface {
{ {
$caller:tt $caller:tt
input = [{ $($input:tt)* }] input = [{ $($input:tt)* }]
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ parse_trait_def }] macro = [{ $crate::parse_trait_def }]
input = [{ $($input)* }] input = [{ $($input)* }]
~~> private_define_interface! { ~~> $crate::private_define_interface! {
$caller $caller
} }
} }
@ -68,11 +68,11 @@ macro_rules! private_define_interface {
$(bound = [{ $($bound:tt)* }])* $(bound = [{ $($bound:tt)* }])*
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ join }] macro = [{ $crate::join }]
sep = [{ + }] sep = [{ + }]
$(item = [{ $($bound)* }])* $(item = [{ $($bound)* }])*
$(item = [{ $crate::Provide<$t> }])* $(item = [{ $crate::Provide<$t> }])*
~~> private_define_interface! { ~~> $crate::private_define_interface! {
$caller $caller
name = [{ $name }] name = [{ $name }]
getters = [{ $( getters = [{ $(
@ -88,11 +88,11 @@ macro_rules! private_define_interface {
joined = [{ $($joined:tt)* }] joined = [{ $($joined:tt)* }]
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ generate_trait_def }] macro = [{ $crate::generate_trait_def }]
name = [{ $name }] name = [{ $name }]
bounds = [{ $($joined)* }] bounds = [{ $($joined)* }]
getters = [{ $($getters)* }] getters = [{ $($getters)* }]
~~> private_define_interface! { ~~> $crate::private_define_interface! {
$caller $caller
name = [{ $name }] name = [{ $name }]
getters = [{ $($getters)* }] getters = [{ $($getters)* }]
@ -108,11 +108,11 @@ macro_rules! private_define_interface {
trait_def = [{ $($trait_def:tt)* }] trait_def = [{ $($trait_def:tt)* }]
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ generate_trait_impl }] macro = [{ $crate::generate_trait_impl }]
name = [{ $name }] name = [{ $name }]
bounds = [{ $($bounds)* }] bounds = [{ $($bounds)* }]
getters = [{ $($getters)* }] getters = [{ $($getters)* }]
~~> private_define_interface! { ~~> $crate::private_define_interface! {
$caller $caller
trait_def = [{ $($trait_def)* }] trait_def = [{ $($trait_def)* }]
} }
@ -181,11 +181,11 @@ macro_rules! private_define_interface {
/// ); /// );
/// ``` /// ```
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! define_interface { macro_rules! define_interface {
($($input:tt)*) => ( ($($input:tt)*) => (
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ private_define_interface }] macro = [{ $crate::private_define_interface }]
input = [{ $($input)* }] input = [{ $($input)* }]
} }
); );

View file

@ -96,7 +96,9 @@
//! //!
//! See the individual macro documentation for more details. //! See the individual macro documentation for more details.
#[doc(hidden)]
pub extern crate tt_call; pub extern crate tt_call;
#[doc(hidden)]
pub extern crate failure; pub extern crate failure;
mod join; mod join;

View file

@ -1,11 +1,11 @@
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! parse_bound { macro_rules! parse_bound {
{ {
$caller:tt $caller:tt
input = [{ $($input:tt)* }] input = [{ $($input:tt)* }]
} => { } => {
parse_bound! { $crate::parse_bound! {
$caller $caller
rest = [{ $($input)* }] rest = [{ $($input)* }]
} }
@ -18,7 +18,7 @@ macro_rules! parse_bound {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ $crate::tt_call::parse_type }] macro = [{ $crate::tt_call::parse_type }]
input = [{ $($rest)* }] input = [{ $($rest)* }]
~~> parse_bound! { ~~> $crate::parse_bound! {
$caller $caller
$(bound = [{ $($bound)* }])* $(bound = [{ $($bound)* }])*
} }
@ -30,7 +30,7 @@ macro_rules! parse_bound {
type = [{ $($type:tt)* }] type = [{ $($type:tt)* }]
rest = [{ + $($rest:tt)* }] rest = [{ + $($rest:tt)* }]
} => { } => {
parse_bound! { $crate::parse_bound! {
$caller $caller
$(bound = [{ $($bound)* }])* $(bound = [{ $($bound)* }])*
bound = [{ $($type)* }] bound = [{ $($type)* }]
@ -53,7 +53,7 @@ macro_rules! parse_bound {
} }
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export]
macro_rules! parse_trait_def { macro_rules! parse_trait_def {
{ {
$caller:tt $caller:tt
@ -70,9 +70,9 @@ macro_rules! parse_trait_def {
input = [{ $name:ident: $($rest:tt)* }] input = [{ $name:ident: $($rest:tt)* }]
} => { } => {
$crate::tt_call::tt_call! { $crate::tt_call::tt_call! {
macro = [{ parse_bound }] macro = [{ $crate::parse_bound }]
input = [{ $($rest)* }] input = [{ $($rest)* }]
~~> parse_trait_def! { ~~> $crate::parse_trait_def! {
$caller $caller
name = [{ $name }] name = [{ $name }]
} }