Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decline to lint technically-unnecessary parens in function or method arguments inside of nested macros #47896

Commits on Jan 31, 2018

  1. wherein the parens lint keeps its own counsel re args in nested macros

    In rust-lang#46980 ("in which the unused-parens lint..." (14982db)), the
    unused-parens lint was made to check function and method arguments,
    which it previously did not (seemingly due to oversight rather than
    willful design). However, in rust-lang#47775 and discussion thereon,
    user–developers of Geal/nom and graphql-rust/juniper reported that the
    lint was seemingly erroneously triggering on certain complex macros in
    those projects. While this doesn't seem like a bug in the lint in the
    particular strict sense that the expanded code would, in fact, contain
    unncecessary parentheses, it also doesn't seem like the sort of thing
    macro authors should have to think about: the spirit of the
    unused-parens lint is to prevent needless clutter in code, not to give
    macro authors extra heartache in the handling of token trees.
    
    We propose the expediency of declining to lint unused parentheses in
    function or method args inside of nested expansions: we believe that
    this should eliminate the petty, troublesome lint warnings reported
    in the issue, without forgoing the benefits of the lint in simpler
    macros.
    
    It seemed like too much duplicated code for the `Call` and `MethodCall`
    match arms to duplicate the nested-macro check in addition to each
    having their own `for` loop, so this occasioned a slight refactor so
    that the function and method cases could share code—hopefully the
    overall intent is at least no less clear to the gentle reader.
    
    This is concerning rust-lang#47775.
    zackmdavis committed Jan 31, 2018
    Configuration menu
    Copy the full SHA
    5985b0b View commit details
    Browse the repository at this point in the history