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
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> src/main.rs:6:18
|
6 | fn func() -> Struct<Self>;
| ^^^^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::marker::Sized`
| |
| doesn't have a size known at compile-time
...
9 | struct Struct<T> {
| - required by this bound in `Struct`
|
= help: the trait `std::marker::Sized` is not implemented for `Self`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
The text was updated successfully, but these errors were encountered:
Rust requires size for structs parameterized with PhantomData.
I'm honestly not sure if this is a bug or type system limitation.
I tried this code: playground
I expected to see this happen: Compilation complete.
std::marker::PhantomData<*const T>
is zero-size. And*const T
is known size.Instead, this happened: The build failed.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: