Closed
Description
These all fail in slightly different ways:
pub trait Trig<T> {
pure fn sin(&self) -> T;
}
pub trait Angle<T>: Trig<T> {}
pub pure fn sin<A:Angle<R>, R>(theta: &A) -> R { theta.sin() }
fn foo<R, A:Angle<R>>(theta: A) -> R { sin(&theta) }
impl int: Trig<int> {
pure fn sin(&self) -> int { 10 }
}
impl int: Angle<int> {
}
fn main() {
assert foo(0) == 10;
}
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9:39: 9:42 error: mismatched types: expected `@Trig<'b>` but found `@Trig<'a>` (expected type parameter but found type parameter)
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9 fn foo<R, A:Angle<R>>(theta: A) -> R { sin(&theta) }
pub trait Trig<T> {
pure fn sin(&self) -> T;
}
pub trait Angle<T>: Trig<T> {}
pub pure fn sin<A:Angle<R>, R>(theta: &A) -> R { theta.sin() }
fn foo<A:Angle<R>, R>(theta: A) -> R { return sin(&theta); }
fn main() {
}
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9:46: 9:49 error: failed to find an implementation of trait @Angle<<V2>> for <V1>
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9 fn foo<A:Angle<R>, R>(theta: A) -> R { return sin(&theta); }
pub trait Trig<T> {
pure fn sin(&self) -> T;
}
pub trait Angle<T>: Trig<T> {}
pub pure fn sin<A:Angle<int>>(theta: &A) -> int { theta.sin() }
fn foo<A:Angle<int>>(theta: A) -> int { return sin(&theta); }
fn main() {
}
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9:47: 9:50 error: failed to find an implementation of trait @Angle<int> for <V1>
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9 fn foo<A:Angle<int>>(theta: A) -> int { return sin(&theta); }
pub trait Trig<T> {
pure fn sin(&self) -> T;
}
pub trait Angle<T>: Trig<T> {}
pub pure fn sin<A:Trig<R>, R>(theta: &A) -> R { theta.sin() }
fn foo<A:Angle<R>, R>(theta: A) -> R { sin(&theta) }
impl int: Trig<int> {
pure fn sin(&self) -> int { 10 }
}
impl int: Angle<int> {
}
fn main() {
assert foo(0) == 10;
}
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9:39: 9:52 error: mismatched types: expected `'b` but found `'a` (expected type parameter but found type parameter)
/home/brian/dev/rust/src/test/run-pass/trait-inheritance-typaram-order.rs:9 fn foo<A:Angle<R>, R>(theta: A) -> R { sin(&theta) }