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)] fails when used with a raw pointer to DST #36870

Closed
whitequark opened this issue Sep 30, 2016 · 6 comments
Closed

#[derive(Debug)] fails when used with a raw pointer to DST #36870

whitequark opened this issue Sep 30, 2016 · 6 comments

Comments

@whitequark
Copy link
Member

whitequark commented Sep 30, 2016

... with the following error message:

error[E0277]: the trait bound `core::ops::Fn() -> bool + 'static: core::marker::Sized` is not satisfied
   --> /home/whitequark/Work/artiq-dev/artiq/artiq/runtime/../runtime.rs/src/sched.rs:109:16
    |
109 |     Completion(*const (Fn() -> bool + 'static)),
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/whitequark/Work/artiq-dev/artiq/artiq/runtime/../runtime.rs/src/sched.rs:107:10: 107:15 note: in this expansion of #[derive(Debug)] (defined in /home/whitequark/Work/artiq-dev/artiq/artiq/runtime/../runtime.rs/src/sched.rs)
    |
    = note: `core::ops::Fn() -> bool + 'static` does not have a constant size known at compile-time
    = note: required because of the requirements on the impl of `core::fmt::Debug` for `*const core::ops::Fn() -> bool + 'static`
    = note: required because of the requirements on the impl of `core::fmt::Debug` for `&*const core::ops::Fn() -> bool + 'static`
    = note: required for the cast to the object type `core::fmt::Debug`

since the Debug impl for raw pointers just prints the actual pointer, I don't see why it should require the pointee to be Sized.

@whitequark whitequark changed the title #[derive(Debug)] for *const Fn() fails #[derive(Debug)] for *const DST fails Sep 30, 2016
@whitequark whitequark changed the title #[derive(Debug)] for *const DST fails #[derive(Debug)] fails when used with a raw pointer to DST Sep 30, 2016
@apasel422
Copy link
Contributor

Do you have a code snippet that exhibits this?

@apasel422
Copy link
Contributor

Seems like this is a duplicate of #30427.

@whitequark
Copy link
Member Author

trait T {}
#[derive(Debug)]
struct S(*const T);

@durka
Copy link
Contributor

durka commented Sep 30, 2016

I'm working on this.

@durka
Copy link
Contributor

durka commented Oct 1, 2016

It is not a duplicate of #30427. That was fixed by #31479 which extended the Pointer implementation to unsized T. However, the Debug impl, which merely delegates to Pointer, was not updated in that PR.

Manishearth added a commit to Manishearth/rust that referenced this issue Oct 1, 2016
impl Debug for raw pointers to unsized data

`?Sized` was missing from these impls for seemingly no reason.

Fixes rust-lang#36870.
@whitequark
Copy link
Member Author

Thanks @durka

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

No branches or pull requests

3 participants