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

Fix meta variable misuse #269

merged 1 commit into from
Jul 30, 2019

Conversation

ia0
Copy link
Contributor

@ia0 ia0 commented Jul 17, 2019

No description provided.

@KodrAus
Copy link
Contributor

KodrAus commented Jul 21, 2019

Hi @ia0, are you able to give a quick summary of what this PR is all about and whether it's likely to break anything?

@ia0
Copy link
Contributor Author

ia0 commented Jul 21, 2019

Hi @KodrAus,
This PR is about fixing #![deny(meta_variable_misuse)] lints (from rust-lang/rust#62008). It should not break anything that was not already broken, but one of the change can probably be done differently. I'll add a comment on the given change.

@@ -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.

@@ -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

Copy link
Contributor

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation @ia0!

Ok, this looks good to me. While I'm not deeply familiar with these macros I know we've got a pretty reasonable test suite here so will trust it to have caught any regressions that might've come about.

@KodrAus KodrAus merged commit 3714653 into rust-lang-deprecated:master Jul 30, 2019
@ia0 ia0 deleted the rust_issues_61053 branch July 30, 2019 22:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants