Skip to content

#[derive()] without traits should be ignored, not give an error, even followed by invalid item #4216

@lucasly-ba

Description

@lucasly-ba

code:

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
#[derive()]
pub fn check_ge(a: i32, b: i32) -> bool
{
    a >= b
}

On top of ##4211 :

a.rs:1:3: error: derive may only be applied to structs, enums and unions
    1 | #[derive()]
      |   ^~~~~~

Analyzing compilation unit

Time variable                                  wall           GGC
 TOTAL                              :   0.00          136k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

Expected:

warning: unused attribute
 --> a.rs:1:1
  |
1 | #[derive()]
  | ^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

warning: 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions