-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.
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.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.