2013-07-19 20:42:11 -05:00
|
|
|
// xfail-test
|
|
|
|
// xfail'd because lint is messed up with the new visitor transition
|
|
|
|
|
2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-04-09 12:16:27 -05:00
|
|
|
#[deny(unused_variable)];
|
|
|
|
#[deny(dead_assignment)];
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn f1(x: int) {
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
2012-10-05 16:58:42 -05:00
|
|
|
fn f1b(x: &mut int) {
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
2013-04-09 12:16:27 -05:00
|
|
|
#[allow(unused_variable)]
|
|
|
|
fn f1c(x: int) {}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn f2() {
|
|
|
|
let x = 3;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f3() {
|
|
|
|
let mut x = 3;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR variable `x` is assigned to, but never used
|
2012-05-23 22:53:49 -05:00
|
|
|
x += 4;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR value assigned to `x` is never read
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f3b() {
|
|
|
|
let mut z = 3;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR variable `z` is assigned to, but never used
|
2012-05-23 22:53:49 -05:00
|
|
|
loop {
|
|
|
|
z += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-09 12:16:27 -05:00
|
|
|
#[allow(unused_variable)]
|
|
|
|
fn f3c() {
|
|
|
|
let mut z = 3;
|
|
|
|
loop { z += 4; }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused_variable)]
|
|
|
|
#[allow(dead_assignment)]
|
|
|
|
fn f3d() {
|
|
|
|
let mut x = 3;
|
|
|
|
x += 4;
|
|
|
|
}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn f4() {
|
2012-08-20 14:23:37 -05:00
|
|
|
match Some(3) {
|
|
|
|
Some(i) => {
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `i`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
2012-08-20 14:23:37 -05:00
|
|
|
None => {}
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 13:04:07 -05:00
|
|
|
enum tri {
|
|
|
|
a(int), b(int), c(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f4b() -> int {
|
|
|
|
match a(3) {
|
|
|
|
a(i) | b(i) | c(i) => {
|
|
|
|
i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn main() {
|
|
|
|
}
|