about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-11-06 17:34:33 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-11-06 21:51:40 -0500
commitf2aaed8338d80afccd2159d9c819d8d0f300cb55 (patch)
tree12bd4214839b3f780154483f18a4fa86facf2151 /src/libcore
parente84e7a00ddec76570bbaa9afea385d544f616814 (diff)
downloadrust-f2aaed8338d80afccd2159d9c819d8d0f300cb55.tar.gz
rust-f2aaed8338d80afccd2159d9c819d8d0f300cb55.zip
libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.
Fixes #18621.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/ops.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index ac735492be4..2631d0d4423 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -805,6 +805,16 @@ pub trait Deref<Sized? Result> {
     fn deref<'a>(&'a self) -> &'a Result;
 }
 
+#[cfg(not(stage0))]
+impl<'a, Sized? T> Deref<T> for &'a T {
+    fn deref(&self) -> &T { *self }
+}
+
+#[cfg(not(stage0))]
+impl<'a, Sized? T> Deref<T> for &'a mut T {
+    fn deref(&self) -> &T { *self }
+}
+
 /**
  *
  * The `DerefMut` trait is used to specify the functionality of dereferencing
@@ -845,6 +855,11 @@ pub trait DerefMut<Sized? Result>: Deref<Result> {
     fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
 }
 
+#[cfg(not(stage0))]
+impl<'a, Sized? T> DerefMut<T> for &'a mut T {
+    fn deref_mut(&mut self) -> &mut T { *self }
+}
+
 /// A version of the call operator that takes an immutable receiver.
 #[lang="fn"]
 pub trait Fn<Args,Result> {