Skip to content

False positive in nonstandard_macro_braces involving macros #7422

Closed
@dtolnay

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions