@@ -62,13 +62,7 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
62
62
debug ! ( "finalizing import uses for {:?}" ,
63
63
self . session. codemap( ) . span_to_snippet( span) ) ;
64
64
65
- if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
66
- !self . used_imports . contains ( & ( id, ValueNS ) ) {
67
- self . session . add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
68
- id,
69
- span,
70
- "unused import" . to_string ( ) ) ;
71
- }
65
+ self . check_import ( id, span) ;
72
66
73
67
let mut def_map = self . def_map . borrow_mut ( ) ;
74
68
let path_res = if let Some ( r) = def_map. get_mut ( & id) {
@@ -109,6 +103,16 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
109
103
type_used : t_used,
110
104
} ;
111
105
}
106
+
107
+ fn check_import ( & self , id : ast:: NodeId , span : Span ) {
108
+ if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
109
+ !self . used_imports . contains ( & ( id, ValueNS ) ) {
110
+ self . session . add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
111
+ id,
112
+ span,
113
+ "unused import" . to_string ( ) ) ;
114
+ }
115
+ }
112
116
}
113
117
114
118
impl < ' a , ' b , ' v , ' tcx > Visitor < ' v > for UnusedImportCheckVisitor < ' a , ' b , ' tcx > {
@@ -144,14 +148,7 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
144
148
}
145
149
}
146
150
ViewPathGlob ( _) => {
147
- if !self . used_imports . contains ( & ( item. id , TypeNS ) ) &&
148
- !self . used_imports . contains ( & ( item. id , ValueNS ) ) {
149
- self . session
150
- . add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
151
- item. id ,
152
- p. span ,
153
- "unused import" . to_string ( ) ) ;
154
- }
151
+ self . check_import ( item. id , p. span ) ;
155
152
}
156
153
}
157
154
}
0 commit comments