]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-inherent-non-conflict.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / impl-inherent-non-conflict.rs
CommitLineData
416331ca 1// run-pass
b039eaaf 2// Ensure that a user-defined type admits multiple inherent methods
c34b1796
AL
3// with the same name, which can be called on values that have a
4// precise enough type to allow distinguishing between the methods.
5
c34b1796
AL
6
7struct Foo<T>(T);
8
9impl Foo<usize> {
10 fn bar(&self) -> i32 { self.0 as i32 }
11}
12
13impl Foo<isize> {
14 fn bar(&self) -> i32 { -(self.0 as i32) }
15}
16
17fn main() {
18 let foo_u = Foo::<usize>(5);
19 assert_eq!(foo_u.bar(), 5);
20
21 let foo_i = Foo::<isize>(3);
22 assert_eq!(foo_i.bar(), -3);
23}