Skip to content

Commit 50e1896

Browse files
committed
rustc_resolve: fix fallout of merging ast::ViewItem into ast::Item.
1 parent cce9399 commit 50e1896

File tree

2 files changed

+161
-179
lines changed

2 files changed

+161
-179
lines changed

src/librustc_resolve/check_unused.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use Namespace::{TypeNS, ValueNS};
2323
use rustc::lint;
2424
use rustc::middle::privacy::{DependsOn, LastImport, Used, Unused};
2525
use syntax::ast;
26-
use syntax::ast::{ViewItem, ViewItemExternCrate, ViewItemUse};
2726
use syntax::ast::{ViewPathGlob, ViewPathList, ViewPathSimple};
2827
use syntax::codemap::{Span, DUMMY_SP};
2928
use syntax::visit::{mod, Visitor};
@@ -105,53 +104,54 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
105104
}
106105

107106
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) {
109108
// Ignore is_public import statements because there's no way to be sure
110109
// whether they're used or not. Also ignore imports with a dummy span
111110
// because this means that they were generated in some fashion by the
112111
// 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);
115114
return;
116115
}
117116

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) {
121120
if !self.used_crates.contains(&crate_num) {
122121
self.session.add_lint(lint::builtin::UNUSED_EXTERN_CRATES,
123-
id,
124-
vi.span,
122+
item.id,
123+
item.span,
125124
"unused extern crate".to_string());
126125
}
127126
}
128127
},
129-
ViewItemUse(ref p) => {
128+
ast::ItemUse(ref p) => {
130129
match p.node {
131-
ViewPathSimple(_, _, id) => {
132-
self.finalize_import(id, p.span)
130+
ViewPathSimple(_, _) => {
131+
self.finalize_import(item.id, p.span)
133132
}
134133

135-
ViewPathList(_, ref list, _) => {
134+
ViewPathList(_, ref list) => {
136135
for i in list.iter() {
137136
self.finalize_import(i.node.id(), i.span);
138137
}
139138
}
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)) {
143142
self.session
144143
.add_lint(lint::builtin::UNUSED_IMPORTS,
145-
id,
144+
item.id,
146145
p.span,
147146
"unused import".to_string());
148147
}
149148
}
150149
}
151150
}
151+
_ => {}
152152
}
153153

154-
visit::walk_view_item(self, vi);
154+
visit::walk_item(self, item);
155155
}
156156
}
157157

0 commit comments

Comments
 (0)