]> git.proxmox.com Git - rustc.git/blame - src/test/ui/on-unimplemented/multiple-impls.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / on-unimplemented / multiple-impls.rs
CommitLineData
a7813a04
XL
1// Test if the on_unimplemented message override works
2
60c5eb7d 3#![feature(rustc_attrs)]
a1dfa0c6 4
a7813a04
XL
5
6struct Foo<T>(T);
7struct Bar<T>(T);
8
9#[rustc_on_unimplemented = "trait message"]
10trait Index<Idx: ?Sized> {
11 type Output: ?Sized;
12 fn index(&self, index: Idx) -> &Self::Output;
13}
14
15#[rustc_on_unimplemented = "on impl for Foo"]
16impl Index<Foo<usize>> for [i32] {
17 type Output = i32;
18 fn index(&self, _index: Foo<usize>) -> &i32 {
19 loop {}
20 }
21}
22
23#[rustc_on_unimplemented = "on impl for Bar"]
24impl Index<Bar<usize>> for [i32] {
25 type Output = i32;
26 fn index(&self, _index: Bar<usize>) -> &i32 {
27 loop {}
28 }
29}
30
a1dfa0c6 31
a7813a04
XL
32fn main() {
33 Index::index(&[] as &[i32], 2u32);
34 //~^ ERROR E0277
041b39d2 35 //~| ERROR E0277
a7813a04
XL
36 Index::index(&[] as &[i32], Foo(2u32));
37 //~^ ERROR E0277
041b39d2 38 //~| ERROR E0277
a7813a04
XL
39 Index::index(&[] as &[i32], Bar(2u32));
40 //~^ ERROR E0277
041b39d2 41 //~| ERROR E0277
a7813a04 42}