Skip to content

Commit

Permalink
Fix test case harder (cc rust-lang#9629)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Dec 10, 2013
1 parent 1252947 commit 76d9a96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/librustc/middle/borrowck/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/borrowck-borrow-of-mut-base-ptr-safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
2 changes: 1 addition & 1 deletion src/test/run-pass/borrowck-freeze-frozen-mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

1 comment on commit 76d9a96

@nikomatsakis
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=pnkfelix

Please sign in to comment.