Closed
Description
While reading the object safety code I found this:
ty::StaticExplicitSelfCategory => {
// Static methods are always object-safe since they
// can't be called through a trait object
return msgs
}
I think this is sadly incorrect. The whole idea of object safety is to ensure that an object type Foo
implements the trait Foo
. But if that is the case, then we can have an example like this one:
trait Foo for Sized? {
fn make() -> Self; // static method
}
fn use<Sized? F:Foo>() {
let x = Foo::make();
}
fn main() {
use::<Foo>();
}
cc @nick29581
cc @aturon
Metadata
Metadata
Assignees
Labels
No labels