Skip to content

Commit f765759

Browse files
committed
Add tests.
1 parent ead3edb commit f765759

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
fn main() {
12+
let x = 1i;
13+
proc() { x = 2; };
14+
//~^ ERROR: cannot assign to immutable captured outer variable in a proc `x`
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 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+
#![forbid(unused_mut)]
12+
13+
fn main() {
14+
let mut x = 1i;
15+
//~^ ERROR: variable does not need to be mutable
16+
proc() { println!("{}", x); };
17+
}

src/test/run-pass/issue-11958.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 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+
#![forbid(warnings)]
12+
13+
// Pretty printing tests complain about `use std::predule::*`
14+
#![allow(unused_imports)]
15+
16+
// We shouldn't need to rebind a moved upvar as mut if it's already
17+
// marked as mut
18+
19+
pub fn main() {
20+
let mut x = 1i;
21+
proc() { x = 2; };
22+
}

0 commit comments

Comments
 (0)