Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some imports to the rustc crate #69920

Merged
merged 2 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
remove unnecessary hir::map imports
  • Loading branch information
Centril committed Mar 16, 2020
commit 73a625b5fb820964fff4ff85ac0a09b398dbe994
3 changes: 1 addition & 2 deletions src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use rustc::arena::Arena;
use rustc::dep_graph::DepGraph;
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
use rustc::hir::map::Map;
use rustc::{bug, span_bug};
use rustc_ast::ast;
use rustc_ast::ast::*;
Expand Down Expand Up @@ -1460,7 +1459,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

impl<'r, 'a, 'v, 'hir> intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a, 'hir> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
intravisit::NestedVisitorMap::None
Expand Down
19 changes: 19 additions & 0 deletions src/librustc_hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ pub trait Map<'hir> {
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>;
}

/// An erased version of `Map<'hir>`, using dynamic dispatch.
/// NOTE: This type is effectively only usable with `NestedVisitorMap::None`.
pub struct ErasedMap<'hir>(&'hir dyn Map<'hir>);

impl<'hir> Map<'hir> for ErasedMap<'hir> {
fn body(&self, id: BodyId) -> &'hir Body<'hir> {
self.0.body(id)
}
fn item(&self, id: HirId) -> &'hir Item<'hir> {
self.0.item(id)
}
fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
self.0.trait_item(id)
}
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
self.0.impl_item(id)
}
}

/// Specifies what nested things a visitor wants to visit. The most
/// common choice is `OnlyBodies`, which will cause the visitor to
/// visit fn bodies for fns that it encounters, but skip over nested
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//! `late_lint_methods!` invocation in `lib.rs`.

use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc::hir::map::Map;
use rustc::lint::LintDiagnosticBuilder;
use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt};
use rustc_ast::ast::{self, Expr};
Expand Down Expand Up @@ -1071,7 +1070,7 @@ impl TypeAliasBounds {
err: &'a mut DiagnosticBuilder<'db>,
}
impl<'a, 'db, 'v> Visitor<'v> for WalkAssocTypes<'a, 'db> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
intravisit::NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc::hir::map::Map;
use rustc::lint::builtin::{SAFE_PACKED_BORROWS, UNUSED_UNSAFE};
use rustc::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
use rustc::mir::*;
Expand Down Expand Up @@ -451,7 +450,7 @@ struct UnusedUnsafeVisitor<'a> {
}

impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
intravisit::NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{shim, util};
use rustc::hir::map::Map;
use rustc::mir::{BodyAndCache, ConstQualifs, MirPhase, Promoted};
use rustc::ty::query::Providers;
use rustc::ty::steal::Steal;
Expand Down Expand Up @@ -86,7 +85,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet {
}
intravisit::walk_struct_def(self, v)
}
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_mir_build/hair/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::_match::{expand_pattern, is_useful, MatchCheckCtxt, Matrix, PatStack}

use super::{PatCtxt, PatKind, PatternError};

use rustc::hir::map::Map;
use rustc::ty::{self, Ty, TyCtxt};
use rustc_ast::ast::Mutability;
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder};
Expand Down Expand Up @@ -43,7 +42,7 @@ struct MatchVisitor<'a, 'tcx> {
}

impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -753,7 +752,7 @@ fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pa
}

impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}

impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_passes/intrinsicck.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc::hir::map::Map;
use rustc::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx};
use rustc::ty::query::Providers;
use rustc::ty::{self, Ty, TyCtxt};
Expand Down Expand Up @@ -122,7 +121,7 @@ impl ExprVisitor<'tcx> {
}

impl Visitor<'tcx> for ItemVisitor<'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand All @@ -139,7 +138,7 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> {
}

impl Visitor<'tcx> for ExprVisitor<'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// Checking for error conditions

impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_passes/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// makes all other generics or inline functions that it references
// reachable as well.

use rustc::hir::map::Map;
use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc::middle::privacy;
use rustc::session::config;
Expand All @@ -17,8 +16,7 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::intravisit;
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::{HirIdSet, Node};
use rustc_target::spec::abi::Abi;
Expand Down Expand Up @@ -83,7 +81,7 @@ struct ReachableContext<'a, 'tcx> {
}

impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_passes/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//!
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html

