diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 5feae5e558e..bccd2a1198a 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -3330,10 +3330,10 @@ mod tests { #[cfg(test)] mod bench { + use super::*; use prelude::*; use test::Bencher; use test::black_box; - use super::*; #[bench] fn char_iterator(b: &mut Bencher) { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 79e24ad56e4..c0d5d6b11cf 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -77,7 +77,7 @@ use std::mem; use std::ops; use std::rc::Rc; use collections::enum_set::{EnumSet, CLike}; -use std::collections::hash_map::HashMap; +use std::collections::{HashMap, HashSet}; use std::collections::hash_map::Entry::{Occupied, Vacant}; use syntax::abi; use syntax::ast::{CrateNum, DefId, DUMMY_NODE_ID, Ident, ItemTrait, LOCAL_CRATE}; @@ -105,7 +105,7 @@ pub struct CrateAnalysis<'tcx> { pub ty_cx: ty::ctxt<'tcx>, pub reachable: NodeSet, pub name: String, - pub glob_map: Option, + pub glob_map: Option, } #[deriving(Copy, PartialEq, Eq, Hash)] @@ -6286,6 +6286,10 @@ pub type CaptureModeMap = NodeMap; // Trait method resolution pub type TraitMap = NodeMap>; +// Map from the NodeId of a glob import to a list of items which are actually +// imported. +pub type GlobMap = HashMap>; + pub fn with_freevars(tcx: &ty::ctxt, fid: ast::NodeId, f: F) -> T where F: FnOnce(&[Freevar]) -> T, { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f132ede06a4..4ab5c19430b 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -343,10 +343,11 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, middle::lang_items::collect_language_items(krate, &sess)); let make_glob_map = if save_analysis(&sess) { - middle::resolve::MakeGlobMap::Yes + resolve::MakeGlobMap::Yes } else { - middle::resolve::MakeGlobMap::No + resolve::MakeGlobMap::No }; + let resolve::CrateMap { def_map, freevars, capture_mode_map, @@ -358,6 +359,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, } = time(time_passes, "resolution", (), |_| resolve::resolve_crate(&sess, + &ast_map, &lang_items, krate, make_glob_map)); diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index c09014cdb7a..78527315199 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -33,19 +33,19 @@ struct UnusedImportCheckVisitor<'a, 'b:'a, 'tcx:'b> { } // Deref and DerefMut impls allow treating UnusedImportCheckVisitor as Resolver. -impl<'a, 'b, 'tcx> Deref> for UnusedImportCheckVisitor<'a, 'b, 'tcx:'b> { +impl<'a, 'b, 'tcx:'b> Deref> for UnusedImportCheckVisitor<'a, 'b, 'tcx> { fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> { &*self.resolver } } -impl<'a, 'b, 'tcx> DerefMut> for UnusedImportCheckVisitor<'a, 'b, 'tcx:'b> { +impl<'a, 'b, 'tcx:'b> DerefMut> for UnusedImportCheckVisitor<'a, 'b, 'tcx> { fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b, 'tcx> { &mut *self.resolver } } -impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> { +impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> { // We have information about whether `use` (import) directives are actually used now. // If an import is not used at all, we signal a lint error. If an import is only used // for a single namespace, we remove the other namespace from the recorded privacy diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 03e992ef7a7..720883a8e9a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -55,7 +55,7 @@ use rustc::middle::lang_items::LanguageItems; use rustc::middle::pat_util::pat_bindings; use rustc::middle::privacy::*; use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace}; -use rustc::middle::ty::{CaptureModeMap, Freevar, FreevarMap, TraitMap}; +use rustc::middle::ty::{CaptureModeMap, Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, NodeSet, DefIdSet, FnvHashMap}; use rustc::util::lev_distance::lev_distance; @@ -66,7 +66,7 @@ use syntax::ast::{ExprPath, ExprStruct, FnDecl}; use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics}; use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemFn}; use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic}; -use syntax::ast::{ItemStruct, ItemTrait, ItemTy, Local}; +use syntax::ast::{ItemStruct, ItemTrait, ItemTy, Local, LOCAL_CRATE}; use syntax::ast::{MethodImplItem, Mod, Name, NamedField, NodeId}; use syntax::ast::{Pat, PatEnum, PatIdent, PatLit}; use syntax::ast::{PatRange, PatStruct, Path, PathListIdent, PathListMod}; @@ -110,10 +110,6 @@ struct BindingInfo { // Map from the name in a pattern to its binding mode. type BindingMap = HashMap; -// Map from the NodeId of a glob import to a list of items which are actually -// imported. -pub type GlobMap = HashMap>; - #[deriving(Copy, PartialEq)] enum PatternBindingMode { RefutableMode, @@ -970,20 +966,6 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { } -<<<<<<< HEAD:src/librustc_resolve/lib.rs -======= -struct UnusedImportCheckVisitor<'a, 'b:'a, 'tcx:'b> { - resolver: &'a mut Resolver<'b, 'tcx> -} - -impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> { - fn visit_view_item(&mut self, vi: &ViewItem) { - self.resolver.check_for_item_unused_imports(vi); - visit::walk_view_item(self, vi); - } -} - ->>>>>>> save-analysis: emit names of items that a glob import actually imports.:src/librustc/middle/resolve.rs #[deriving(PartialEq)] enum FallbackChecks { Everything, diff --git a/src/librustc_resolve/record_exports.rs b/src/librustc_resolve/record_exports.rs index 41882a94b34..80659152f9f 100644 --- a/src/librustc_resolve/record_exports.rs +++ b/src/librustc_resolve/record_exports.rs @@ -27,24 +27,24 @@ use syntax::parse::token; use std::rc::Rc; -struct ExportRecorder<'a, 'b:'a> { - resolver: &'a mut Resolver<'b> +struct ExportRecorder<'a, 'b:'a, 'tcx:'b> { + resolver: &'a mut Resolver<'b, 'tcx> } // Deref and DerefMut impls allow treating ExportRecorder as Resolver. -impl<'a, 'b> Deref> for ExportRecorder<'a, 'b> { - fn deref<'c>(&'c self) -> &'c Resolver<'b> { +impl<'a, 'b, 'tcx:'b> Deref> for ExportRecorder<'a, 'b, 'tcx> { + fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> { &*self.resolver } } -impl<'a, 'b> DerefMut> for ExportRecorder<'a, 'b> { - fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b> { +impl<'a, 'b, 'tcx:'b> DerefMut> for ExportRecorder<'a, 'b, 'tcx> { + fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b, 'tcx> { &mut *self.resolver } } -impl<'a, 'b> ExportRecorder<'a, 'b> { +impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> { fn record_exports_for_module_subtree(&mut self, module_: Rc) { // If this isn't a local krate, then bail out. We don't need to record diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index fb44961017f..fb369924c64 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -534,13 +534,12 @@ pub unsafe fn from_c_multistring(buf: *const libc::c_char, #[cfg(test)] mod tests { + use super::*; use prelude::*; use ptr; use thread::Thread; use libc; - use super::*; - #[test] fn test_str_multistring_parsing() { unsafe { diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index c72e41d61c0..d941665f048 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -448,7 +448,9 @@ static dot_dot_static: &'static [u8] = b".."; #[cfg(test)] mod tests { use super::*; - use prelude::*; + use prelude::Option::{mod, Some, None}; + use prelude::{Vec, Clone, AsSlice, SliceExt, CloneSliceExt, IteratorExt}; + use prelude::{DoubleEndedIteratorExt, Str, StrExt, ToString, GenericPath}; use str; macro_rules! t { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 278908b8068..12da1752adf 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1121,8 +1121,10 @@ fn prefix_len(p: Option) -> uint { #[cfg(test)] mod tests { - use mem; use super::*; + use prelude::Option::{mod, Some, None}; + use prelude::{Vec, Clone, AsSlice, SliceExt, CloneSliceExt, IteratorExt}; + use prelude::{DoubleEndedIteratorExt, Str, ToString, GenericPath}; use super::PathPrefix::*; use super::parse_prefix;