Closed
Description
The error that you get when using a dyn
type with a fn that expects a Sized
type parameter is not particularly enlightening:
#![feature(dyn_trait)]
trait Something { }
impl Something for () { }
fn foo<T: Something>(_: &T) { }
fn main() {
let x: &dyn Something = &();
foo(x);
}
error[E0277]: the trait bound `Something: std::marker::Sized` is not satisfied
--> src/main.rs:10:5
|
10 | foo(x);
| ^^^ `Something` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `Something`
= note: required by `foo`
This came up when attempting to do some refactorings to use a dyn Trait
where previously we had used a type parameter. I'm not exactly sure what sort of error we should report here -- but it seems like it'd be nice to talk about the definition site.