@@ -23,7 +23,6 @@ use Namespace::{TypeNS, ValueNS};
23
23
use rustc:: lint;
24
24
use rustc:: middle:: privacy:: { DependsOn , LastImport , Used , Unused } ;
25
25
use syntax:: ast;
26
- use syntax:: ast:: { ViewItem , ViewItemExternCrate , ViewItemUse } ;
27
26
use syntax:: ast:: { ViewPathGlob , ViewPathList , ViewPathSimple } ;
28
27
use syntax:: codemap:: { Span , DUMMY_SP } ;
29
28
use syntax:: visit:: { mod, Visitor } ;
@@ -105,53 +104,54 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
105
104
}
106
105
107
106
impl < ' a , ' b , ' v , ' tcx > Visitor < ' v > for UnusedImportCheckVisitor < ' a , ' b , ' tcx > {
108
- fn visit_view_item ( & mut self , vi : & ViewItem ) {
107
+ fn visit_item ( & mut self , item : & ast :: Item ) {
109
108
// Ignore is_public import statements because there's no way to be sure
110
109
// whether they're used or not. Also ignore imports with a dummy span
111
110
// because this means that they were generated in some fashion by the
112
111
// compiler and we don't need to consider them.
113
- if vi . vis == ast:: Public || vi . span == DUMMY_SP {
114
- visit:: walk_view_item ( self , vi ) ;
112
+ if item . vis == ast:: Public || item . span == DUMMY_SP {
113
+ visit:: walk_item ( self , item ) ;
115
114
return ;
116
115
}
117
116
118
- match vi . node {
119
- ViewItemExternCrate ( _ , _ , id ) => {
120
- if let Some ( crate_num) = self . session . cstore . find_extern_mod_stmt_cnum ( id) {
117
+ match item . node {
118
+ ast :: ItemExternCrate ( _ ) => {
119
+ if let Some ( crate_num) = self . session . cstore . find_extern_mod_stmt_cnum ( item . id ) {
121
120
if !self . used_crates . contains ( & crate_num) {
122
121
self . session . add_lint ( lint:: builtin:: UNUSED_EXTERN_CRATES ,
123
- id,
124
- vi . span ,
122
+ item . id ,
123
+ item . span ,
125
124
"unused extern crate" . to_string ( ) ) ;
126
125
}
127
126
}
128
127
} ,
129
- ViewItemUse ( ref p) => {
128
+ ast :: ItemUse ( ref p) => {
130
129
match p. node {
131
- ViewPathSimple ( _, _, id ) => {
132
- self . finalize_import ( id, p. span )
130
+ ViewPathSimple ( _, _) => {
131
+ self . finalize_import ( item . id , p. span )
133
132
}
134
133
135
- ViewPathList ( _, ref list, _ ) => {
134
+ ViewPathList ( _, ref list) => {
136
135
for i in list. iter ( ) {
137
136
self . finalize_import ( i. node . id ( ) , i. span ) ;
138
137
}
139
138
}
140
- ViewPathGlob ( _, id ) => {
141
- if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
142
- !self . used_imports . contains ( & ( id, ValueNS ) ) {
139
+ ViewPathGlob ( _) => {
140
+ if !self . used_imports . contains ( & ( item . id , TypeNS ) ) &&
141
+ !self . used_imports . contains ( & ( item . id , ValueNS ) ) {
143
142
self . session
144
143
. add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
145
- id,
144
+ item . id ,
146
145
p. span ,
147
146
"unused import" . to_string ( ) ) ;
148
147
}
149
148
}
150
149
}
151
150
}
151
+ _ => { }
152
152
}
153
153
154
- visit:: walk_view_item ( self , vi ) ;
154
+ visit:: walk_item ( self , item ) ;
155
155
}
156
156
}
157
157
0 commit comments