Closed
Description
Given the following code: playground
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
trait OnlySized<T> {}
impl<T> OnlySized<T> for () {}
trait LetsGo {
fn uwu() -> impl OnlySized<[u8]>;
}
struct Owo;
impl LetsGo for Owo {
fn uwu() -> () {}
}
fn main() {}
The current output is:
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/main.rs:15:17
|
15 | fn uwu() -> () {}
| ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= help: the trait `OnlySized<T>` is implemented for `()`
note: required for `()` to implement `OnlySized<[u8]>`
--> src/main.rs:6:9
|
6 | impl<T> OnlySized<T> for () {}
| ^^^^^^^^^^^^ ^^
note: required by a bound in `LetsGo::uwu::{opaque#0}`
--> src/main.rs:9:22
|
9 | fn uwu() -> impl OnlySized<[u8]>;
| ^^^^^^^^^^^^^^^ required by this bound in `LetsGo::uwu::{opaque#0}`
The problem here is that (): OnlySized<T> where T: Sized
, but [u8]: !Sized
, therefore (): !OnlySized<[u8]>
The doesn't have a size known at compile-time
pointing at ()
is quite confusing, since (): Sized
.
Also the {opaque#0}
name from the desugaring can be improved as well.