Closed
Description
STR
#[derive(Debug)]
struct Row<T>([T]);
//~ error: the trait `core::marker::Sized` is not implemented for the type `[T]`
fn main() {}
Expansion:
struct Row<T>([T]);
impl <T: ::std::fmt::Debug> ::std::fmt::Debug for Row<T> where
T: ::std::fmt::Debug {
fn fmt(&self, __arg_0: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match *self {
Row(ref __self_0_0) =>
__arg_0.debug_tuple("Row").field(&(*__self_0_0)).finish(),
//~^ error: the trait `core::marker::Sized` is not implemented for the type `[T]`
}
}
}
fn main() {}
This is because the DebugTuple::field
method expects a &Debug
trait object, and fat pointers (like &[T]
) can't be coerced to trait objects. This would work if the signature of the DebugTuple::field
was changed to:
impl DebugTuple {
fn field<T: ?Sized + Debug>(self, value: &T) -> DebugTuple { .. }
}
As a workaround you can impl Debug
manually as write!(f, "Row({:?})", &self.0)
Version
rustc 1.1.0-nightly (c2b30b86d 2015-05-12) (built 2015-05-13)
cc @alexcrichton
cc @sfackler