-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-trait-systemArea: Trait systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
In the following code:
struct Foo;
trait Channel<T> {
type ID;
const CHANNEL: Self::ID;
}
impl<T> Channel<T> for Foo {
type ID = u8;
const CHANNEL: u8 = 3;
}
the compiler refuses it with the following error:
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> src/lib.rs:10:5
|
10 | const CHANNEL: u8 = 3;
| ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized>
= help: consider adding a `where T: std::marker::Sized` bound
= note: required because of the requirements on the impl of `Channel<T>` for `Foo`
after adding T: ?Sized to lines 3 and 8, the code compiles.
chrign, eldruin and neoneye
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team