Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Fix meta variable misuse #269

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/impl_error_chain_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ macro_rules! impl_error_chain_kind {
queue [ #[$qmeta:meta] $( $tail:tt )*]
) => {
impl_error_chain_kind!(SORT [$( $def )*]
enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: unknown macro variable `emeta`
  --> src/impl_error_chain_kind.rs:88:26
   |
88 |             enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )*
   |                          ^^^^^^
error: unknown macro variable `eitem`
  --> src/impl_error_chain_kind.rs:88:39
   |
88 |             enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )*
   |                                       ^^^^^^
error: unknown macro variable `etyp`
  --> src/impl_error_chain_kind.rs:88:52
   |
88 |             enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )*
   |                                                    ^^^^^

Someone familiar with the code should be able to decide how to fix this error:

  • Either remove the whole rule because it is never reached (most probable actually).
  • Or adapt the right-hand side of the rule such that it does not reference unbound meta-variables (that's what I tried to do).
  • Or adapt the left-hand side of the rule such that it binds $emeta, $eitem, and $etyp.

$(#[$bmeta])* => $bitem: $bmode $(( $($btyp),* ))*]
enum [$(#[$bmeta])* => $bitem: $bmode $(( $($btyp),* ))*]
items [$($( #[$imeta:meta] )*
=> $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*
$bitem: $bmode [$( $bvar:$btyp ),*] {} ]
Expand All @@ -103,7 +102,7 @@ macro_rules! impl_error_chain_kind {
) => {
impl_error_chain_kind!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),*] ]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All following errors are similar to this one, so I'm just providing the output for this error.

error: meta-variable repeats with different Kleene operator
   --> src/impl_error_chain_kind.rs:106:55
    |
102 |         queue [($( $qvar:ident: $qtyp:ty ),+) $( $tail:tt )*]
    |                                            - expected repetition
...
106 |             buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),*] ]
    |                                                       ^^^^^         - conflicting repetition

buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),+] ]
queue [$( $tail )*]
);
};
Expand All @@ -117,7 +116,7 @@ macro_rules! impl_error_chain_kind {
) => {
impl_error_chain_kind!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ]
buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),+] ]
queue [$( $tail )*]);
};
// Add struct enum-variant, with excess comma - e.g. { descr: &'static str, }
Expand All @@ -130,7 +129,7 @@ macro_rules! impl_error_chain_kind {
) => {
impl_error_chain_kind!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ]
buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),+] ]
queue [$( $tail )*]);
};
// Add braces and flush always on braces
Expand Down Expand Up @@ -188,7 +187,7 @@ macro_rules! impl_error_chain_kind {
pub enum $name {
$(
$(#[$imeta])*
$iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*,
$iitem $(($( $ttyp ),+))* $({$( $svar: $styp ),*})*,
)*

#[doc(hidden)]
Expand Down Expand Up @@ -217,7 +216,7 @@ macro_rules! impl_error_chain_kind {
) => {
impl_error_chain_kind!(ENUM_DEFINITION [ $($def)* ]
body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )*
$( #[$qmeta] )* => $qitem (($( $qtyp ),*)) {} ]
$( #[$qmeta] )* => $qitem (($( $qtyp ),+)) {} ]
queue [ $($queue)* ]
);
};
Expand Down