use rustc::hir::map::Map;
use rustc::middle::region::*;
use rustc::ty::query::Providers;
use rustc::ty::TyCtxt;
Expand Down Expand Up @@ -696,7 +695,7 @@ impl<'tcx> RegionResolutionVisitor<'tcx> {
}

impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_passes/upvars.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Upvar (closure capture) collection from cross-body HIR uses of `Res::Local`s.

use rustc::hir::map::Map;
use rustc::ty::query::Providers;
use rustc::ty::TyCtxt;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
Expand Down Expand Up @@ -44,7 +43,7 @@ struct LocalCollector {
}

impl Visitor<'tcx> for LocalCollector {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -73,7 +72,7 @@ impl CaptureCollector<'_, '_> {
}

impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_passes/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rustc::middle::lang_items;
use rustc::middle::lang_items::whitelisted;
use rustc::session::config;

use rustc::hir::map::Map;
use rustc::ty::TyCtxt;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::struct_span_err;
Expand Down Expand Up @@ -85,9 +84,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
}

impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Map<'v>> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
}

impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_resolve/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) {
gather.visit_body(body);

impl<'v, 'a, 'tcx> Visitor<'v> for GatherLabels<'a, 'tcx> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -2172,7 +2172,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}

impl<'a> Visitor<'a> for SelfVisitor<'a> {
type Map = Map<'a>;
type Map = intravisit::ErasedMap<'a>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -2263,7 +2263,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}

impl<'v, 'a> Visitor<'v> for GatherLifetimes<'a> {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -2852,7 +2852,7 @@ fn insert_late_bound_lifetimes(
}

impl<'v> Visitor<'v> for ConstrainedCollector {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down Expand Up @@ -2895,7 +2895,7 @@ fn insert_late_bound_lifetimes(
}

impl<'v> Visitor<'v> for AllCollector {
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ struct ReturnsVisitor<'v> {
}

impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
type Map = rustc::hir::map::Map<'v>;
type Map = hir::intravisit::ErasedMap<'v>;

fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
hir::intravisit::NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use rustc::hir::map::Map;
use rustc::ty::error::{ExpectedFound, TypeError};
use rustc::ty::subst::{InternalSubsts, Subst};
use rustc::ty::util::ExplicitSelf;
Expand Down Expand Up @@ -890,7 +889,7 @@ fn compare_synthetic_generics<'tcx>(
}
}
}
type Map = Map<'v>;
type Map = intravisit::ErasedMap<'v>;
fn nested_visit_map(
&mut self,
) -> intravisit::NestedVisitorMap<Self::Map>
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/generator_interior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! types computed here.

use super::FnCtxt;
use rustc::hir::map::Map;
use rustc::middle::region::{self, YieldData};
use rustc::ty::{self, Ty};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
Expand Down Expand Up @@ -209,7 +208,7 @@ pub fn resolve_interior<'a, 'tcx>(
// librustc/middle/region.rs since `expr_count` is compared against the results
// there.
impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use crate::check::FnCtxt;
use crate::middle::lang_items::FnOnceTraitLangItem;
use rustc::hir::map as hir_map;
use rustc::hir::map::Map;
use rustc::ty::print::with_crate_prefix;
use rustc::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
use rustc_ast::ast;
Expand Down Expand Up @@ -1347,7 +1346,7 @@ impl intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> {
}
}

type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
intravisit::NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub mod writeback;
use crate::astconv::{AstConv, GenericArgCountMismatch, PathSeg};
use crate::middle::lang_items;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::hir::map::Map;
use rustc::middle::region;
use rustc::mir::interpret::ConstValue;
use rustc::session::parse::feature_err;
Expand Down Expand Up @@ -1177,7 +1176,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
}

impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ use crate::check::dropck;
use crate::check::FnCtxt;
use crate::mem_categorization as mc;
use crate::middle::region;
use rustc::hir::map::Map;
use rustc::ty::adjustment;
use rustc::ty::subst::{GenericArgKind, SubstsRef};
use rustc::ty::{self, Ty};
Expand Down Expand Up @@ -417,7 +416,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
// hierarchy, and in particular the relationships between free
// regions, until regionck, as described in #3238.

type Map = Map<'tcx>;
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
Expand Down
Loading