You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traitTrait{}// OK#[deriving(Show)]structFoo<T:Trait>{foo:T,}#[deriving(Show)]//~^ error: the trait `Trait` is not implemented for the type `T`structBar<T>whereT:Trait{bar:T,}fnmain(){}
Output
If you check the --pretty=expanded output, you'll notice the T: Trait bound is missing in the Bar case.
// OKstructFoo<T:Trait>{foo:T,}#[automatically_derived]impl<T:::std::fmt::Show + Trait>::std::fmt::ShowforFoo<T>{fnfmt(&self,__arg_0:&mut::std::fmt::Formatter) -> ::std::fmt::Result{match*self{Foo{foo:ref __self_0_0 } =>
match(&(*__self_0_0),){(__arg0,) => {#[inline]#[allow(dead_code)]static __STATIC_FMTSTR:&'static [&'static str] =
&["Foo { foo: "," }"];let __args_vec =
&[::std::fmt::argument(::std::fmt::Show::fmt,
__arg0)];let __args =
unsafe{::std::fmt::Arguments::new(__STATIC_FMTSTR,
__args_vec)};
__arg_0.write_fmt(&__args)}},}}}//~^ error: the trait `Trait` is not implemented for the type `T`structBar<T>{bar:T,}#[automatically_derived]impl<T:::std::fmt::Show>::std::fmt::ShowforBar<T>{fnfmt(&self,__arg_0:&mut::std::fmt::Formatter) -> ::std::fmt::Result{match*self{Bar{bar:ref __self_0_0 } =>
match(&(*__self_0_0),){(__arg0,) => {#[inline]#[allow(dead_code)]static __STATIC_FMTSTR:&'static [&'static str] =
&["Bar { bar: "," }"];let __args_vec =
&[::std::fmt::argument(::std::fmt::Show::fmt,
__arg0)];let __args =
unsafe{::std::fmt::Arguments::new(__STATIC_FMTSTR,
__args_vec)};
__arg_0.write_fmt(&__args)}},}}}fnmain(){}
The possible solution would be to make the deriving syntax extension also copy the where clause bounds into the expanded impl, just like it already does for the "inline bounds" impl<T: Show + Trait> ....
The text was updated successfully, but these errors were encountered:
japaric
changed the title
#[Deriving(..)] doesn't work on structs that specify their bounds using where clauses#[deriving(..)] doesn't work on structs that specify their bounds using where clauses
Nov 27, 2014
STR
Output
If you check the
--pretty=expanded
output, you'll notice theT: Trait
bound is missing in theBar
case.Version
The possible solution would be to make the
deriving
syntax extension also copy thewhere
clause bounds into the expandedimpl
, just like it already does for the "inline bounds"impl<T: Show + Trait> ...
.The text was updated successfully, but these errors were encountered: