]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/default-method-supertrait-vtable.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / test / run-pass / default-method-supertrait-vtable.rs
CommitLineData
223e47cc
LB
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
1a4d82fc 10//
1a4d82fc
JJ
11
12
13// Tests that we can call a function bounded over a supertrait from
14// a default method
223e47cc 15
c34b1796 16fn require_y<T: Y>(x: T) -> isize { x.y() }
1a4d82fc
JJ
17
18trait Y {
c34b1796 19 fn y(self) -> isize;
1a4d82fc 20}
223e47cc 21
223e47cc 22
1a4d82fc 23trait Z: Y + Sized {
c34b1796 24 fn x(self) -> isize {
1a4d82fc
JJ
25 require_y(self)
26 }
27}
28
c34b1796
AL
29impl Y for isize {
30 fn y(self) -> isize { self }
1a4d82fc
JJ
31}
32
c34b1796 33impl Z for isize {}
970d7e83 34
1a4d82fc
JJ
35pub fn main() {
36 assert_eq!(12.x(), 12);
223e47cc 37}