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

derive(Debug) does not compile #92

Closed
jean-airoldie opened this issue Jun 18, 2023 · 3 comments · Fixed by #93
Closed

derive(Debug) does not compile #92

jean-airoldie opened this issue Jun 18, 2023 · 3 comments · Fixed by #93

Comments

@jean-airoldie
Copy link

Hi,

The following does not compile:

#[ouroboros::self_referencing]
#[derive(Debug)]
pub struct Struct<'a> {
    bytes: Vec<u8>,
    #[borrows(bytes)]
    slice: &'a [u8],
}
error: bad syntax
 --> src/lib.rs:4:1
  |
4 | #[derive(Debug)]
  | ^^^^^^^^^^^^^^^^

error: could not compile `ouroboros-private` (lib) due to previous error

Neither does this:

#[derive(Debug)]
#[ouroboros::self_referencing]
pub struct Struct<'a> {
    bytes: Vec<u8>,
    #[borrows(bytes)]
    slice: &'a [u8],
}
    Checking ouroboros-private v0.1.0 (/home/maxence/bug/ouroboros-private)
error[E0609]: no field `bytes` on type `&Struct<'a>`
 --> src/lib.rs:4:5
  |
4 |     bytes: Vec<u8>,
  |     ^^^^^ unknown field

error[E0609]: no field `slice` on type `&Struct<'a>`
 --> src/lib.rs:6:5
  |
6 |     slice: &'a [u8],
  |     ^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `ouroboros-private` (lib) due to 2 previous errors

Im using rustc 1.72.0-nightly (1c53407e8 2023-05-28)

@kpreid
Copy link
Contributor

kpreid commented Jun 18, 2023

You might want to write a manual impl fmt::Debug for Struct<'_> anyway, because the derive, if it succeeded, would print the entire contents of bytes and the entire contents of the slice of it, duplicating some data.

@jean-airoldie
Copy link
Author

Good point.

@circuitsacul
Copy link

But this is still a bug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants