]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
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 | ||
1a4d82fc JJ |
11 | #![deny(unused_imports)] |
12 | #![allow(dead_code)] | |
223e47cc | 13 | |
1a4d82fc | 14 | use bar::c::cc as cal; |
223e47cc | 15 | |
1a4d82fc JJ |
16 | use std::mem::*; // shouldn't get errors for not using |
17 | // everything imported | |
223e47cc LB |
18 | |
19 | // Should get errors for both 'Some' and 'None' | |
1a4d82fc JJ |
20 | use std::option::Option::{Some, None}; //~ ERROR unused import |
21 | //~^ ERROR unused import | |
223e47cc | 22 | |
1a4d82fc | 23 | use test::A; //~ ERROR unused import |
223e47cc LB |
24 | // Be sure that if we just bring some methods into scope that they're also |
25 | // counted as being used. | |
1a4d82fc | 26 | use test::B; |
223e47cc LB |
27 | |
28 | // Make sure this import is warned about when at least one of its imported names | |
29 | // is unused | |
1a4d82fc JJ |
30 | use test2::{foo, bar}; //~ ERROR unused import |
31 | ||
32 | mod test2 { | |
33 | pub fn foo() {} | |
34 | pub fn bar() {} | |
35 | } | |
36 | ||
37 | mod test { | |
38 | pub trait A { fn a(&self) {} } | |
39 | pub trait B { fn b(&self) {} } | |
40 | pub struct C; | |
41 | impl A for C {} | |
42 | impl B for C {} | |
43 | } | |
223e47cc LB |
44 | |
45 | mod foo { | |
1a4d82fc JJ |
46 | pub struct Point{pub x: isize, pub y: isize} |
47 | pub struct Square{pub p: Point, pub h: usize, pub w: usize} | |
223e47cc LB |
48 | } |
49 | ||
50 | mod bar { | |
51 | // Don't ignore on 'pub use' because we're not sure if it's used or not | |
1a4d82fc | 52 | pub use std::cmp::PartialEq; |
223e47cc LB |
53 | |
54 | pub mod c { | |
55 | use foo::Point; | |
56 | use foo::Square; //~ ERROR unused import | |
1a4d82fc | 57 | pub fn cc(p: Point) -> isize { return 2is * (p.x + p.y); } |
223e47cc LB |
58 | } |
59 | ||
60 | #[allow(unused_imports)] | |
61 | mod foo { | |
1a4d82fc | 62 | use std::cmp::PartialEq; |
223e47cc LB |
63 | } |
64 | } | |
65 | ||
66 | fn main() { | |
67 | cal(foo::Point{x:3, y:9}); | |
1a4d82fc JJ |
68 | let mut a = 3is; |
69 | let mut b = 4is; | |
70 | swap(&mut a, &mut b); | |
71 | test::C.b(); | |
72 | let _a = foo(); | |
223e47cc | 73 | } |