Issue #2591: Change "upvar" to "variable declared in an outer block" in tests
This commit is contained in:
parent
68670f631c
commit
b6ed1de29e
7 changed files with 9 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
// error-pattern:moving out of immutable upvar
|
// error-pattern:moving out of immutable variable declared in an outer block
|
||||||
fn force(f: fn()) { f(); }
|
fn force(f: fn()) { f(); }
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = @{x: 17, y: 2};
|
let mut x = @{x: 17, y: 2};
|
||||||
|
|
|
@ -63,7 +63,7 @@ fn loop_in_block() {
|
||||||
let mut v = ~3, w = ~4;
|
let mut v = ~3, w = ~4;
|
||||||
let mut _x = &mut w;
|
let mut _x = &mut w;
|
||||||
for uint::range(0u, 10u) {|_i|
|
for uint::range(0u, 10u) {|_i|
|
||||||
borrow(v); //! ERROR loan of mutable upvar as immutable conflicts with prior loan
|
borrow(v); //! ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ fn at_most_once_block() {
|
||||||
let mut v = ~3, w = ~4;
|
let mut v = ~3, w = ~4;
|
||||||
let mut _x = &mut w;
|
let mut _x = &mut w;
|
||||||
at_most_once {||
|
at_most_once {||
|
||||||
borrow(v); //! ERROR loan of mutable upvar as immutable conflicts with prior loan
|
borrow(v); //! ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn borrow(v: &int, f: fn(x: &int)) {
|
||||||
fn box_imm() {
|
fn box_imm() {
|
||||||
let mut v = ~3;
|
let mut v = ~3;
|
||||||
borrow(v) { |w| //! NOTE loan of mutable local variable granted here
|
borrow(v) { |w| //! NOTE loan of mutable local variable granted here
|
||||||
v = ~4; //! ERROR assigning to mutable upvar prohibited due to outstanding loan
|
v = ~4; //! ERROR assigning to mutable variable declared in an outer block prohibited due to outstanding loan
|
||||||
assert *v == 3;
|
assert *v == 3;
|
||||||
assert *w == 4;
|
assert *w == 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 5;
|
let x = 5;
|
||||||
let _y = fn~(move x) -> int {
|
let _y = fn~(move x) -> int {
|
||||||
let _z = fn~(move x) -> int { x }; //! ERROR moving out of upvar
|
let _z = fn~(move x) -> int { x }; //! ERROR moving out of variable declared in an outer block
|
||||||
22
|
22
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// error-pattern:moving out of immutable upvar
|
// error-pattern:moving out of immutable variable declared in an outer block
|
||||||
fn test(-x: uint) {}
|
fn test(-x: uint) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = 3u;
|
let i = 3u;
|
||||||
for uint::range(0u, 10u) {|_x| test(i)}
|
for uint::range(0u, 10u) {|_x| test(i)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// error-pattern:assigning to immutable upvar
|
// error-pattern:assigning to immutable variable declared in an outer block
|
||||||
// Make sure that nesting a block within a fn@ doesn't let us
|
// Make sure that nesting a block within a fn@ doesn't let us
|
||||||
// mutate upvars from a fn@.
|
// mutate upvars from a fn@.
|
||||||
fn f2(x: fn()) { x(); }
|
fn f2(x: fn()) { x(); }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// error-pattern:assigning to upvar
|
// error-pattern:assigning to variable declared in an outer block
|
||||||
// Make sure we can't write to upvars from fn@s
|
// Make sure we can't write to upvars from fn@s
|
||||||
fn main() {
|
fn main() {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue