rust/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
455 B
Rust
Raw Normal View History

#![allow(unused, bare_trait_objects)]
2020-10-16 15:46:59 -05: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);
}
}
fn foo(x: dyn Foo) { //~ ERROR [E0277]
2020-10-16 15:46:59 -05:00
x.foo()
}
fn bar(x: Foo) { //~ ERROR [E0277]
x.foo()
}
fn qux(_: [()]) {} //~ ERROR [E0277]
2020-10-16 15:46:59 -05:00
fn main() {
let x: Box<dyn Foo> = Box::new(A { v: 22 });
foo(*x); //~ ERROR [E0277]
2020-10-16 15:46:59 -05:00
}