diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 10d3de6b131e..7a16b69b80c9 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1425,7 +1425,6 @@ pub impl Resolver { // Build up the import directives. let module_ = self.get_module_from_parent(parent); - let state = @mut ImportState(); match view_path.node { view_path_simple(binding, full_path, _, _) => { let source_ident = *full_path.idents.last(); @@ -1435,19 +1434,17 @@ pub impl Resolver { module_, module_path, subclass, - view_path.span, - state); + view_path.span); } view_path_list(_, ref source_idents, _) => { - for (*source_idents).each |source_ident| { + for source_idents.each |source_ident| { let name = source_ident.node.name; let subclass = @SingleImport(name, name); self.build_import_directive(privacy, module_, copy module_path, subclass, - view_path.span, - state); + source_ident.span); } } view_path_glob(_, _) => { @@ -1455,8 +1452,7 @@ pub impl Resolver { module_, module_path, @GlobImport, - view_path.span, - state); + view_path.span); } } } @@ -1842,8 +1838,7 @@ pub impl Resolver { module_: @mut Module, +module_path: ~[ident], subclass: @ImportDirectiveSubclass, - span: span, - state: @mut ImportState) { + span: span) { let directive = @ImportDirective(privacy, module_path, subclass, span); module_.imports.push(directive); @@ -1867,6 +1862,7 @@ pub impl Resolver { } None => { debug!("(building import directive) creating new"); + let state = @mut ImportState(); let resolution = @mut ImportResolution(privacy, span, state); diff --git a/src/test/compile-fail/unused-imports-warn.rs b/src/test/compile-fail/unused-imports-warn.rs index 7756f96b4703..6afb80fc192a 100644 --- a/src/test/compile-fail/unused-imports-warn.rs +++ b/src/test/compile-fail/unused-imports-warn.rs @@ -17,14 +17,19 @@ use core::either::Right; //~ ERROR unused import use core::util::*; // shouldn't get errors for not using // everything imported -// Should only get one error instead of two errors here +// Should get errors for both 'Some' and 'None' use core::option::{Some, None}; //~ ERROR unused import + //^~ ERROR unused import use core::io::ReaderUtil; //~ ERROR unused import // Be sure that if we just bring some methods into scope that they're also // counted as being used. use core::io::WriterUtil; +// Make sure this import is warned about when at least one of its imported names +// is unused +use core::vec::{filter, map}; //~ ERROR unused import + mod foo { pub struct Point{x: int, y: int} pub struct Square{p: Point, h: uint, w: uint} @@ -51,4 +56,7 @@ fn main() { let a = 3; ignore(a); io::stdout().write_str(~"a"); + let _a = do map(~[2]) |&x| { + x + 2 + }; }