Closed
Description
trait A {
fn foo(&self, _x: &Self);
}
impl A for () {
fn foo(&self, _x: &Self) {}
}
fn main() {
let _x: &A;
}
This code passes, while the codes like let x = &() as &A;
cause compile error because the trait A
is not object-safe. 0255-object-safety
Is there any reason for type &A
to exist? If not, the declaration of variables of type &A
should be invalid.