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

False positive in nonstandard_macro_braces involving macros #7422

Closed
dtolnay opened this issue Jul 3, 2021 · 1 comment · Fixed by #7431
Closed

False positive in nonstandard_macro_braces involving macros #7422

dtolnay opened this issue Jul 3, 2021 · 1 comment · Fixed by #7431
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dtolnay
Copy link
Member

dtolnay commented Jul 3, 2021

// src/main.rs

#[derive(testing::Derive)]
pub struct S;

fn main() {}
// src/lib.rs

use proc_macro::TokenStream;

#[proc_macro_derive(Derive)]
pub fn derive(input: TokenStream) -> TokenStream {
    let _ = input;
    "fn _f() -> Vec<u8> { vec![] }".parse().unwrap()
}
$ cargo clippy
warning: use of irregular braces for `vec!` macro
 --> src/main.rs:1:10
  |
1 | #[derive(testing::Derive)]
  |          ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(clippy::nonstandard_macro_braces)]` on by default
help: consider writing `testing::Derive`
 --> src/main.rs:1:10
  |
1 | #[derive(testing::Derive)]
  |          ^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
  = note: this warning originates in the derive macro `testing::Derive` (in Nightly builds, run with -Z macro-backtrace for more info)

vec![] seems like the standard braces. The consider writing `testing::Derive`​ doesn't make sense.

@DevinR528 @llogiq


Meta

  • cargo clippy -V: clippy 0.1.55 (798baeb 2021-07-02)
  • rustc -Vv:
    rustc 1.55.0-nightly (798baebde 2021-07-02)
    binary: rustc
    commit-hash: 798baebde1fe77e5a660490ec64e727a5d79970d
    commit-date: 2021-07-02
    host: x86_64-unknown-linux-gnu
    release: 1.55.0-nightly
    LLVM version: 12.0.1
    
@dtolnay dtolnay added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jul 3, 2021
dtolnay added a commit to dtolnay/star-history that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `write!` macro
      --> src/main.rs:68:10
       |
    68 | #[derive(Error, Debug)]
       |          ^^^^^
       |
       = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
      --> src/main.rs:68:10
       |
    68 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to dtolnay/serde-repr that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `format_args!` macro
     --> tests/test.rs:8:30
      |
    8 |     #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
      |                              ^^^^^^^^^^^^^^^^
      |
      = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Deserialize_repr`
     --> tests/test.rs:8:30
      |
    8 |     #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
      |                              ^^^^^^^^^^^^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Deserialize_repr` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `format_args!` macro
      --> tests/test.rs:56:30
       |
    56 |     #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
       |                              ^^^^^^^^^^^^^^^^
       |
    help: consider writing `Deserialize_repr`
      --> tests/test.rs:56:30
       |
    56 |     #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
       |                              ^^^^^^^^^^^^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Deserialize_repr` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to dtolnay/rust-quiz that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `write!` macro
      --> src/error.rs:10:10
       |
    10 | #[derive(Error, Debug)]
       |          ^^^^^
       |
       = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
      --> src/error.rs:10:10
       |
    10 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to serde-rs/serde that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `format_args!` macro
       --> test_suite/tests/test_gen.rs:528:25
        |
    528 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^
        |
        = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Deserialize`
       --> test_suite/tests/test_gen.rs:528:25
        |
    528 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `format_args!` macro
        --> test_suite/tests/test_annotations.rs:1791:43
         |
    1791 |     #[derive(Debug, PartialEq, Serialize, Deserialize)]
         |                                           ^^^^^^^^^^^
         |
         = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Deserialize`
        --> test_suite/tests/test_annotations.rs:1791:43
         |
    1791 |     #[derive(Debug, PartialEq, Serialize, Deserialize)]
         |                                           ^^^^^^^^^^^
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
         = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to dtolnay/proc-macro-hack that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `vec!` macro
     --> demo-hack-impl/src/lib.rs:6:1
      |
    6 | #[proc_macro_hack]
      | ^^^^^^^^^^^^^^^^^^
      |
      = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `#[proc_macro_hack]`
     --> demo-hack-impl/src/lib.rs:6:1
      |
    6 | #[proc_macro_hack]
      | ^^^^^^^^^^^^^^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the attribute macro `proc_macro_hack` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to dtolnay/anyhow that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `write!` macro
     --> tests/test_boxed.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      |
      = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
     --> tests/test_boxed.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_context.rs:36:10
       |
    36 | #[derive(Error, Debug)]
       |          ^^^^^
       |
       = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
      --> tests/test_context.rs:36:10
       |
    36 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
