From 8364a6feefe730c1cf06e95d00406afbdf5938c2 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 12 Dec 2015 03:29:35 +0000 Subject: [PATCH 1/2] Remove unused imports --- src/compiletest/runtest.rs | 2 -- src/libcollections/btree/node.rs | 2 +- src/libcollections/string.rs | 2 +- src/libcollections/vec.rs | 2 +- src/libcore/slice.rs | 1 - src/librustc/lint/context.rs | 2 +- src/librustc/middle/infer/combine.rs | 1 - src/librustc/middle/infer/mod.rs | 5 ++--- src/librustc/middle/infer/region_inference/mod.rs | 2 +- src/librustc/middle/stability.rs | 2 +- src/librustc/middle/ty/mod.rs | 3 +-- src/librustc/util/ppaux.rs | 7 ++----- src/librustc_borrowck/borrowck/gather_loans/mod.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_metadata/tls_context.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 4 ++-- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/save/dump_csv.rs | 3 +-- src/librustc_trans/trans/closure.rs | 2 +- src/librustc_trans/trans/debuginfo/gdb.rs | 1 - src/librustc_trans/trans/intrinsic.rs | 4 +--- src/librustc_trans/trans/meth.rs | 1 - src/librustc_typeck/check/mod.rs | 3 +-- src/librustc_typeck/check/regionck.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 1 - src/librustc_typeck/coherence/orphan.rs | 1 - src/librustc_typeck/coherence/overlap.rs | 2 +- src/librustc_typeck/coherence/unsafety.rs | 1 - src/librustc_typeck/lib.rs | 1 - src/libstd/collections/hash/map.rs | 1 - src/libstd/collections/hash/set.rs | 1 - src/libstd/sys/unix/fs.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/ext/quote.rs | 4 ++-- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/parse/parser.rs | 6 +++--- src/libsyntax_ext/cfg.rs | 1 - src/libtest/lib.rs | 2 -- 42 files changed, 35 insertions(+), 59 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 1b1f5115b60..459b43b4ffe 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use self::TargetLocation::*; - use common::Config; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc}; diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index 26479b3f559..198025536f0 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -23,7 +23,7 @@ use core::marker::PhantomData; use core::ops::{Deref, DerefMut, Index, IndexMut}; use core::ptr::Unique; use core::{slice, mem, ptr, cmp}; -use alloc::heap::{self, EMPTY}; +use alloc::heap; use borrow::Borrow; diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 8c0b52f71f8..05a4075f500 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -23,7 +23,7 @@ use core::fmt; use core::hash; use core::iter::FromIterator; use core::mem; -use core::ops::{self, Deref, Add, Index}; +use core::ops::{self, Add}; use core::ptr; use core::slice; use core::str::pattern::Pattern; diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index ddad7533a08..ab8dee31ee3 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -68,7 +68,7 @@ use core::hash::{self, Hash}; use core::intrinsics::{arith_offset, assume, needs_drop}; use core::iter::FromIterator; use core::mem; -use core::ops::{Index, IndexMut, Deref}; +use core::ops::{Index, IndexMut}; use core::ops; use core::ptr; use core::slice; diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index b17fac4d771..635b296a645 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -48,7 +48,6 @@ use result::Result; use result::Result::{Ok, Err}; use ptr; use mem; -use mem::size_of; use marker::{Send, Sync, self}; use num::wrapping::OverflowingOps; use raw::Repr; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 1ed873f0508..d7ac096b407 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -26,7 +26,7 @@ use self::TargetLint::*; use middle::privacy::AccessLevels; -use middle::ty::{self, Ty}; +use middle::ty; use session::{early_error, Session}; use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass}; use lint::{EarlyLintPass, EarlyLintPassObject, LateLintPass, LateLintPassObject}; diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 03554a59655..2a25ed2c6e1 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -41,7 +41,6 @@ use super::{InferCtxt}; use super::{MiscVariable, TypeTrace}; use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf}; -use middle::ty::{TyVar}; use middle::ty::{IntType, UintType}; use middle::ty::{self, Ty}; use middle::ty::error::TypeError; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index d677328e415..119651f12e9 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -27,10 +27,9 @@ use middle::region::CodeExtent; use middle::subst; use middle::subst::Substs; use middle::subst::Subst; -use middle::traits::{self, FulfillmentContext, Normalized, - SelectionContext, ObligationCause}; +use middle::traits; use middle::ty::adjustment; -use middle::ty::{TyVid, IntVid, FloatVid, RegionVid}; +use middle::ty::{TyVid, IntVid, FloatVid}; use middle::ty::{self, Ty, HasTypeFlags}; use middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; use middle::ty::fold::{TypeFolder, TypeFoldable}; diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index e148aecd241..a63c662de61 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -24,7 +24,7 @@ use rustc_data_structures::graph::{self, Direction, NodeIndex}; use rustc_data_structures::unify::{self, UnificationTable}; use middle::free_region::FreeRegionMap; use middle::ty::{self, Ty}; -use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid}; +use middle::ty::{BoundRegion, Region, RegionVid}; use middle::ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound}; use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; use middle::ty::error::TypeError; diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 31158901775..8104d53fc93 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -29,7 +29,7 @@ use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods}; use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap}; use rustc_front::hir; -use rustc_front::hir::{Block, Crate, Item, Generics, StructField, Variant}; +use rustc_front::hir::{Crate, Item, Generics, StructField, Variant}; use rustc_front::intravisit::{self, Visitor}; use std::mem::replace; diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index 54fe1a9bc8e..20e98821ca3 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/middle/ty/mod.rs @@ -27,7 +27,7 @@ use middle::def::{self, ExportMap}; use middle::def_id::DefId; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; use middle::region::{CodeExtent}; -use middle::subst::{self, ParamSpace, Subst, Substs, VecPerParamSpace}; +use middle::subst::{self, Subst, Substs, VecPerParamSpace}; use middle::traits; use middle::ty; use middle::ty::fold::TypeFolder; @@ -52,7 +52,6 @@ use syntax::parse::token::{InternedString, special_idents}; use rustc_front::hir; use rustc_front::hir::{ItemImpl, ItemTrait}; -use rustc_front::hir::{MutImmutable, MutMutable, Visibility}; pub use self::sty::{Binder, DebruijnIndex}; pub use self::sty::{BuiltinBound, BuiltinBounds, ExistentialBounds}; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7b4347459e6..3c0a395f57c 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -11,16 +11,13 @@ use middle::def_id::DefId; use middle::subst::{self, Subst}; -use middle::ty::{BoundRegion, BrAnon, BrNamed}; -use middle::ty::{ReEarlyBound, BrFresh, ctxt}; -use middle::ty::{ReFree, ReScope, ReStatic, Region, ReEmpty}; -use middle::ty::{ReSkolemized, ReVar, BrEnv}; +use middle::ty::{BrAnon, BrEnv, BrFresh, BrNamed}; use middle::ty::{TyBool, TyChar, TyStruct, TyEnum}; use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn}; use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple}; use middle::ty::TyClosure; use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; -use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags}; +use middle::ty::{self, Ty, HasTypeFlags}; use middle::ty::fold::TypeFoldable; use std::fmt; diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index c07a27043c2..6f6ce67380b 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -29,7 +29,7 @@ use syntax::ast; use syntax::codemap::Span; use syntax::ast::NodeId; use rustc_front::hir; -use rustc_front::hir::{Expr, FnDecl, Block, Pat}; +use rustc_front::hir::Expr; use rustc_front::intravisit; use rustc_front::intravisit::Visitor; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 64bbf49e3a8..38ec728e9c1 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -38,7 +38,7 @@ use rustc::middle::ty::{self, Ty}; use std::fmt; use std::mem; use std::rc::Rc; -use syntax::ast::{self, NodeId}; +use syntax::ast; use syntax::codemap::Span; use rustc_front::hir; diff --git a/src/librustc_metadata/tls_context.rs b/src/librustc_metadata/tls_context.rs index e368ff3822a..eb82d2df94d 100644 --- a/src/librustc_metadata/tls_context.rs +++ b/src/librustc_metadata/tls_context.rs @@ -16,7 +16,7 @@ use rbml::reader::Decoder as RbmlDecoder; use rustc::middle::cstore::tls; use rustc::middle::def_id::DefId; use rustc::middle::subst::Substs; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty; use decoder::{self, Cmd}; use encoder; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9f70598198e..aee2ed81981 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -45,7 +45,7 @@ use rustc::middle::privacy::ImportUse::*; use rustc::middle::privacy::LastPrivate::*; use rustc::middle::privacy::PrivateDep::*; use rustc::middle::privacy::ExternalExports; -use rustc::middle::ty::{self, Ty}; +use rustc::middle::ty; use rustc::util::nodemap::NodeMap; use rustc::front::map as ast_map; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 8b5b6ff781e..0c0cf01e92b 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -38,12 +38,12 @@ use syntax::parse::token::special_idents; use syntax::codemap::{Span, DUMMY_SP}; use rustc_front::hir; -use rustc_front::hir::{Block, Crate, DeclItem}; +use rustc_front::hir::{Block, DeclItem}; use rustc_front::hir::{ForeignItem, ForeignItemFn, ForeignItemStatic}; use rustc_front::hir::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn}; use rustc_front::hir::{ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; -use rustc_front::hir::{NamedField, PathListIdent, PathListMod, Public}; +use rustc_front::hir::{NamedField, PathListIdent, PathListMod}; use rustc_front::hir::StmtDecl; use rustc_front::hir::UnnamedField; use rustc_front::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple}; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 4d5978f5560..b6f81e0fa83 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -64,7 +64,7 @@ use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, DefIdSet, FnvHashMap}; use syntax::ast; -use syntax::ast::{CRATE_NODE_ID, Ident, Name, NodeId, CrateNum, TyIs, TyI8, TyI16, TyI32, TyI64}; +use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, TyIs, TyI8, TyI16, TyI32, TyI64}; use syntax::ast::{TyUs, TyU8, TyU16, TyU32, TyU64, TyF64, TyF32}; use syntax::attr::AttrMetaMethods; use syntax::parse::token::{self, special_names, special_idents}; diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index b3e7ed7ed5e..34fb8977c48 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -34,10 +34,9 @@ use session::Session; use middle::def; use middle::def_id::DefId; -use middle::ty::{self, Ty}; +use middle::ty; use std::fs::File; -use std::path::Path; use syntax::ast::{self, NodeId}; use syntax::codemap::*; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index c125ba30a51..e089a6e059c 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -20,7 +20,7 @@ use trans::build::*; use trans::callee::{self, ArgVals, Callee, TraitItem, MethodData}; use trans::cleanup::{CleanupMethods, CustomScope, ScopeId}; use trans::common::*; -use trans::datum::{self, Datum, rvalue_scratch_datum, Rvalue, ByValue}; +use trans::datum::{self, Datum, rvalue_scratch_datum, Rvalue}; use trans::debuginfo::{self, DebugLoc}; use trans::declare; use trans::expr; diff --git a/src/librustc_trans/trans/debuginfo/gdb.rs b/src/librustc_trans/trans/debuginfo/gdb.rs index 03b58fb2c47..4e3fadd0fa9 100644 --- a/src/librustc_trans/trans/debuginfo/gdb.rs +++ b/src/librustc_trans/trans/debuginfo/gdb.rs @@ -11,7 +11,6 @@ // .debug_gdb_scripts binary section. use llvm; -use llvm::ValueRef; use trans::common::{C_bytes, CrateContext, C_i32}; use trans::declare; diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 27f5e31eaaf..66f53deffa9 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -14,7 +14,7 @@ use arena::TypedArena; use intrinsics::{self, Intrinsic}; use libc; use llvm; -use llvm::{SequentiallyConsistent, Acquire, Release, AtomicXchg, ValueRef, TypeKind}; +use llvm::{ValueRef, TypeKind}; use middle::infer; use middle::subst; use middle::subst::FnSpace; @@ -32,10 +32,8 @@ use trans::debuginfo::DebugLoc; use trans::declare; use trans::expr; use trans::glue; -use trans::type_of::*; use trans::type_of; use trans::machine; -use trans::machine::llsize_of; use trans::type_::Type; use middle::ty::{self, Ty, HasTypeFlags}; use middle::subst::Substs; diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 123bd9f9c37..049773f0bec 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -28,7 +28,6 @@ use trans::consts; use trans::datum::*; use trans::debuginfo::DebugLoc; use trans::declare; -use trans::expr::SaveIn; use trans::expr; use trans::glue; use trans::machine; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b4434a56fff..ca9046e65f7 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -93,7 +93,7 @@ use middle::pat_util::{self, pat_id_map}; use middle::privacy::{AllPublic, LastMod}; use middle::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace, TypeSpace}; use middle::traits::{self, report_fulfillment_errors}; -use middle::ty::{FnSig, GenericPredicates, TypeScheme}; +use middle::ty::{GenericPredicates, TypeScheme}; use middle::ty::{Disr, ParamTy, ParameterEnvironment}; use middle::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; use middle::ty::{self, HasTypeFlags, RegionEscape, ToPolyTraitRef, Ty}; @@ -127,7 +127,6 @@ use syntax::util::lev_distance::lev_distance; use rustc_front::intravisit::{self, Visitor}; use rustc_front::hir; use rustc_front::hir::Visibility; -use rustc_front::hir::{Item, ItemImpl}; use rustc_front::print::pprust; use rustc_back::slice; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 3ecb9468ef4..8777e38bb71 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -92,7 +92,7 @@ use middle::mem_categorization::Categorization; use middle::region::{self, CodeExtent}; use middle::subst::Substs; use middle::traits; -use middle::ty::{self, RegionEscape, ReScope, Ty, MethodCall, HasTypeFlags}; +use middle::ty::{self, RegionEscape, Ty, MethodCall, HasTypeFlags}; use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound}; use middle::pat_util; use middle::ty::adjustment; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index cdbfda40813..37bbfb4e967 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -40,7 +40,6 @@ use syntax::codemap::Span; use syntax::parse::token; use util::nodemap::{DefIdMap, FnvHashMap}; use rustc::front::map as hir_map; -use rustc::front::map::NodeItem; use rustc_front::intravisit; use rustc_front::hir::{Item, ItemImpl,Crate}; use rustc_front::hir; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index b436a5ee524..411e1a4e480 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -19,7 +19,6 @@ use syntax::ast; use syntax::codemap::Span; use rustc_front::intravisit; use rustc_front::hir; -use rustc_front::hir::{Item, ItemImpl}; pub fn check(tcx: &ty::ctxt) { let mut orphan = OrphanChecker { tcx: tcx }; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 90a3b99b71c..5cbe142ab19 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -15,7 +15,7 @@ use middle::cstore::{CrateStore, LOCAL_CRATE}; use middle::def_id::DefId; use middle::traits; use middle::ty; -use middle::infer::{self, new_infer_ctxt}; +use middle::infer; use syntax::ast; use syntax::codemap::Span; use rustc_front::hir; diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 40b38ad8839..936d26f9208 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -14,7 +14,6 @@ use middle::ty; use rustc_front::intravisit; use rustc_front::hir; -use rustc_front::hir::{Item, ItemImpl}; pub fn check(tcx: &ty::ctxt) { let mut orphan = UnsafetyChecker { tcx: tcx }; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 02c1f3973c6..da246eff7da 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -110,7 +110,6 @@ use util::common::time; use rustc_front::hir; use syntax::codemap::Span; -use syntax::print::pprust::*; use syntax::{ast, abi}; use std::cell::RefCell; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 38c080febf1..9ab440f289e 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -24,7 +24,6 @@ use mem::{self, replace}; use ops::{Deref, FnMut, FnOnce, Index}; use option::Option::{self, Some, None}; use rand::{self, Rng}; -use result::Result; use super::table::{ self, diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 08f356463bc..761709d41e7 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -13,7 +13,6 @@ use clone::Clone; use cmp::{Eq, PartialEq}; use core::marker::Sized; use default::Default; -use fmt::Debug; use fmt; use hash::Hash; use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain, Extend}; diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 8ea8f0c6c77..9ac11b442da 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -14,7 +14,7 @@ use os::unix::prelude::*; use ffi::{CString, CStr, OsString, OsStr}; use fmt; use io::{self, Error, ErrorKind, SeekFrom}; -use libc::{self, c_int, size_t, off_t, c_char, mode_t}; +use libc::{self, c_int, off_t, c_char, mode_t}; use mem; use path::{Path, PathBuf}; use ptr; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b56846327c3..de5595eebee 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -51,7 +51,7 @@ use abi::Abi; use ext::base; use ext::tt::macro_parser; use owned_slice::OwnedSlice; -use parse::token::{InternedString, str_to_ident}; +use parse::token::InternedString; use parse::token; use parse::lexer; use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index d511ce09a36..fcc7351deaa 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -24,7 +24,7 @@ use config::CfgDiag; use diagnostic::SpanHandler; use feature_gate::{GatedCfg, GatedCfgAttr}; use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration}; -use parse::token::{InternedString, intern_and_get_ident}; +use parse::token::InternedString; use parse::token; use ptr::P; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b1afe2bb69c..02d318e5b53 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{Block, Crate, DeclLocal, ExprMac, PatMac}; +use ast::{Block, Crate, DeclLocal, PatMac}; use ast::{Local, Ident, Mac_, Name}; use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac}; use ast::{StmtExpr, StmtSemi}; diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 496f6a429a3..0c3a8b05fba 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Path, Stmt, TokenTree, Ty}; +use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, TokenTree, Ty}; use codemap::Span; use ext::base::ExtCtxt; use ext::base; @@ -33,7 +33,7 @@ pub mod rt { use ptr::P; use std::rc::Rc; - use ast::{TokenTree, Expr}; + use ast::TokenTree; pub use parse::new_parser_from_tts; pub use codemap::{BytePos, Span, dummy_spanned, DUMMY_SP}; diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 16764e5af5c..fb09118035c 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -85,7 +85,7 @@ use codemap; use parse::lexer::*; //resolve bug? use parse::ParseSess; use parse::parser::{LifetimeAndTypesWithoutColons, Parser}; -use parse::token::{Eof, DocComment, MatchNt, SubstNt}; +use parse::token::{DocComment, MatchNt, SubstNt}; use parse::token::{Token, Nonterminal}; use parse::token; use print::pprust; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index ba781ae3cc2..d5993c81f24 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -14,7 +14,7 @@ use ast::{TokenTree, Ident, Name}; use codemap::{Span, DUMMY_SP}; use diagnostic::SpanHandler; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; -use parse::token::{Eof, DocComment, Interpolated, MatchNt, SubstNt}; +use parse::token::{DocComment, MatchNt, SubstNt}; use parse::token::{Token, NtIdent, SpecialMacroVar}; use parse::token; use parse::lexer::TokenAndSpan; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9398f1a5733..712f4e38012 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -28,12 +28,12 @@ use ast::{ExprLit, ExprLoop, ExprMac, ExprRange}; use ast::{ExprMethodCall, ExprParen, ExprPath}; use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary}; use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl}; -use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod, FunctionRetTy}; +use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, FunctionRetTy}; use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic}; use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst}; use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl}; use ast::{ItemExternCrate, ItemUse}; -use ast::{LifetimeDef, Lit, Lit_}; +use ast::{Lit, Lit_}; use ast::{LitBool, LitChar, LitByte, LitByteStr}; use ast::{LitStr, LitInt, Local}; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; @@ -50,7 +50,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; -use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr}; +use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPtr}; use ast::{TyRptr, TyTup, TyU32, TyVec}; use ast::TypeTraitItem; use ast::{UnnamedField, UnsafeBlock}; diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 1e1bf538876..ff0f139d825 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -18,7 +18,6 @@ use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; use syntax::attr; -use syntax::attr::*; use syntax::parse::token; use syntax::config::CfgDiagReal; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 7ffe567ac83..365f67e5616 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -59,11 +59,9 @@ use self::NamePadding::*; use self::OutputLocation::*; use stats::Stats; -use getopts::{OptGroup, optflag, optopt}; use serialize::Encodable; use std::boxed::FnBox; use term::Terminal; -use term::color::{Color, RED, YELLOW, GREEN, CYAN}; use std::any::Any; use std::cmp; From ba20a862d4082d96c12fc928e900d3e507348a1a Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 12 Dec 2015 03:30:53 +0000 Subject: [PATCH 2/2] rustc_resolve: fix a bug in which unused imports can get wrongly marked as used when checking for unused qualifications in resolve_path (fixes #30078) --- src/librustc_resolve/lib.rs | 35 +++++++++++--------- src/test/compile-fail/lint-qualification.rs | 1 + src/test/compile-fail/lint-unused-imports.rs | 5 ++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b6f81e0fa83..46fc3f37f7b 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1463,7 +1463,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { fn resolve_item_in_lexical_scope(&mut self, module_: Rc, name: Name, - namespace: Namespace) + namespace: Namespace, + record_used: bool) -> ResolveResult<(Target, bool)> { debug!("(resolving item in lexical scope) resolving `{}` in namespace {:?} in `{}`", name, @@ -1503,10 +1504,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { debug!("(resolving item in lexical scope) using import resolution"); // track used imports and extern crates as well let id = import_resolution[namespace].id; - self.used_imports.insert((id, namespace)); - self.record_import_use(id, name); - if let Some(DefId{krate: kid, ..}) = target.target_module.def_id() { - self.used_crates.insert(kid); + if record_used { + self.used_imports.insert((id, namespace)); + self.record_import_use(id, name); + if let Some(DefId{krate: kid, ..}) = target.target_module.def_id() { + self.used_crates.insert(kid); + } } return Success((target, false)); } @@ -1583,7 +1586,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { -> ResolveResult> { // If this module is an anonymous module, resolve the item in the // lexical scope. Otherwise, resolve the item from the crate root. - let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS); + let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS, true); match resolve_result { Success((target, _)) => { if let Some(module_def) = target.binding.module() { @@ -2791,7 +2794,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { span: Span) -> BareIdentifierPatternResolution { let module = self.current_module.clone(); - match self.resolve_item_in_lexical_scope(module, name, ValueNS) { + match self.resolve_item_in_lexical_scope(module, name, ValueNS, true) { Success((target, _)) => { debug!("(resolve bare identifier pattern) succeeded in finding {} at {:?}", name, @@ -2899,17 +2902,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } // Try to find a path to an item in a module. - let unqualified_def = self.resolve_identifier(segments.last().unwrap().identifier, - namespace, - check_ribs); - + let last_ident = segments.last().unwrap().identifier; if segments.len() <= 1 { + let unqualified_def = self.resolve_identifier(last_ident, namespace, check_ribs, true); return unqualified_def.and_then(|def| self.adjust_local_def(def, span)) .map(|def| { PathResolution::new(def, LastMod(AllPublic), path_depth) }); } + let unqualified_def = self.resolve_identifier(last_ident, namespace, check_ribs, false); let def = self.resolve_module_relative_path(span, segments, namespace); match (def, unqualified_def) { (Some((ref d, _)), Some(ref ud)) if *d == ud.def => { @@ -2929,7 +2931,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { fn resolve_identifier(&mut self, identifier: hir::Ident, namespace: Namespace, - check_ribs: bool) + check_ribs: bool, + record_used: bool) -> Option { // First, check to see whether the name is a primitive type. if namespace == TypeNS { @@ -2946,7 +2949,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } - self.resolve_item_by_name_in_lexical_scope(identifier.unhygienic_name, namespace) + let name = identifier.unhygienic_name; + self.resolve_item_by_name_in_lexical_scope(name, namespace, record_used) .map(LocalDef::from_def) } @@ -3197,11 +3201,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { fn resolve_item_by_name_in_lexical_scope(&mut self, name: Name, - namespace: Namespace) + namespace: Namespace, + record_used: bool) -> Option { // Check the items. let module = self.current_module.clone(); - match self.resolve_item_in_lexical_scope(module, name, namespace) { + match self.resolve_item_in_lexical_scope(module, name, namespace, record_used) { Success((target, _)) => { match target.binding.def() { None => { diff --git a/src/test/compile-fail/lint-qualification.rs b/src/test/compile-fail/lint-qualification.rs index 18a5a8ecc5d..0ad3d2c5e73 100644 --- a/src/test/compile-fail/lint-qualification.rs +++ b/src/test/compile-fail/lint-qualification.rs @@ -17,4 +17,5 @@ mod foo { fn main() { use foo::bar; foo::bar(); //~ ERROR: unnecessary qualification + bar(); } diff --git a/src/test/compile-fail/lint-unused-imports.rs b/src/test/compile-fail/lint-unused-imports.rs index 1468ae64d94..35883293990 100644 --- a/src/test/compile-fail/lint-unused-imports.rs +++ b/src/test/compile-fail/lint-unused-imports.rs @@ -50,11 +50,14 @@ mod foo { mod bar { // Don't ignore on 'pub use' because we're not sure if it's used or not pub use std::cmp::PartialEq; + pub struct Square; pub mod c { use foo::Point; use foo::Square; //~ ERROR unused import - pub fn cc(p: Point) -> isize { return 2 * (p.x + p.y); } + pub fn cc(_p: Point) -> super::Square { + super::Square + } } #[allow(unused_imports)]