libs: add Deref, DerefMut impls for references

libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.

r? @aturon 
May want to drop these changes to avoid some [rebasing pain](https://github.com/rust-lang/rust/pull/18698) later on.