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.
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.
11 #![deny(unused_imports)]
14 use bar::c::cc as cal;
16 use std::mem::*; // shouldn't get errors for not using
17 // everything imported
19 //~^ ERROR unused import: `use std::fmt::{};`
21 // Should get errors for both 'Some' and 'None'
22 use std::option::Option::{Some, None};
23 //~^ ERROR unused imports: `None`, `Some`
24 //~| ERROR unused imports: `None`, `Some`
26 use test::A; //~ ERROR unused import: `test::A`
27 // Be sure that if we just bring some methods into scope that they're also
28 // counted as being used.
30 // But only when actually used: do not get confused by the method with the same name.
31 use test::B2; //~ ERROR unused import: `test::B2`
33 // Make sure this import is warned about when at least one of its imported names
35 use test2::{foo, bar}; //~ ERROR unused import: `bar`
43 pub trait A { fn a(&self) {} }
44 pub trait B { fn b(&self) {} }
45 pub trait B2 { fn b(&self) {} }
52 pub struct Point{pub x: isize, pub y: isize}
53 pub struct Square{pub p: Point, pub h: usize, pub w: usize}
57 // Don't ignore on 'pub use' because we're not sure if it's used or not
58 pub use std::cmp::PartialEq;
63 use foo::Square; //~ ERROR unused import: `foo::Square`
64 pub fn cc(_p: Point) -> super::Square {
65 fn f() -> super::Square {
72 #[allow(unused_imports)]
74 use std::cmp::PartialEq;
79 use self::g; //~ ERROR unused import: `self::g`
86 #[allow(unused_variables)]
88 use test2::foo; //~ ERROR unused import: `test2::foo`
93 cal(foo::Point{x:3, y:9});