rust/src/test/compile-fail/liveness-unused.rs

47 lines
758 B
Rust
Raw Normal View History

fn f1(x: int) {
//~^ WARNING unused variable: `x`
}
fn f1b(&x: int) {
//~^ WARNING unused variable: `x`
}
fn f2() {
let x = 3;
//~^ WARNING unused variable: `x`
}
fn f3() {
let mut x = 3;
//~^ WARNING variable `x` is assigned to, but never used
x += 4;
//~^ WARNING value assigned to `x` is never read
}
fn f3b() {
let mut z = 3;
//~^ WARNING variable `z` is assigned to, but never used
loop {
z += 4;
}
}
fn f4() {
alt some(3) {
2012-08-03 21:59:04 -05:00
some(i) => {
}
2012-08-03 21:59:04 -05:00
none => {}
}
}
// leave this in here just to trigger compile-fail:
class r {
let x: ();
new() { self.x = (); }
drop {}
}
fn main() {
let x = r();
fn@() { copy x; }; //~ ERROR copying a noncopyable value
}