2014-02-05 16:33:10 -06:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#![deny(unused_variables)]
|
|
|
|
#![deny(unused_assignments)]
|
2014-03-21 20:05:05 -05:00
|
|
|
#![allow(dead_code, non_camel_case_types)]
|
2015-01-30 09:51:34 -06:00
|
|
|
#![feature(core)]
|
2015-01-22 20:22:03 -06:00
|
|
|
#![feature(os)]
|
2013-04-09 12:16:27 -05:00
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn f1(x: isize) {
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn f1b(x: &mut isize) {
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#[allow(unused_variables)]
|
2015-01-08 04:54:35 -06:00
|
|
|
fn f1c(x: isize) {}
|
2013-04-09 12:16:27 -05:00
|
|
|
|
2014-03-06 08:58:34 -06:00
|
|
|
fn f1d() {
|
2015-01-08 04:54:35 -06:00
|
|
|
let x: isize;
|
2014-03-06 08:58:34 -06:00
|
|
|
//~^ ERROR unused variable: `x`
|
|
|
|
}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn f2() {
|
2015-01-08 05:05:56 -06:00
|
|
|
let x = 3is;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f3() {
|
2015-01-08 05:05:56 -06:00
|
|
|
let mut x = 3is;
|
2013-04-09 12:16:27 -05:00
|
|
|
//~^ ERROR variable `x` is assigned to, but never used
|
2015-01-08 05:05:56 -06:00
|
|
|
x += 4is;
|
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() {
|
2015-01-08 05:05:56 -06:00
|
|
|
let mut z = 3is;
|
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 {
|
2015-01-08 05:05:56 -06:00
|
|
|
z += 4is;
|
2012-05-23 22:53:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#[allow(unused_variables)]
|
2013-04-09 12:16:27 -05:00
|
|
|
fn f3c() {
|
2015-01-08 05:05:56 -06:00
|
|
|
let mut z = 3is;
|
|
|
|
loop { z += 4is; }
|
2013-04-09 12:16:27 -05:00
|
|
|
}
|
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#[allow(unused_variables)]
|
|
|
|
#[allow(unused_assignments)]
|
2013-04-09 12:16:27 -05:00
|
|
|
fn f3d() {
|
2015-01-08 05:05:56 -06:00
|
|
|
let mut x = 3is;
|
|
|
|
x += 4is;
|
2013-04-09 12:16:27 -05:00
|
|
|
}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn f4() {
|
2015-01-08 05:05:56 -06:00
|
|
|
match Some(3is) {
|
2012-08-20 14:23:37 -05:00
|
|
|
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 {
|
2015-01-08 04:54:35 -06:00
|
|
|
a(isize), b(isize), c(isize)
|
2012-08-24 13:04:07 -05:00
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn f4b() -> isize {
|
2015-01-08 05:05:56 -06:00
|
|
|
match tri::a(3is) {
|
2014-11-06 02:05:53 -06:00
|
|
|
tri::a(i) | tri::b(i) | tri::c(i) => {
|
2012-08-24 13:04:07 -05:00
|
|
|
i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-15 15:07:00 -05:00
|
|
|
fn f5a() {
|
2015-01-26 14:46:12 -06:00
|
|
|
for x in 1is..10 { }
|
2014-09-15 15:07:00 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f5b() {
|
2015-01-08 05:05:56 -06:00
|
|
|
for (x, _) in [1is, 2, 3].iter().enumerate() { }
|
2014-09-15 15:07:00 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f5c() {
|
2015-01-08 05:05:56 -06:00
|
|
|
for (_, x) in [1is, 2, 3].iter().enumerate() {
|
2014-09-15 15:07:00 -05:00
|
|
|
//~^ ERROR unused variable: `x`
|
|
|
|
continue;
|
|
|
|
std::os::set_exit_status(*x); //~ WARNING unreachable statement
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 22:53:49 -05:00
|
|
|
fn main() {
|
|
|
|
}
|