]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/liveness-dead.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / test / compile-fail / liveness-dead.rs
1 // Copyright 2012 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 #![allow(dead_code)]
12 #![deny(unused_assignments)]
13
14 fn f1(x: &mut isize) {
15 *x = 1; // no error
16 }
17
18 fn f2() {
19 let mut x: isize = 3; //~ ERROR: value assigned to `x` is never read
20 x = 4;
21 x.clone();
22 }
23
24 fn f3() {
25 let mut x: isize = 3;
26 x.clone();
27 x = 4; //~ ERROR: value assigned to `x` is never read
28 }
29
30 fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read
31 x = 4;
32 x.clone();
33 }
34
35 fn f5(mut x: i32) {
36 x.clone();
37 x = 4; //~ ERROR: value assigned to `x` is never read
38 }
39
40 fn main() {}