]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/coercion-generic-bad.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / coercion-generic-bad.rs
1 struct Struct {
2     person: &'static str
3 }
4
5 trait Trait<T> {
6     fn f(&self, x: T);
7 }
8
9 impl Trait<&'static str> for Struct {
10     fn f(&self, x: &'static str) {
11         println!("Hello, {}!", x);
12     }
13 }
14
15 fn main() {
16     let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
17     //~^ ERROR `Struct: Trait<isize>` is not satisfied
18     s.f(1);
19 }