Warn unused trait imports
This commit is contained in:
parent
7ad1900e1c
commit
24d86137f5
13 changed files with 169 additions and 25 deletions
|
|
@ -59,6 +59,7 @@ pub enum DepNode<D: Clone + Debug> {
|
|||
TypeckItemBody(D),
|
||||
Dropck,
|
||||
DropckImpl(D),
|
||||
UnusedTraitCheck,
|
||||
CheckConst(D),
|
||||
Privacy,
|
||||
IntrinsicCheck(D),
|
||||
|
|
@ -163,6 +164,7 @@ impl<D: Clone + Debug> DepNode<D> {
|
|||
CheckEntryFn => Some(CheckEntryFn),
|
||||
Variance => Some(Variance),
|
||||
Dropck => Some(Dropck),
|
||||
UnusedTraitCheck => Some(UnusedTraitCheck),
|
||||
Privacy => Some(Privacy),
|
||||
Reachability => Some(Reachability),
|
||||
DeadCheck => Some(DeadCheck),
|
||||
|
|
|
|||
|
|
@ -1639,8 +1639,13 @@ pub type FreevarMap = NodeMap<Vec<Freevar>>;
|
|||
|
||||
pub type CaptureModeMap = NodeMap<CaptureClause>;
|
||||
|
||||
pub struct TraitCandidate {
|
||||
pub def_id: DefId,
|
||||
pub import_id: Option<NodeId>,
|
||||
}
|
||||
|
||||
// Trait method resolution
|
||||
pub type TraitMap = NodeMap<Vec<DefId>>;
|
||||
pub type TraitMap = NodeMap<Vec<TraitCandidate>>;
|
||||
|
||||
// Map from the NodeId of a glob import to a list of items which are actually
|
||||
// imported.
|
||||
|
|
|
|||
|
|
@ -289,6 +289,8 @@ pub struct TyCtxt<'tcx> {
|
|||
// scratch every time.
|
||||
pub freevars: RefCell<FreevarMap>,
|
||||
|
||||
pub maybe_unused_trait_imports: NodeSet,
|
||||
|
||||
// Records the type of every item.
|
||||
pub tcache: RefCell<DepTrackingMap<maps::Tcache<'tcx>>>,
|
||||
|
||||
|
|
@ -338,6 +340,10 @@ pub struct TyCtxt<'tcx> {
|
|||
/// about.
|
||||
pub used_mut_nodes: RefCell<NodeSet>,
|
||||
|
||||
/// Set of trait imports actually used in the method resolution.
|
||||
/// This is used for warning unused imports.
|
||||
pub used_trait_imports: RefCell<NodeSet>,
|
||||
|
||||
/// The set of external nominal types whose implementations have been read.
|
||||
/// This is used for lazy resolution of methods.
|
||||
pub populated_external_types: RefCell<DefIdSet>,
|
||||
|
|
@ -543,6 +549,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||
map: ast_map::Map<'tcx>,
|
||||
freevars: FreevarMap,
|
||||
maybe_unused_trait_imports: NodeSet,
|
||||
region_maps: RegionMaps,
|
||||
lang_items: middle::lang_items::LanguageItems,
|
||||
stability: stability::Index<'tcx>,
|
||||
|
|
@ -581,6 +588,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
fulfilled_predicates: RefCell::new(fulfilled_predicates),
|
||||
map: map,
|
||||
freevars: RefCell::new(freevars),
|
||||
maybe_unused_trait_imports: maybe_unused_trait_imports,
|
||||
tcache: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
|
||||
rcache: RefCell::new(FnvHashMap()),
|
||||
tc_cache: RefCell::new(FnvHashMap()),
|
||||
|
|
@ -595,6 +603,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
impl_items: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
|
||||
used_unsafe: RefCell::new(NodeSet()),
|
||||
used_mut_nodes: RefCell::new(NodeSet()),
|
||||
used_trait_imports: RefCell::new(NodeSet()),
|
||||
populated_external_types: RefCell::new(DefIdSet()),
|
||||
populated_external_primitive_impls: RefCell::new(DefIdSet()),
|
||||
extern_const_statics: RefCell::new(DefIdMap()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue