-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Failing to use derive for nested types parameterized on associated types #31518
Comments
Discussed on irc with @durka. |
If the expansion code for |
Here's a playpen with the pretty-expanded form of the original code, with the bound on line 26 added to make it compile. |
Hmm yep and it's basically unfixable as per the discussion there, at least with structs which can have private members, because adding |
Yes, for the case: pub trait Foo { type Bar; }
#[derive(Debug)]
enum Baz<F> where F: Foo { Baz(F::Bar) }
#[derive(Debug)]
pub enum Bang<F> where F: Foo { Bang(Baz<F>) } you'd need the derivation for |
It's worse than tricky. If you turn them into structs pub trait Foo { type Bar; }
#[derive(Debug)]
struct Baz<F> where F: Foo { baz: F::Bar }
#[derive(Debug)]
pub struct Bang<F> where F: Foo { bang: Baz<F> } then you aren't even allowed to write the necessary bound. |
Isn't the bound |
Actually the most specific bound is |
You could recursively derive the bounds for |
Yeah, I could, but |
Yes, it sounds like |
Closing in favor of #32872. |
In this example (https://play.rust-lang.org/?gist=5dde58647c1e97b97f46) there's an error failing to derive
Debug
forBang
:The error is
error: the trait
core::fmt::Debugis not implemented for the type
::Bar[E0277]
. It works forBaz
, you only get problems when you nest types parameterized on associated types.The text was updated successfully, but these errors were encountered: