Skip to content

Commit 76d9a96

Browse files
committed
Fix test case harder (cc #9629)
1 parent 1252947 commit 76d9a96

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/librustc/middle/borrowck/doc.rs

+18
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,24 @@ of this rule: there are comments in the borrowck source referencing
215215
these names, so that you can cross reference to find the actual code
216216
that corresponds to the formal rule.
217217
218+
### Invariants
219+
220+
I want to collect, at a high-level, the invariants the borrow checker
221+
maintains. I will give them names and refer to them throughout the
222+
text. Together these invariants are crucial for the overall soundness
223+
of the system.
224+
225+
**Mutability requires uniqueness.** To mutate a path
226+
227+
**Unique mutability.** There is only one *usable* mutable path to any
228+
given memory at any given time. This implies that when claiming memory
229+
with an expression like `p = &mut x`, the compiler must guarantee that
230+
the borrowed value `x` can no longer be mutated so long as `p` is
231+
live. (This is done via restrictions, read on.)
232+
233+
**.**
234+
235+
218236
### The `gather_loans` pass
219237
220238
We start with the `gather_loans` pass, which walks the AST looking for

src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ fn foo<'a>(mut t0: &'a mut int,
2121
let r: &int = &*t0; // ...after all, could do same thing directly.
2222
}
2323

24-
fn main() {
24+
pub fn main() {
2525
}

src/test/run-pass/borrowck-freeze-frozen-mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn main() {
3030
assert_eq!(*index1, 2);
3131
assert_eq!(*index2, 3);
3232
}
33-
assert_eq!(data[0], 1);
33+
assert_eq!(data[0], 5);
3434
assert_eq!(data[1], 2);
3535
assert_eq!(data[2], 3);
3636
}

0 commit comments

Comments
 (0)