rust/tests/ui/kindck/kindck-inherited-copy-bound.rs

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

35 lines
647 B
Rust
Raw Normal View History

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