Skip to content

Commit

Permalink
Rollup merge of rust-lang#22884 - japaric:obsolete, r=alexcrichton
Browse files Browse the repository at this point in the history
 This is leftover from rust-lang#21843

If you still have `|&:| {}` closures in your code, simply remove the `&:` part.

[breaking-change]
  • Loading branch information
Manishearth committed Feb 28, 2015
2 parents 37760c1 + 7ad2e22 commit 040a811
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3765,9 +3765,9 @@ An example of creating and calling a closure:
```rust
let captured_var = 10;

let closure_no_args = |&:| println!("captured_var={}", captured_var);
let closure_no_args = || println!("captured_var={}", captured_var);

let closure_args = |&: arg: i32| -> i32 {
let closure_args = |arg: i32| -> i32 {
println!("captured_var={}, arg={}", captured_var, arg);
arg // Note lack of semicolon after 'arg'
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
}
}
(Ok(const_int(a)), Ok(const_int(b))) => {
let is_a_min_value = |&:| {
let is_a_min_value = || {
let int_ty = match ty::expr_ty_opt(tcx, e).map(|ty| &ty.sty) {
Some(&ty::ty_int(int_ty)) => int_ty,
_ => return false
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
scope: region::CodeExtent,
depth: uint)
{
let origin = |&:| infer::SubregionOrigin::SafeDestructor(span);
let origin = || infer::SubregionOrigin::SafeDestructor(span);
let mut walker = ty_root.walk();
let opt_phantom_data_def_id = rcx.tcx().lang_items.phantom_data();

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/process2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl Process {
// file descriptor. Otherwise, the first file descriptor opened
// up in the child would be numbered as one of the stdio file
// descriptors, which is likely to wreak havoc.
let setup = |&: src: Option<AnonPipe>, dst: c_int| {
let setup = |src: Option<AnonPipe>, dst: c_int| {
let src = match src {
None => {
let flags = if dst == libc::STDIN_FILENO {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/process2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Process {
// Similarly to unix, we don't actually leave holes for the stdio file
// descriptors, but rather open up /dev/null equivalents. These
// equivalents are drawn from libuv's windows process spawning.
let set_fd = |&: fd: &Option<AnonPipe>, slot: &mut HANDLE,
let set_fd = |fd: &Option<AnonPipe>, slot: &mut HANDLE,
is_stdin: bool| {
match *fd {
None => {
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,6 @@ impl<'a> Parser<'a> {
{
self.bump();
self.bump();
return;
} else if
self.eat(&token::Colon)
{
Expand Down
18 changes: 18 additions & 0 deletions src/test/parse-fail/obsolete-closure-kind.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2015 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.

// Test that we generate obsolete syntax errors around usages of closure kinds: `|:|`, `|&:|` and
// `|&mut:|`.

fn main() {
let a = |:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
let a = |&:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
let a = |&mut:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
}

0 comments on commit 040a811

Please sign in to comment.