Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
tamaroning opened this issue Aug 28, 2024 · 0 comments
Open
1 task

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

tamaroning opened this issue Aug 28, 2024 · 0 comments
Assignees
Labels

Comments

@tamaroning
Copy link
Contributor

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

@philberty philberty self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants