Skip to content

Commit 040a811

Browse files
committed
Rollup merge of rust-lang#22884 - japaric:obsolete, r=alexcrichton
This is leftover from rust-lang#21843 If you still have `|&:| {}` closures in your code, simply remove the `&:` part. [breaking-change]
2 parents 37760c1 + 7ad2e22 commit 040a811

File tree

7 files changed

+24
-7
lines changed

7 files changed

+24
-7
lines changed

src/doc/reference.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3765,9 +3765,9 @@ An example of creating and calling a closure:
37653765
```rust
37663766
let captured_var = 10;
37673767

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

3770-
let closure_args = |&: arg: i32| -> i32 {
3770+
let closure_args = |arg: i32| -> i32 {
37713771
println!("captured_var={}, arg={}", captured_var, arg);
37723772
arg // Note lack of semicolon after 'arg'
37733773
};

src/librustc/middle/const_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
257257
}
258258
}
259259
(Ok(const_int(a)), Ok(const_int(b))) => {
260-
let is_a_min_value = |&:| {
260+
let is_a_min_value = || {
261261
let int_ty = match ty::expr_ty_opt(tcx, e).map(|ty| &ty.sty) {
262262
Some(&ty::ty_int(int_ty)) => int_ty,
263263
_ => return false

src/librustc_typeck/check/dropck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
4545
scope: region::CodeExtent,
4646
depth: uint)
4747
{
48-
let origin = |&:| infer::SubregionOrigin::SafeDestructor(span);
48+
let origin = || infer::SubregionOrigin::SafeDestructor(span);
4949
let mut walker = ty_root.walk();
5050
let opt_phantom_data_def_id = rcx.tcx().lang_items.phantom_data();
5151

src/libstd/sys/unix/process2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl Process {
274274
// file descriptor. Otherwise, the first file descriptor opened
275275
// up in the child would be numbered as one of the stdio file
276276
// descriptors, which is likely to wreak havoc.
277-
let setup = |&: src: Option<AnonPipe>, dst: c_int| {
277+
let setup = |src: Option<AnonPipe>, dst: c_int| {
278278
let src = match src {
279279
None => {
280280
let flags = if dst == libc::STDIN_FILENO {

src/libstd/sys/windows/process2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl Process {
160160
// Similarly to unix, we don't actually leave holes for the stdio file
161161
// descriptors, but rather open up /dev/null equivalents. These
162162
// equivalents are drawn from libuv's windows process spawning.
163-
let set_fd = |&: fd: &Option<AnonPipe>, slot: &mut HANDLE,
163+
let set_fd = |fd: &Option<AnonPipe>, slot: &mut HANDLE,
164164
is_stdin: bool| {
165165
match *fd {
166166
None => {

src/libsyntax/parse/parser.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,6 @@ impl<'a> Parser<'a> {
11631163
{
11641164
self.bump();
11651165
self.bump();
1166-
return;
11671166
} else if
11681167
self.eat(&token::Colon)
11691168
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that we generate obsolete syntax errors around usages of closure kinds: `|:|`, `|&:|` and
12+
// `|&mut:|`.
13+
14+
fn main() {
15+
let a = |:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
16+
let a = |&:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
17+
let a = |&mut:| {}; //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
18+
}

0 commit comments

Comments
 (0)