rust/tests/ui/traits/vtable-res-trait-param.rs

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

24 lines
419 B
Rust
Raw Normal View History

trait TraitA {
fn method_a(&self) -> isize;
}
trait TraitB {
fn gimme_an_a<A:TraitA>(&self, a: A) -> isize;
}
impl TraitB for isize {
fn gimme_an_a<A:TraitA>(&self, a: A) -> isize {
2013-03-14 00:57:30 +00:00
a.method_a() + *self
}
}
fn call_it<B:TraitB>(b: B) -> isize {
let y = 4;
2016-07-28 16:49:31 +00:00
b.gimme_an_a(y) //~ ERROR `{integer}: TraitA` is not satisfied
}
fn main() {
2015-01-31 16:23:42 +00:00
let x = 3;
assert_eq!(call_it(x), 22);
}