Closed
Description
rustc
is telling me that T
needs to be Sized
when it is clearly already Sized
. This code:
#![feature(const_fn)]
const fn size_of<T: Sized>() -> (usize, T) where T: Sized {
(::std::mem::size_of::<T>(), ::std::mem::transmute([0u8; ::std::mem::size_of::<T>()]))
}
Produces this error:
error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
--> src/main.rs:4:62
|
4 | (::std::mem::size_of::<T>(), ::std::mem::transmute([0u8; ::std::mem::size_of::<T>()]))
| ^^^^^^^^^^^^^^^^^^^^^^^^ `T` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= help: consider adding a `where T: std::marker::Sized` bound
= note: required by `std::mem::size_of`
Obviously T: Sized
and where T: Sized
are redundant, but I did it to demonstrate that neither is sufficient. The same error appears if only one of the bounds is used, or if neither are used.