diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index a207985e64c83..cba094d619e01 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -198,8 +198,9 @@ fn with_appropriate_checker(cx: Context, id: node_id, fn check_for_bare(cx: Context, fv: @freevar_entry) { cx.tcx.sess.span_err( fv.span, - "attempted dynamic environment capture"); - } + "can't capture dynamic environment in a fn item; \ + use the || { ... } closure form instead"); + } // same check is done in resolve.rs, but shouldn't be done let fty = ty::node_id_to_type(cx.tcx, id); match ty::get(fty).sty { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 06147894d4462..f8adb1bbb0a4d 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -3382,7 +3382,8 @@ impl Resolver { self.session.span_err( span, - "attempted dynamic environment-capture"); + "can't capture dynamic environment in a fn item; \ + use the || { ... } closure form instead"); } else { // This was an attempt to use a type parameter outside // its scope. @@ -3404,7 +3405,8 @@ impl Resolver { self.session.span_err( span, - "attempted dynamic environment-capture"); + "can't capture dynamic environment in a fn item; \ + use the || { ... } closure form instead"); } else { // This was an attempt to use a type parameter outside // its scope. diff --git a/src/test/compile-fail/bad-env-capture.rs b/src/test/compile-fail/bad-env-capture.rs index c1eb39c466aac..ac5a4c220a4a6 100644 --- a/src/test/compile-fail/bad-env-capture.rs +++ b/src/test/compile-fail/bad-env-capture.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: attempted dynamic environment-capture +// error-pattern: can't capture dynamic environment in a fn item; fn foo() { let x: int; fn bar() { log(debug, x); } diff --git a/src/test/compile-fail/bad-env-capture2.rs b/src/test/compile-fail/bad-env-capture2.rs index a6d4d71242b73..c97069acd9aee 100644 --- a/src/test/compile-fail/bad-env-capture2.rs +++ b/src/test/compile-fail/bad-env-capture2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: attempted dynamic environment-capture +// error-pattern: can't capture dynamic environment in a fn item; fn foo(x: int) { fn bar() { log(debug, x); } } diff --git a/src/test/compile-fail/bad-env-capture3.rs b/src/test/compile-fail/bad-env-capture3.rs index 9e26faf32e7c2..e3a6ac2cdfc4f 100644 --- a/src/test/compile-fail/bad-env-capture3.rs +++ b/src/test/compile-fail/bad-env-capture3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: attempted dynamic environment-capture +// error-pattern: can't capture dynamic environment in a fn item; fn foo(x: int) { fn mth() { fn bar() { log(debug, x); } diff --git a/src/test/compile-fail/capture1.rs b/src/test/compile-fail/capture1.rs index 290dc70888221..706edd0a112b8 100644 --- a/src/test/compile-fail/capture1.rs +++ b/src/test/compile-fail/capture1.rs @@ -10,7 +10,7 @@ // except according to those terms. -// error-pattern: attempted dynamic environment-capture +// error-pattern: can't capture dynamic environment in a fn item; fn main() { let bar: int = 5; diff --git a/src/test/compile-fail/issue-3021-b.rs b/src/test/compile-fail/issue-3021-b.rs index d3aec178c238a..641403fb85a14 100644 --- a/src/test/compile-fail/issue-3021-b.rs +++ b/src/test/compile-fail/issue-3021-b.rs @@ -18,7 +18,7 @@ fn siphash(k0 : u64) { impl siphash { pub fn reset(&mut self) { - self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture + self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR can't capture dynamic environment //~^ ERROR unresolved name `k0`. } } diff --git a/src/test/compile-fail/issue-3021-d.rs b/src/test/compile-fail/issue-3021-d.rs index c6b5d8c42d595..c5ee9e8bb90e1 100644 --- a/src/test/compile-fail/issue-3021-d.rs +++ b/src/test/compile-fail/issue-3021-d.rs @@ -30,9 +30,9 @@ fn siphash(k0 : u64, k1 : u64) -> siphash { impl siphash for SipState { fn reset(&self) { - self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture + self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR can't capture dynamic environment //~^ ERROR unresolved name `k0`. - self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR attempted dynamic environment-capture + self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR can't capture dynamic environment //~^ ERROR unresolved name `k1`. } fn result(&self) -> u64 { return mk_result(self); } diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index 0ca6173275cb2..56ade814db020 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -21,7 +21,7 @@ fn siphash(k0 : u64) -> SipHash { impl SipHash for SipState { fn reset(&self) { - self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture + self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR can't capture dynamic environment //~^ ERROR unresolved name `k0`. } }