]> git.lizzy.rs Git - rust.git/commitdiff
Fix test case harder (cc #9629)
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 10 Dec 2013 17:08:22 +0000 (12:08 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 10 Dec 2013 18:14:45 +0000 (13:14 -0500)
src/librustc/middle/borrowck/doc.rs
src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs
src/test/run-pass/borrowck-freeze-frozen-mut.rs

index 3bc725c355d34b032ab32ca02757e9d6059fa5fc..f95547ea933d61b83dc32c0c4df10330d0fc2244 100644 (file)
@@ -215,6 +215,24 @@ struct defined in `middle::borrowck`. Formally, we define `LOAN` as
 these names, so that you can cross reference to find the actual code
 that corresponds to the formal rule.
 
+### Invariants
+
+I want to collect, at a high-level, the invariants the borrow checker
+maintains. I will give them names and refer to them throughout the
+text. Together these invariants are crucial for the overall soundness
+of the system.
+
+**Mutability requires uniqueness.** To mutate a path
+
+**Unique mutability.** There is only one *usable* mutable path to any
+given memory at any given time. This implies that when claiming memory
+with an expression like `p = &mut x`, the compiler must guarantee that
+the borrowed value `x` can no longer be mutated so long as `p` is
+live. (This is done via restrictions, read on.)
+
+**.**
+
+
 ### The `gather_loans` pass
 
 We start with the `gather_loans` pass, which walks the AST looking for
index c36917cafc90d3393cef135e0ce4adf70ca12fa0..b7aa2989ac5820466348e361385130bfb5a8ae98 100644 (file)
@@ -21,5 +21,5 @@ fn foo<'a>(mut t0: &'a mut int,
     let r: &int = &*t0; // ...after all, could do same thing directly.
 }
 
-fn main() {
+pub fn main() {
 }
index 6aa95b1356e2814ecf6122f5030c1bc4bf4234dc..77e1a258dec846184854be73e810a7a74d0d3273 100644 (file)
@@ -30,7 +30,7 @@ pub fn main() {
         assert_eq!(*index1, 2);
         assert_eq!(*index2, 3);
     }
-    assert_eq!(data[0], 1);
+    assert_eq!(data[0], 5);
     assert_eq!(data[1], 2);
     assert_eq!(data[2], 3);
 }