gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

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

Open lucasly-ba opened this issue 2 months ago • 2 comments

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 #https://github.com/Rust-GCC/gccrs/pull/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

lucasly-ba avatar Oct 15 '25 14:10 lucasly-ba

I think it is normal you got an error, as you try to derive a function, which is not a struct/enum or union.

Edit: It is not as it should be ignored, as it is in master

Villosse avatar Oct 17 '25 10:10 Villosse

I think we can close this one now

CohenArthur avatar Dec 08 '25 14:12 CohenArthur