@@ -51,16 +51,8 @@ impl<'a, 'b, 'tcx:'b> DerefMut for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
51
51
52
52
impl < ' a , ' b , ' tcx > UnusedImportCheckVisitor < ' a , ' b , ' tcx > {
53
53
// We have information about whether `use` (import) directives are actually
54
- // used now. If an import is not used at all, we signal a lint error. If an
55
- // import is only used for a single namespace, we remove the other namespace
56
- // from the recorded privacy information. That means in privacy.rs, we will
57
- // only check imports and namespaces which are used. In particular, this
58
- // means that if an import could name either a public or private item, we
59
- // will check the correct thing, dependent on how the import is used.
60
- fn finalize_import ( & mut self , id : ast:: NodeId , span : Span ) {
61
- debug ! ( "finalizing import uses for {:?}" ,
62
- self . session. codemap( ) . span_to_snippet( span) ) ;
63
-
54
+ // used now. If an import is not used at all, we signal a lint error.
55
+ fn check_import ( & mut self , id : ast:: NodeId , span : Span ) {
64
56
if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
65
57
!self . used_imports . contains ( & ( id, ValueNS ) ) {
66
58
self . session . add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
@@ -95,23 +87,16 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
95
87
hir:: ItemUse ( ref p) => {
96
88
match p. node {
97
89
ViewPathSimple ( _, _) => {
98
- self . finalize_import ( item. id , p. span )
90
+ self . check_import ( item. id , p. span )
99
91
}
100
92
101
93
ViewPathList ( _, ref list) => {
102
94
for i in list {
103
- self . finalize_import ( i. node . id ( ) , i. span ) ;
95
+ self . check_import ( i. node . id ( ) , i. span ) ;
104
96
}
105
97
}
106
98
ViewPathGlob ( _) => {
107
- if !self . used_imports . contains ( & ( item. id , TypeNS ) ) &&
108
- !self . used_imports . contains ( & ( item. id , ValueNS ) ) {
109
- self . session
110
- . add_lint ( lint:: builtin:: UNUSED_IMPORTS ,
111
- item. id ,
112
- p. span ,
113
- "unused import" . to_string ( ) ) ;
114
- }
99
+ self . check_import ( item. id , p. span )
115
100
}
116
101
}
117
102
}
0 commit comments