Skip to content

macro imports don't work when there are _two_ imported attributes #52525

Closed
@Manishearth

Description

@Manishearth
// crate must be on rust 2018
// OR add an `extern crate serde_derive`

use serde_derive::Deserialize;

#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(deny_unknown_fields)]
enum Foo {
    A(u8)
}

This is the code you are supposed to use according to the macro_use_extern_crate lint.

It fails to compile, with

   Compiling t v0.1.0 (file:///home/manishearth/sand/bar/t)                                                              
error: cannot find attribute macro `serde` in this scope=========>      ] 9/10: t                                        
  --> src/main.rs:11:3
   |
11 | #[serde(deny_unknown_fields)]
   |   ^^^^^

It compiles fine if you use just one of the two attributes. Swapping attribute order makes it complain about the last non-derive attribute.

This seems broken?

cc @dtolnay @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-1-2Area: Declarative macros 1.2A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions