]>
Commit | Line | Data |
---|---|---|
7453a54e SL |
1 | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // ignore-tidy-linelength | |
94b46f34 | 12 | // compile-flags:-Zprint-mono-items=eager |
7453a54e SL |
13 | |
14 | #![deny(dead_code)] | |
15 | #![crate_type="lib"] | |
16 | ||
17 | use std::ops::{Index, IndexMut, Add, Deref}; | |
18 | ||
19 | pub struct Indexable { | |
20 | data: [u8; 3] | |
21 | } | |
22 | ||
23 | impl Index<usize> for Indexable { | |
24 | type Output = u8; | |
25 | ||
94b46f34 | 26 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[0]::index[0] |
7453a54e SL |
27 | fn index(&self, index: usize) -> &Self::Output { |
28 | if index >= 3 { | |
29 | &self.data[0] | |
30 | } else { | |
31 | &self.data[index] | |
32 | } | |
33 | } | |
34 | } | |
35 | ||
36 | impl IndexMut<usize> for Indexable { | |
94b46f34 | 37 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[1]::index_mut[0] |
7453a54e SL |
38 | fn index_mut(&mut self, index: usize) -> &mut Self::Output { |
39 | if index >= 3 { | |
40 | &mut self.data[0] | |
41 | } else { | |
42 | &mut self.data[index] | |
43 | } | |
44 | } | |
45 | } | |
46 | ||
47 | ||
94b46f34 XL |
48 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[4]::eq[0] |
49 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[4]::ne[0] | |
7453a54e SL |
50 | #[derive(PartialEq)] |
51 | pub struct Equatable(u32); | |
52 | ||
53 | ||
54 | impl Add<u32> for Equatable { | |
55 | type Output = u32; | |
56 | ||
94b46f34 | 57 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[2]::add[0] |
7453a54e SL |
58 | fn add(self, rhs: u32) -> u32 { |
59 | self.0 + rhs | |
60 | } | |
61 | } | |
62 | ||
63 | impl Deref for Equatable { | |
64 | type Target = u32; | |
65 | ||
94b46f34 | 66 | //~ MONO_ITEM fn overloaded_operators::{{impl}}[3]::deref[0] |
7453a54e SL |
67 | fn deref(&self) -> &Self::Target { |
68 | &self.0 | |
69 | } | |
70 | } |