diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc/middle/borrowck/doc.rs index 3bc725c355d34..f95547ea933d6 100644 --- a/src/librustc/middle/borrowck/doc.rs +++ b/src/librustc/middle/borrowck/doc.rs @@ -215,6 +215,24 @@ of this rule: there are comments in the borrowck source referencing 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 diff --git a/src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs b/src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs index c36917cafc90d..b7aa2989ac582 100644 --- a/src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs +++ b/src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs @@ -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() { } diff --git a/src/test/run-pass/borrowck-freeze-frozen-mut.rs b/src/test/run-pass/borrowck-freeze-frozen-mut.rs index 6aa95b1356e28..77e1a258dec84 100644 --- a/src/test/run-pass/borrowck-freeze-frozen-mut.rs +++ b/src/test/run-pass/borrowck-freeze-frozen-mut.rs @@ -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); }