2022-12-15 02:51:55 +00:00
|
|
|
#![allow(unused, bare_trait_objects)]
|
2020-10-16 20:46:59 +00:00
|
|
|
#[repr(align(256))]
|
|
|
|
struct A {
|
|
|
|
v: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Foo {
|
|
|
|
fn foo(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for A {
|
|
|
|
fn foo(&self) {
|
|
|
|
assert_eq!(self as *const A as usize % 256, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-15 02:51:55 +00:00
|
|
|
fn foo(x: dyn Foo) { //~ ERROR [E0277]
|
2020-10-16 20:46:59 +00:00
|
|
|
x.foo()
|
|
|
|
}
|
|
|
|
|
2022-12-15 02:51:55 +00:00
|
|
|
fn bar(x: Foo) { //~ ERROR [E0277]
|
|
|
|
x.foo()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn qux(_: [()]) {} //~ ERROR [E0277]
|
|
|
|
|
2020-10-16 20:46:59 +00:00
|
|
|
fn main() {
|
|
|
|
let x: Box<dyn Foo> = Box::new(A { v: 22 });
|
2022-12-15 02:51:55 +00:00
|
|
|
foo(*x); //~ ERROR [E0277]
|
2020-10-16 20:46:59 +00:00
|
|
|
}
|