Revert "remove alias analysis and replace with borrowck"

18s perf regression compiling rustc with opts

This reverts commit 7f6ee0ce0d.
This commit is contained in:
Brian Anderson 2012-06-07 19:42:22 -07:00
parent c058f1d992
commit 7ef825bb60
51 changed files with 1134 additions and 31 deletions

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
type point = { x: int, y: int };
fn a() {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
type point = { x: int, y: int };
fn a() {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(_v: &int) {}
fn borrow_from_arg_imm_ref(&&v: ~int) {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
// Note: the borrowck analysis is currently flow-insensitive.
// Therefore, some of these errors are marked as spurious and could be
// corrected by a simple change to the analysis. The others are

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(v: &int, f: fn(x: &int)) {
f(v);
}

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn take(-_v: ~int) {
}

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(v: &int, f: fn(x: &int)) {
f(v);
}

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
type point = { x: int, y: int };
impl foo for point {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
type point = { x: int, y: int };
impl foo for point {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
// Here we check that it is allowed to lend out an element of a
// (locally rooted) mutable, unique vector, and that we then prevent
// modifications to the contents.

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn want_slice(v: [int]/&) -> int {
let mut sum = 0;
for vec::each(v) { |i| sum += i; }

View file

@ -1,13 +0,0 @@
enum cycle {
node({mut a: ~cycle}),
empty
}
fn main() {
let x = ~node({mut a: ~empty});
// Create a cycle!
alt check *x { //! NOTE loan of immutable local variable granted here
node(y) {
y.a <- x; //! ERROR moving out of immutable local variable prohibited due to outstanding loan
}
};
}

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn match_imm_box(v: &const @option<int>) -> int {
alt *v {
@some(i) {i}

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn match_ref(&&v: option<int>) -> int {
alt v {
some(i) {

View file

@ -1,3 +1,5 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
// xfail-pretty -- comments are infaithfully preserved
fn main() {

View file

@ -1,3 +1,5 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
// xfail-pretty -- comments are infaithfully preserved
fn main() {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
pure fn pure_borrow(_x: &int, _y: ()) {}
fn test1(x: @mut ~int) {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn impure(_i: int) {}
// check that unchecked alone does not override borrowck:

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(_v: &int) {}
fn box_mut(v: @mut ~int) {

View file

@ -1,3 +1,6 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(_v: &int) {}
fn local() {

View file

@ -1,3 +1,5 @@
// xfail-fast (compile-flags unsupported on windows)
// compile-flags:--borrowck=err
fn borrow(_v: &int) {}
fn box_mut(v: &mut ~int) {

View file

@ -8,6 +8,8 @@ fn f<T>(&o: option<T>) {
fn main() {
f::<int>(option::none);
//!^ ERROR taking mut reference to static item
//!^^ ERROR illegal borrow unless pure: creating mutable alias to aliasable, immutable memory
//!^^^ NOTE impure due to access to impure function
// Additional errors reported by borrowck:
//^^ ERROR illegal borrow unless pure: creating mutable alias to aliasable, immutable memory
//^^^ NOTE impure due to access to impure function
}

View file

@ -0,0 +1,8 @@
// error-pattern:invalidate reference x
fn whoknows(x: @mut {mut x: int}) { x.x = 10; }
fn main() {
let box = @mut {mut x: 1};
alt *box { x { whoknows(box); log(error, x); } }
}

View file

@ -0,0 +1,10 @@
// error-pattern:may alias with argument
fn foo(x: {mut x: int}, f: fn@()) { log(debug, x); }
fn whoknows(x: @mut {mut x: int}) { *x = {mut x: 10}; }
fn main() {
let box = @mut {mut x: 1};
foo(*box, bind whoknows(box));
}

View file

@ -0,0 +1,8 @@
// error-pattern:invalidate reference i
enum foo { left({mut x: int}), right(bool) }
fn main() {
let mut x = left({mut x: 10});
alt x { left(i) { x = right(false); copy x; log(debug, i); } _ { } }
}

View file

@ -0,0 +1,8 @@
// error-pattern:mut reference to a variable that roots another reference
fn f(a: {mut x: int}, &b: {mut x: int}) -> int {
b.x += 1;
ret a.x + b.x;
}
fn main() { let i = {mut x: 4}; log(debug, f(i, i)); }