Rebasing changes
This commit is contained in:
parent
dbde7419cc
commit
4b92a5a229
9 changed files with 30 additions and 39 deletions
|
@ -3330,10 +3330,10 @@ mod tests {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod bench {
|
mod bench {
|
||||||
|
use super::*;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
use test::black_box;
|
use test::black_box;
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn char_iterator(b: &mut Bencher) {
|
fn char_iterator(b: &mut Bencher) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ use std::mem;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use collections::enum_set::{EnumSet, CLike};
|
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 std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
use syntax::ast::{CrateNum, DefId, DUMMY_NODE_ID, Ident, ItemTrait, LOCAL_CRATE};
|
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 ty_cx: ty::ctxt<'tcx>,
|
||||||
pub reachable: NodeSet,
|
pub reachable: NodeSet,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub glob_map: Option<middle::resolve::GlobMap>,
|
pub glob_map: Option<GlobMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Copy, PartialEq, Eq, Hash)]
|
#[deriving(Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -6286,6 +6286,10 @@ pub type CaptureModeMap = NodeMap<ast::CaptureClause>;
|
||||||
// Trait method resolution
|
// Trait method resolution
|
||||||
pub type TraitMap = NodeMap<Vec<DefId>>;
|
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
|
pub fn with_freevars<T, F>(tcx: &ty::ctxt, fid: ast::NodeId, f: F) -> T where
|
||||||
F: FnOnce(&[Freevar]) -> T,
|
F: FnOnce(&[Freevar]) -> T,
|
||||||
{
|
{
|
||||||
|
|
|
@ -343,10 +343,11 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
||||||
middle::lang_items::collect_language_items(krate, &sess));
|
middle::lang_items::collect_language_items(krate, &sess));
|
||||||
|
|
||||||
let make_glob_map = if save_analysis(&sess) {
|
let make_glob_map = if save_analysis(&sess) {
|
||||||
middle::resolve::MakeGlobMap::Yes
|
resolve::MakeGlobMap::Yes
|
||||||
} else {
|
} else {
|
||||||
middle::resolve::MakeGlobMap::No
|
resolve::MakeGlobMap::No
|
||||||
};
|
};
|
||||||
|
let resolve::CrateMap {
|
||||||
def_map,
|
def_map,
|
||||||
freevars,
|
freevars,
|
||||||
capture_mode_map,
|
capture_mode_map,
|
||||||
|
@ -358,6 +359,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
||||||
} =
|
} =
|
||||||
time(time_passes, "resolution", (),
|
time(time_passes, "resolution", (),
|
||||||
|_| resolve::resolve_crate(&sess,
|
|_| resolve::resolve_crate(&sess,
|
||||||
|
&ast_map,
|
||||||
&lang_items,
|
&lang_items,
|
||||||
krate,
|
krate,
|
||||||
make_glob_map));
|
make_glob_map));
|
||||||
|
|
|
@ -33,19 +33,19 @@ struct UnusedImportCheckVisitor<'a, 'b:'a, 'tcx:'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deref and DerefMut impls allow treating UnusedImportCheckVisitor as Resolver.
|
// 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> {
|
fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> {
|
||||||
&*self.resolver
|
&*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> {
|
fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b, 'tcx> {
|
||||||
&mut *self.resolver
|
&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.
|
// 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
|
// 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
|
// for a single namespace, we remove the other namespace from the recorded privacy
|
||||||
|
|
|
@ -55,7 +55,7 @@ use rustc::middle::lang_items::LanguageItems;
|
||||||
use rustc::middle::pat_util::pat_bindings;
|
use rustc::middle::pat_util::pat_bindings;
|
||||||
use rustc::middle::privacy::*;
|
use rustc::middle::privacy::*;
|
||||||
use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace};
|
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::nodemap::{NodeMap, NodeSet, DefIdSet, FnvHashMap};
|
||||||
use rustc::util::lev_distance::lev_distance;
|
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::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics};
|
||||||
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemFn};
|
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemFn};
|
||||||
use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic};
|
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::{MethodImplItem, Mod, Name, NamedField, NodeId};
|
||||||
use syntax::ast::{Pat, PatEnum, PatIdent, PatLit};
|
use syntax::ast::{Pat, PatEnum, PatIdent, PatLit};
|
||||||
use syntax::ast::{PatRange, PatStruct, Path, PathListIdent, PathListMod};
|
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.
|
// Map from the name in a pattern to its binding mode.
|
||||||
type BindingMap = HashMap<Name, BindingInfo>;
|
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)]
|
#[deriving(Copy, PartialEq)]
|
||||||
enum PatternBindingMode {
|
enum PatternBindingMode {
|
||||||
RefutableMode,
|
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)]
|
#[deriving(PartialEq)]
|
||||||
enum FallbackChecks {
|
enum FallbackChecks {
|
||||||
Everything,
|
Everything,
|
||||||
|
|
|
@ -27,24 +27,24 @@ use syntax::parse::token;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
struct ExportRecorder<'a, 'b:'a> {
|
struct ExportRecorder<'a, 'b:'a, 'tcx:'b> {
|
||||||
resolver: &'a mut Resolver<'b>
|
resolver: &'a mut Resolver<'b, 'tcx>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deref and DerefMut impls allow treating ExportRecorder as Resolver.
|
// Deref and DerefMut impls allow treating ExportRecorder as Resolver.
|
||||||
impl<'a, 'b> Deref<Resolver<'b>> for ExportRecorder<'a, 'b> {
|
impl<'a, 'b, 'tcx:'b> Deref<Resolver<'b, 'tcx>> for ExportRecorder<'a, 'b, 'tcx> {
|
||||||
fn deref<'c>(&'c self) -> &'c Resolver<'b> {
|
fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> {
|
||||||
&*self.resolver
|
&*self.resolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> DerefMut<Resolver<'b>> for ExportRecorder<'a, '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> {
|
fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b, 'tcx> {
|
||||||
&mut *self.resolver
|
&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,
|
fn record_exports_for_module_subtree(&mut self,
|
||||||
module_: Rc<Module>) {
|
module_: Rc<Module>) {
|
||||||
// If this isn't a local krate, then bail out. We don't need to record
|
// If this isn't a local krate, then bail out. We don't need to record
|
||||||
|
|
|
@ -534,13 +534,12 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use ptr;
|
use ptr;
|
||||||
use thread::Thread;
|
use thread::Thread;
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_str_multistring_parsing() {
|
fn test_str_multistring_parsing() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -448,7 +448,9 @@ static dot_dot_static: &'static [u8] = b"..";
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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;
|
use str;
|
||||||
|
|
||||||
macro_rules! t {
|
macro_rules! t {
|
||||||
|
|
|
@ -1121,8 +1121,10 @@ fn prefix_len(p: Option<PathPrefix>) -> uint {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use mem;
|
|
||||||
use super::*;
|
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::PathPrefix::*;
|
||||||
use super::parse_prefix;
|
use super::parse_prefix;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue