]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/default-method/supervtable.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / traits / default-method / supervtable.rs
CommitLineData
b7449926 1// run-pass
1a4d82fc
JJ
2
3
4// Tests that we can call a function bounded over a supertrait from
5// a default method
223e47cc 6
c34b1796 7fn require_y<T: Y>(x: T) -> isize { x.y() }
1a4d82fc
JJ
8
9trait Y {
c34b1796 10 fn y(self) -> isize;
1a4d82fc 11}
223e47cc 12
223e47cc 13
1a4d82fc 14trait Z: Y + Sized {
c34b1796 15 fn x(self) -> isize {
1a4d82fc
JJ
16 require_y(self)
17 }
18}
19
c34b1796
AL
20impl Y for isize {
21 fn y(self) -> isize { self }
1a4d82fc
JJ
22}
23
c34b1796 24impl Z for isize {}
970d7e83 25
1a4d82fc
JJ
26pub fn main() {
27 assert_eq!(12.x(), 12);
223e47cc 28}