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