summaryrefslogtreecommitdiffstats
path: root/src/test/ui/overloaded/overloaded-autoderef-indexing.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/overloaded/overloaded-autoderef-indexing.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/ui/overloaded/overloaded-autoderef-indexing.rs b/src/test/ui/overloaded/overloaded-autoderef-indexing.rs
new file mode 100644
index 000000000..1c8c7cca9
--- /dev/null
+++ b/src/test/ui/overloaded/overloaded-autoderef-indexing.rs
@@ -0,0 +1,20 @@
+// run-pass
+
+use std::ops::Deref;
+
+struct DerefArray<'a, T:'a> {
+ inner: &'a [T]
+}
+
+impl<'a, T> Deref for DerefArray<'a, T> {
+ type Target = &'a [T];
+
+ fn deref<'b>(&'b self) -> &'b &'a [T] {
+ &self.inner
+ }
+}
+
+pub fn main() {
+ let a = &[1, 2, 3];
+ assert_eq!(DerefArray {inner: a}[1], 2);
+}