Revert "remove alias analysis and replace with borrowck"
18s perf regression compiling rustc with opts
This reverts commit 7f6ee0ce0d.
This commit is contained in:
parent
c058f1d992
commit
7ef825bb60
51 changed files with 1134 additions and 31 deletions
|
|
@ -1,3 +1,6 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
|
||||
type point = { x: int, y: int };
|
||||
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
|
||||
type point = { x: int, y: int };
|
||||
|
||||
fn a() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
|
||||
fn take(-_v: ~int) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
// xfail-pretty -- comments are infaithfully preserved
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
// xfail-pretty -- comments are infaithfully preserved
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// xfail-fast (compile-flags unsupported on windows)
|
||||
// compile-flags:--borrowck=err
|
||||
|
||||
fn borrow(_v: &int) {}
|
||||
|
||||
fn local() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
8
src/test/compile-fail/unsafe-alias-2.rs
Normal file
8
src/test/compile-fail/unsafe-alias-2.rs
Normal 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); } }
|
||||
}
|
||||
10
src/test/compile-fail/unsafe-alias.rs
Normal file
10
src/test/compile-fail/unsafe-alias.rs
Normal 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));
|
||||
}
|
||||
8
src/test/compile-fail/unsafe-alt.rs
Normal file
8
src/test/compile-fail/unsafe-alt.rs
Normal 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); } _ { } }
|
||||
}
|
||||
8
src/test/compile-fail/unsafe-mutable-alias.rs
Normal file
8
src/test/compile-fail/unsafe-mutable-alias.rs
Normal 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)); }
|
||||
Loading…
Add table
Add a link
Reference in a new issue