typeck: boxed closures can't capture by value
closes #19141 closes #20193 closes #20228
This commit is contained in:
parent
c43efee6de
commit
5b0c8acd69
7 changed files with 96 additions and 3 deletions
|
|
@ -11,6 +11,6 @@
|
|||
pub fn main() {
|
||||
let bar = box 3;
|
||||
let _g = || {
|
||||
let _h = move|| -> int { *bar }; //~ ERROR cannot move out of captured outer variable
|
||||
let _h = move |:| -> int { *bar }; //~ ERROR cannot move out of captured outer variable
|
||||
};
|
||||
}
|
||||
|
|
|
|||
15
src/test/compile-fail/issue-19141.rs
Normal file
15
src/test/compile-fail/issue-19141.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let n = 0u;
|
||||
|
||||
let f = move || n += 1; //~error boxed closures can't capture by value
|
||||
}
|
||||
24
src/test/compile-fail/issue-20193.rs
Normal file
24
src/test/compile-fail/issue-20193.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo(t: &mut int){
|
||||
println!("{}", t);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let test = 10;
|
||||
|
||||
let h = move || { //~error boxed closures can't capture by value
|
||||
let mut r = &mut test.clone();
|
||||
foo(r);
|
||||
};
|
||||
|
||||
h();
|
||||
}
|
||||
20
src/test/compile-fail/issue-20228-1.rs
Normal file
20
src/test/compile-fail/issue-20228-1.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
fn foo(&self) {
|
||||
let _ = move || { self }; //~error boxed closures can't capture by value
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
20
src/test/compile-fail/issue-20228-2.rs
Normal file
20
src/test/compile-fail/issue-20228-2.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
fn foo(&self) {
|
||||
let _ = move || { self.foo() }; //~error boxed closures can't capture by value
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue