Skip to content

Commit

Permalink
Remove resolver.record_resolution().
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Nov 29, 2016
1 parent 8fe525d commit c871637
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
30 changes: 5 additions & 25 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ pub trait Resolver {
// Obtain the resolution for a node id
fn get_resolution(&mut self, id: NodeId) -> Option<PathResolution>;

// Record the resolution of a path or binding generated by the lowerer when expanding.
fn record_resolution(&mut self, id: NodeId, def: Def);

// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
// This should only return `None` during testing.
fn definitions(&mut self) -> &mut Definitions;
Expand Down Expand Up @@ -351,12 +348,7 @@ impl<'a> LoweringContext<'a> {
// Otherwise, the base path is an implicit `Self` type path,
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
// `<I as Iterator>::Item::default`.
let ty = self.ty(p.span, hir::TyPath(hir::QPath::Resolved(qself, path)));

// Associate that innermost path type with the base Def.
self.resolver.record_resolution(ty.id, resolution.base_def);

ty
self.ty(p.span, hir::TyPath(hir::QPath::Resolved(qself, path)))
};

// Anything after the base path are associated "extensions",
Expand Down Expand Up @@ -1902,10 +1894,8 @@ impl<'a> LoweringContext<'a> {
def: def,
segments: hir_vec![hir::PathSegment::from_name(id)],
})));
let expr = self.expr(span, expr_path, ThinVec::new());
self.resolver.record_resolution(expr.id, def);

expr
self.expr(span, expr_path, ThinVec::new())
}

fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr {
Expand All @@ -1918,10 +1908,7 @@ impl<'a> LoweringContext<'a> {
attrs: ThinVec<Attribute>)
-> hir::Expr {
let path = self.std_path(span, components, true);
let def = path.def;
let expr = self.expr(span, hir::ExprPath(hir::QPath::Resolved(None, P(path))), attrs);
self.resolver.record_resolution(expr.id, def);
expr
self.expr(span, hir::ExprPath(hir::QPath::Resolved(None, P(path))), attrs)
}

fn expr_match(&mut self,
Expand All @@ -1948,11 +1935,8 @@ impl<'a> LoweringContext<'a> {
e: Option<P<hir::Expr>>,
attrs: ThinVec<Attribute>) -> hir::Expr {
let path = self.std_path(span, components, false);
let def = path.def;
let qpath = hir::QPath::Resolved(None, P(path));
let expr = self.expr(span, hir::ExprStruct(qpath, fields, e), attrs);
self.resolver.record_resolution(expr.id, def);
expr
self.expr(span, hir::ExprStruct(qpath, fields, e), attrs)
}

fn expr(&mut self, span: Span, node: hir::Expr_, attrs: ThinVec<Attribute>) -> hir::Expr {
Expand Down Expand Up @@ -2021,16 +2005,13 @@ impl<'a> LoweringContext<'a> {
subpats: hir::HirVec<P<hir::Pat>>)
-> P<hir::Pat> {
let path = self.std_path(span, components, true);
let def = path.def;
let qpath = hir::QPath::Resolved(None, P(path));
let pt = if subpats.is_empty() {
hir::PatKind::Path(qpath)
} else {
hir::PatKind::TupleStruct(qpath, subpats, None)
};
let pat = self.pat(span, pt);
self.resolver.record_resolution(pat.id, def);
pat
self.pat(span, pt)
}

fn pat_ident(&mut self, span: Span, name: Name) -> P<hir::Pat> {
Expand All @@ -2047,7 +2028,6 @@ impl<'a> LoweringContext<'a> {
let def_index = defs.create_def_with_parent(parent_def, id, def_path_data);
DefId::local(def_index)
};
self.resolver.record_resolution(id, Def::Local(def_id));

P(hir::Pat {
id: id,
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use rustc::hir;
use rustc::hir::{map as hir_map, FreevarMap, TraitMap};
use rustc::hir::def::DefMap;
use rustc::hir::lowering::lower_crate;
use rustc_data_structures::blake2b::Blake2bHasher;
use rustc_data_structures::fmt_wrap::FmtWrap;
Expand Down Expand Up @@ -63,7 +62,6 @@ use derive_registrar;

#[derive(Clone)]
pub struct Resolutions {
pub def_map: DefMap,
pub freevars: FreevarMap,
pub trait_map: TraitMap,
pub maybe_unused_trait_imports: NodeSet,
Expand Down Expand Up @@ -794,7 +792,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
hir_ty_to_ty: NodeMap(),
},
resolutions: Resolutions {
def_map: resolver.def_map,
freevars: resolver.freevars,
trait_map: resolver.trait_map,
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ pub struct Resolver<'a> {
// The idents for the primitive types.
primitive_type_table: PrimitiveTypeTable,

pub def_map: DefMap,
def_map: DefMap,
pub freevars: FreevarMap,
freevars_seen: NodeMap<NodeMap<usize>>,
pub export_map: ExportMap,
Expand Down Expand Up @@ -1183,10 +1183,6 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
self.def_map.get(&id).cloned()
}

fn record_resolution(&mut self, id: NodeId, def: Def) {
self.def_map.insert(id, PathResolution::new(def));
}

fn definitions(&mut self) -> &mut Definitions {
&mut self.definitions
}
Expand Down

0 comments on commit c871637

Please sign in to comment.