]> git.lizzy.rs Git - rust.git/commitdiff
add assertion and comment about mutability
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 18 Mar 2016 22:40:22 +0000 (18:40 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 18 Mar 2016 22:40:22 +0000 (18:40 -0400)
src/librustc_typeck/check/coercion.rs

index 164503980cd0b7d56f7d5d914af0363db8967ae5..bb27333025e072f52deacbacf7c75d2b81db1c9b 100644 (file)
@@ -367,6 +367,7 @@ fn coerce_borrowed_pointer<'a, E, I>(&self,
             // `self.x` both have `&mut `type would be a move of
             // `self.x`, but we auto-coerce it to `foo(&mut *self.x)`,
             // which is a borrow.
+            assert_eq!(mt_b.mutbl, hir::MutImmutable); // can only coerce &T -> &U
             return self.identity(ty);
         }
         let r_borrow = match ty.sty {