]> git.lizzy.rs Git - rust.git/blob - tests/ui/on-unimplemented/on-impl.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / on-unimplemented / on-impl.rs
1 // Test if the on_unimplemented message override works
2
3 #![feature(rustc_attrs)]
4
5
6 #[rustc_on_unimplemented = "invalid"]
7 trait Index<Idx: ?Sized> {
8     type Output: ?Sized;
9     fn index(&self, index: Idx) -> &Self::Output;
10 }
11
12 #[rustc_on_unimplemented = "a usize is required to index into a slice"]
13 impl Index<usize> for [i32] {
14     type Output = i32;
15     fn index(&self, index: usize) -> &i32 {
16         &self[index]
17     }
18 }
19
20
21 fn main() {
22     Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
23     //~^ ERROR E0277
24     //~| ERROR E0277
25     //~| ERROR E0277
26 }