Skip to content

Commit

Permalink
Implement a temp fix an "ambiguity" with outer attributes that will b…
Browse files Browse the repository at this point in the history
…e resolved with fixes in Rust 1.20; also fixes #28 for v0.3
  • Loading branch information
ErichDonGubler committed Aug 15, 2017
1 parent fe09c10 commit da1e433
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,29 @@ mod parse_generics_shim_util;
/// ```
#[macro_export]
macro_rules! contract {
(
#[$attribute: meta]
fn $fn_name:ident $($tail:tt)*
) => {
parse_generics_shim! {
{ constr },
then contract!(@after_bracket_generics, #[$attribute], $fn_name,),
$($tail)*
}
};
(
$(#[$attribute: meta])*
fn $fn_name:ident $($tail:tt)*
) => {
parse_generics_shim! {
{ constr },
then contract!(@after_bracket_generics, $(#[$attribute])* $fn_name,),
then contract!(@after_bracket_generics, , $fn_name,),
$($tail)*
}
};
(
@after_bracket_generics,
$(#[$attribute: meta])* $fn_name:ident,
$(#[$attribute: meta])*, $fn_name:ident,
{
constr: [$($constr: tt)*],
},
Expand All @@ -80,7 +90,7 @@ macro_rules! contract {
{ clause, preds },
then contract!(
@after_where_generics,
$(#[$attribute])* $fn_name,
$(#[$attribute])*, $fn_name,
{
constr: [$($constr)*],
},
Expand All @@ -91,7 +101,7 @@ macro_rules! contract {
};
(
@after_bracket_generics,
$(#[$attribute: meta])* $fn_name: ident,
$(#[$attribute: meta])*, $fn_name: ident,
{
constr: [$($constr: tt)*],
},
Expand All @@ -102,7 +112,7 @@ macro_rules! contract {
) => {
contract! {
@after_where_generics,
$(#[$attribute])* $fn_name,
$(#[$attribute])*, $fn_name,
{
constr: [$($constr)*],
},
Expand All @@ -118,7 +128,7 @@ macro_rules! contract {
};
(
@after_where_generics,
$(#[$attribute: meta])* $fn_name: ident,
$(#[$attribute: meta])*, $fn_name: ident,
{
constr: [$($constr: tt)*],
},
Expand All @@ -131,6 +141,7 @@ macro_rules! contract {
$($block: tt)*
}
) => {
$(#[$attribute])*
fn $fn_name <$($constr)*> $args $( -> $return_type )* $($where_clause)* {
contract_body! {
(pre {}, body {}, post (def) {}, invariant {})
Expand Down

0 comments on commit da1e433

Please sign in to comment.