2014-07-22 04:56:25 -05:00
|
|
|
// Test that Copy bounds inherited by trait are checked.
|
2019-01-08 15:14:04 -06:00
|
|
|
//
|
|
|
|
// revisions: curr object_safe_for_dispatch
|
2014-07-22 04:56:25 -05:00
|
|
|
|
2019-01-08 15:14:04 -06:00
|
|
|
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
2021-08-24 19:39:40 -05:00
|
|
|
|
2015-01-07 20:53:58 -06:00
|
|
|
|
2014-07-22 04:56:25 -05:00
|
|
|
use std::any::Any;
|
|
|
|
|
|
|
|
trait Foo : Copy {
|
2015-02-18 17:58:07 -06:00
|
|
|
fn foo(&self) {}
|
2014-07-22 04:56:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T:Copy> Foo for T {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_param<T:Foo>(foo: &T) { }
|
|
|
|
|
2014-12-14 06:17:23 -06:00
|
|
|
fn a() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let x: Box<_> = Box::new(3);
|
2019-01-08 15:14:04 -06:00
|
|
|
take_param(&x); //[curr]~ ERROR E0277
|
|
|
|
//[object_safe_for_dispatch]~^ ERROR E0277
|
2014-12-14 06:17:23 -06:00
|
|
|
}
|
2014-07-22 04:56:25 -05:00
|
|
|
|
2014-12-14 06:17:23 -06:00
|
|
|
fn b() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let x: Box<_> = Box::new(3);
|
2014-07-22 04:56:25 -05:00
|
|
|
let y = &x;
|
2019-05-28 13:46:13 -05:00
|
|
|
let z = &x as &dyn Foo;
|
2019-01-08 15:14:04 -06:00
|
|
|
//[curr]~^ ERROR E0038
|
|
|
|
//[curr]~| ERROR E0038
|
|
|
|
//[object_safe_for_dispatch]~^^^ ERROR E0038
|
2014-07-22 04:56:25 -05:00
|
|
|
}
|
2014-12-14 06:17:23 -06:00
|
|
|
|
|
|
|
fn main() { }
|