gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

`<tyty::error>` appears in error message when derive macro used

Open tamaroning opened this issue 5 months ago • 0 comments

Summary

expected to get E0204 but got E0308 and the actual message is buggy

Reproducer

I tried this code:

#[lang = "sized"]
pub trait Sized {}

#[lang = "copy"]
trait Copy {}

pub trait Clone {
    fn clone(&self) -> Self;
}

impl Clone for i32 {
    fn clone(&self) -> i32 {
        *self
    }
}

//#[derive(Clone)]
struct S {
}

#[derive(Clone, Copy)]
struct S2 {
    a: i32,
    s: S
}

fn main() -> i32 {
    0
}

Does the code make use of any (1.49) nightly feature ?

  • [ ] Nightly

Godbolt link

https://godbolt.org/z/M3sveonGx

Actual behavior

got

<source>:21:3: error: mismatched types, expected '& <tyty::error>' but got '& S' [E0308]
    8 |     fn clone(&self) -> Self;
      |              ~
......
   21 | #[derive(Clone, Copy)]
      |   ^~~~~~
Compiler returned: 1

Expected behavior

I expected to see... (rustc)

error[E0204]: the trait `Copy` may not be implemented for this type
  --> <source>:23:17
   |
23 | #[derive(Clone, Copy)]
   |                 ^^^^
...
26 |     s: S
   |     ---- this field does not implement `Copy`
   |
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

GCC Version

master

tamaroning avatar Aug 28 '24 17:08 tamaroning