rust/tests/ui/traits/inheritance/visibility.rs

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

21 lines
377 B
Rust
Raw Normal View History

// run-pass
mod traits {
pub trait Foo { fn f(&self) -> isize; }
impl Foo for isize { fn f(&self) -> isize { 10 } }
}
trait Quux: traits::Foo { }
impl<T:traits::Foo> Quux for T { }
// Foo is not in scope but because Quux is we can still access
// Foo's methods on a Quux bound typaram
fn f<T:Quux>(x: &T) {
assert_eq!(x.f(), 10);
}
pub fn main() {
2015-01-25 15:05:03 -06:00
f(&0)
}