dtolnay added a commit to dtolnay/thiserror that referenced this issue Jul 3, 2021
Clippy bug: rust-lang/rust-clippy#7422

    error: use of irregular braces for `write!` macro
     --> tests/test_backtrace.rs:5:10
      |
    5 | #[derive(Error, Debug)]
      |          ^^^^^
      |
      = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
     --> tests/test_backtrace.rs:5:10
      |
    5 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_lints.rs:13:21
       |
    13 |     #[derive(Debug, Error)]
       |                     ^^^^^
       |
       = note: `-D clippy::nonstandard-macro-braces` implied by `-D clippy::all`
    help: consider writing `Error`
      --> tests/test_lints.rs:13:21
       |
    13 |     #[derive(Debug, Error)]
       |                     ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_source.rs:7:10
      |
    7 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_source.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_source.rs:7:10
      |
    7 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_source.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_source.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_source.rs:54:18
       |
    54 |           #[derive(Error)]
       |                    ^^^^^
    ...
    64 | / error_from_macro! {
    65 | |     #[error("Something")]
    66 | |     Variant(#[from] io::Error)
    67 | | }
       | |_- in this macro invocation
       |
    help: consider writing `Error`
      --> tests/test_source.rs:54:18
       |
    54 |           #[derive(Error)]
       |                    ^^^^^
    ...
    64 | / error_from_macro! {
    65 | |     #[error("Something")]
    66 | |     Variant(#[from] io::Error)
    67 | | }
       | |_- in this macro invocation
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_expr.rs:9:10
      |
    9 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_expr.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_expr.rs:9:10
      |
    9 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_expr.rs:39:10
       |
    39 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_expr.rs:39:10
       |
    39 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_from.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_from.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_from.rs:6:10
      |
    6 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:13:10
       |
    13 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
     --> tests/test_path.rs:8:10
      |
    8 | #[derive(Error, Debug)]
      |          ^^^^^
      |
    note: the lint level is defined here
     --> tests/test_path.rs:1:9
      |
    1 | #![deny(clippy::all, clippy::pedantic)]
      |         ^^^^^^^^^^^
      = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
     --> tests/test_path.rs:8:10
      |
    8 | #[derive(Error, Debug)]
      |          ^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
      = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_path.rs:14:10
       |
    14 | #[derive(Error, Debug, RefCast)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_path.rs:14:10
       |
    14 | #[derive(Error, Debug, RefCast)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:17:10
       |
    17 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:17:10
       |
    17 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_path.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_path.rs:21:10
       |
    21 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:14:14
       |
    14 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: the lint level is defined here
      --> tests/test_transparent.rs:1:9
       |
    1  | #![deny(clippy::all, clippy::pedantic)]
       |         ^^^^^^^^^^^
       = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
      --> tests/test_transparent.rs:14:14
       |
    14 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_from.rs:26:10
       |
    26 | #[derive(Error, Debug)]
       |          ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_from.rs:26:10
       |
    26 | #[derive(Error, Debug)]
       |          ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:34:14
       |
    34 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_transparent.rs:34:14
       |
    34 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_transparent.rs:69:14
       |
    69 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_transparent.rs:69:14
       |
    69 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:12:14
       |
    12 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    note: the lint level is defined here
      --> tests/test_display.rs:1:9
       |
    1  | #![deny(clippy::all, clippy::pedantic)]
       |         ^^^^^^^^^^^
       = note: `#[deny(clippy::nonstandard_macro_braces)]` implied by `#[deny(clippy::all)]`
    help: consider writing `Error`
      --> tests/test_display.rs:12:14
       |
    12 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:24:14
       |
    24 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:24:14
       |
    24 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:35:14
       |
    35 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:35:14
       |
    35 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:44:14
       |
    44 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:44:14
       |
    44 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:53:14
       |
    53 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:53:14
       |
    53 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:70:14
       |
    70 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:70:14
       |
    70 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:84:14
       |
    84 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:84:14
       |
    84 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
      --> tests/test_display.rs:98:14
       |
    98 |     #[derive(Error, Debug)]
       |              ^^^^^
       |
    help: consider writing `Error`
      --> tests/test_display.rs:98:14
       |
    98 |     #[derive(Error, Debug)]
       |              ^^^^^
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
       = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:107:14
        |
    107 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:107:14
        |
    107 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:115:14
        |
    115 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:115:14
        |
    115 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:129:14
        |
    129 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:129:14
        |
    129 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:158:14
        |
    158 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:158:14
        |
    158 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:170:14
        |
    170 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:170:14
        |
    170 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:184:14
        |
    184 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:184:14
        |
    184 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:201:14
        |
    201 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:201:14
        |
    201 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:214:29
        |
    214 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        |
    help: consider writing `Error`
       --> tests/test_display.rs:214:29
        |
    214 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:220:29
        |
    220 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        |
    help: consider writing `Error`
       --> tests/test_display.rs:220:29
        |
    220 |             #[derive(Debug, Error)]
        |                             ^^^^^
    ...
    228 |     decl_error!(Repro(u8));
        |     ----------------------- in this macro invocation
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:236:14
        |
    236 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:236:14
        |
    236 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:247:14
        |
    247 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:247:14
        |
    247 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:258:14
        |
    258 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:258:14
        |
    258 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: use of irregular braces for `write!` macro
       --> tests/test_display.rs:269:14
        |
    269 |     #[derive(Error, Debug)]
        |              ^^^^^
        |
    help: consider writing `Error`
       --> tests/test_display.rs:269:14
        |
    269 |     #[derive(Error, Debug)]
        |              ^^^^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
        = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
bors added a commit that referenced this issue Jul 3, 2021
Downgrade nonstandard_macro_braces to nursery

Due to the large number of crates impacted by #7422, I don't think this lint can be enabled by default right now until the false positive is fixed.

---

changelog: remove [`nonstandard_macro_braces`] from default set of enabled lints
@DevinR528
Copy link
Contributor

I'm looking into it, my guess is that it's finding the macro then comparing the snippet to macro_name!(/[/{ but what the snippet found is the outer macro so test::Derive and since it isn't the same it passes. I wonder if adding a check for the actual macro name in the snippet and bailing out if not found would work well enough?

@bors bors closed this as completed in 3cc6778 Jul 4, 2021
bors bot added a commit to jonasbb/serde_with that referenced this issue Jul 8, 2021
334: Suppress false positive in current clippy nightly r=jonasbb a=jonasbb

rust-lang/rust-clippy#7422

Co-authored-by: Jonas Bushart <jonas@bushart.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants