Rebasing changes

This commit is contained in:
Nick Cameron 2014-12-26 11:01:16 +13:00
parent dbde7419cc
commit 4b92a5a229
9 changed files with 30 additions and 39 deletions

View File

@ -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) {

View File

@ -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<middle::resolve::GlobMap>,
pub glob_map: Option<GlobMap>,
}
#[deriving(Copy, PartialEq, Eq, Hash)]
@ -6286,6 +6286,10 @@ pub type CaptureModeMap = NodeMap<ast::CaptureClause>;
// Trait method resolution
pub type TraitMap = NodeMap<Vec<DefId>>;
// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = HashMap<NodeId, HashSet<Name>>;
pub fn with_freevars<T, F>(tcx: &ty::ctxt, fid: ast::NodeId, f: F) -> T where
F: FnOnce(&[Freevar]) -> T,
{

View File

@ -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));

View File

@ -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<Resolver<'b, 'tcx>> for UnusedImportCheckVisitor<'a, 'b, 'tcx:'b> {
impl<'a, 'b, 'tcx:'b> Deref<Resolver<'b, 'tcx>> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> {
&*self.resolver
}
}
impl<'a, 'b, 'tcx> DerefMut<Resolver<'b, 'tcx>> for UnusedImportCheckVisitor<'a, 'b, 'tcx:'b> {
impl<'a, 'b, 'tcx:'b> DerefMut<Resolver<'b, 'tcx>> 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

View File

@ -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<Name, BindingInfo>;
// Map from the NodeId of a glob import to a list of items which are actually
// imported.
pub type GlobMap = HashMap<NodeId, HashSet<Name>>;
#[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,

View File

@ -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<Resolver<'b>> for ExportRecorder<'a, 'b> {
fn deref<'c>(&'c self) -> &'c Resolver<'b> {
impl<'a, 'b, 'tcx:'b> Deref<Resolver<'b, 'tcx>> for ExportRecorder<'a, 'b, 'tcx> {
fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> {
&*self.resolver
}
}
impl<'a, 'b> DerefMut<Resolver<'b>> for ExportRecorder<'a, 'b> {
fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b> {
impl<'a, 'b, 'tcx:'b> DerefMut<Resolver<'b, 'tcx>> 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<Module>) {
// If this isn't a local krate, then bail out. We don't need to record

View File

@ -534,13 +534,12 @@ pub unsafe fn from_c_multistring<F>(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 {

View File

@ -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 {

View File

@ -1121,8 +1121,10 @@ fn prefix_len(p: Option<PathPrefix>) -> 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;