rust/tests/ui/traits/coercion-generic-bad.rs

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

20 lines
357 B
Rust
Raw Normal View History

2013-12-27 05:38:28 +00:00
struct Struct {
person: &'static str
}
trait Trait<T> {
fn f(&self, x: T);
}
impl Trait<&'static str> for Struct {
fn f(&self, x: &'static str) {
println!("Hello, {}!", x);
}
}
fn main() {
2019-05-28 18:46:13 +00:00
let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
//~^ ERROR `Struct: Trait<isize>` is not satisfied
2013-12-27 05:38:28 +00:00
s.f(1);
}