Skip to content

Commit a9589ae

Browse files
committed
Rollup merge of rust-lang#32724 - sanxiyn:outdated-comment, r=dotdash
Remove outdated comment The corresponding code was removed in rust-lang#31824. Also remove code duplication and rename the function.
2 parents 12d58d6 + a09a3ac commit a9589ae

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/librustc_resolve/check_unused.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,8 @@ impl<'a, 'b, 'tcx:'b> DerefMut for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
5151

5252
impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
5353
// 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) {
6456
if !self.used_imports.contains(&(id, TypeNS)) &&
6557
!self.used_imports.contains(&(id, ValueNS)) {
6658
self.session.add_lint(lint::builtin::UNUSED_IMPORTS,
@@ -95,23 +87,16 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
9587
hir::ItemUse(ref p) => {
9688
match p.node {
9789
ViewPathSimple(_, _) => {
98-
self.finalize_import(item.id, p.span)
90+
self.check_import(item.id, p.span)
9991
}
10092

10193
ViewPathList(_, ref list) => {
10294
for i in list {
103-
self.finalize_import(i.node.id(), i.span);
95+
self.check_import(i.node.id(), i.span);
10496
}
10597
}
10698
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)
115100
}
116101
}
117102
}

0 commit comments

Comments
 (0)