]> git.proxmox.com Git - rustc.git/blame - src/test/ui/associated-types/associated-types-constant-type.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / associated-types / associated-types-constant-type.rs
CommitLineData
b7449926 1// run-pass
c34b1796 2
1a4d82fc
JJ
3trait SignedUnsigned {
4 type Opposite;
5 fn convert(self) -> Self::Opposite;
6}
7
c34b1796
AL
8impl SignedUnsigned for isize {
9 type Opposite = usize;
1a4d82fc 10
c34b1796
AL
11 fn convert(self) -> usize {
12 self as usize
1a4d82fc
JJ
13 }
14}
15
c34b1796
AL
16impl SignedUnsigned for usize {
17 type Opposite = isize;
1a4d82fc 18
c34b1796
AL
19 fn convert(self) -> isize {
20 self as isize
1a4d82fc
JJ
21 }
22}
23
c34b1796 24fn get(x: isize) -> <isize as SignedUnsigned>::Opposite {
1a4d82fc
JJ
25 x.convert()
26}
27
28fn main() {
29 let x = get(22);
c34b1796 30 assert_eq!(22, x);
1a4d82fc 31}