Skip to content

Commit 89d0400

Browse files
committed
auto merge of #8800 : fhahn/rust/ticket_5239, r=alexcrichton
I've added a test for the second example mentioned in #5239. The first example does not compile with a reasonable error message. Should I add a compile-fail test for that example as well? /rust/src/test/run-pass/issue-5239.rs:15:45: 15:51 error: binary operation + cannot be applied to type `&int` rust/src/test/run-pass/issue-5239.rs:15 let _f = |ref x: int| { x += 1}; ^~~~~~ error: aborting due to previous error
2 parents 26e925a + 8557219 commit 89d0400

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/test/compile-fail/issue-5239-1.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 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+
// Regression test for issue #5239
12+
13+
fn main() {
14+
let x: &fn(int) -> int = |ref x| { x += 1; }; //~ ERROR binary operation + cannot be applied to type `&int`
15+
}

src/test/run-pass/issue-5239-2.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 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+
// Regression test for issue #5239
12+
13+
fn main() {
14+
let _f: &fn(int) -> int = |ref x: int| { *x };
15+
let foo = 10;
16+
assert!(_f(foo) == 10);
17+
}

0 commit comments

Comments
 (0)