libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.

Fixes #18621.
auto merge of #18714 : nikomatsakis/rust/issue-18621-deref-for-refs, r=aturon

libs: add Deref, DerefMut impls for references, fixing a bug in compiler in the process that was blocking this.

r? @aturon