Remove resolver.record_resolution().

This commit is contained in:
Jeffrey Seyfried 2016-11-29 00:33:59 +00:00
parent 8fe525dd1c
commit c871637e43
3 changed files with 6 additions and 33 deletions

View File

@ -82,9 +82,6 @@ pub trait Resolver {
// Obtain the resolution for a node id // Obtain the resolution for a node id
fn get_resolution(&mut self, id: NodeId) -> Option<PathResolution>; 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. // 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. // This should only return `None` during testing.
fn definitions(&mut self) -> &mut Definitions; fn definitions(&mut self) -> &mut Definitions;
@ -351,12 +348,7 @@ impl<'a> LoweringContext<'a> {
// Otherwise, the base path is an implicit `Self` type path, // Otherwise, the base path is an implicit `Self` type path,
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in // e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
// `<I as Iterator>::Item::default`. // `<I as Iterator>::Item::default`.
let ty = self.ty(p.span, hir::TyPath(hir::QPath::Resolved(qself, path))); 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
}; };
// Anything after the base path are associated "extensions", // Anything after the base path are associated "extensions",
@ -1902,10 +1894,8 @@ impl<'a> LoweringContext<'a> {
def: def, def: def,
segments: hir_vec![hir::PathSegment::from_name(id)], 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 { fn expr_mut_addr_of(&mut self, span: Span, e: P<hir::Expr>) -> hir::Expr {
@ -1918,10 +1908,7 @@ impl<'a> LoweringContext<'a> {
attrs: ThinVec<Attribute>) attrs: ThinVec<Attribute>)
-> hir::Expr { -> hir::Expr {
let path = self.std_path(span, components, true); let path = self.std_path(span, components, true);
let def = path.def; self.expr(span, hir::ExprPath(hir::QPath::Resolved(None, P(path))), attrs)
let expr = self.expr(span, hir::ExprPath(hir::QPath::Resolved(None, P(path))), attrs);
self.resolver.record_resolution(expr.id, def);
expr
} }
fn expr_match(&mut self, fn expr_match(&mut self,
@ -1948,11 +1935,8 @@ impl<'a> LoweringContext<'a> {
e: Option<P<hir::Expr>>, e: Option<P<hir::Expr>>,
attrs: ThinVec<Attribute>) -> hir::Expr { attrs: ThinVec<Attribute>) -> hir::Expr {
let path = self.std_path(span, components, false); let path = self.std_path(span, components, false);
let def = path.def;
let qpath = hir::QPath::Resolved(None, P(path)); let qpath = hir::QPath::Resolved(None, P(path));
let expr = self.expr(span, hir::ExprStruct(qpath, fields, e), attrs); self.expr(span, hir::ExprStruct(qpath, fields, e), attrs)
self.resolver.record_resolution(expr.id, def);
expr
} }
fn expr(&mut self, span: Span, node: hir::Expr_, attrs: ThinVec<Attribute>) -> hir::Expr { fn expr(&mut self, span: Span, node: hir::Expr_, attrs: ThinVec<Attribute>) -> hir::Expr {
@ -2021,16 +2005,13 @@ impl<'a> LoweringContext<'a> {
subpats: hir::HirVec<P<hir::Pat>>) subpats: hir::HirVec<P<hir::Pat>>)
-> P<hir::Pat> { -> P<hir::Pat> {
let path = self.std_path(span, components, true); let path = self.std_path(span, components, true);
let def = path.def;
let qpath = hir::QPath::Resolved(None, P(path)); let qpath = hir::QPath::Resolved(None, P(path));
let pt = if subpats.is_empty() { let pt = if subpats.is_empty() {
hir::PatKind::Path(qpath) hir::PatKind::Path(qpath)
} else { } else {
hir::PatKind::TupleStruct(qpath, subpats, None) hir::PatKind::TupleStruct(qpath, subpats, None)
}; };
let pat = self.pat(span, pt); self.pat(span, pt)
self.resolver.record_resolution(pat.id, def);
pat
} }
fn pat_ident(&mut self, span: Span, name: Name) -> P<hir::Pat> { fn pat_ident(&mut self, span: Span, name: Name) -> P<hir::Pat> {
@ -2047,7 +2028,6 @@ impl<'a> LoweringContext<'a> {
let def_index = defs.create_def_with_parent(parent_def, id, def_path_data); let def_index = defs.create_def_with_parent(parent_def, id, def_path_data);
DefId::local(def_index) DefId::local(def_index)
}; };
self.resolver.record_resolution(id, Def::Local(def_id));
P(hir::Pat { P(hir::Pat {
id: id, id: id,

View File

@ -10,7 +10,6 @@
use rustc::hir; use rustc::hir;
use rustc::hir::{map as hir_map, FreevarMap, TraitMap}; use rustc::hir::{map as hir_map, FreevarMap, TraitMap};
use rustc::hir::def::DefMap;
use rustc::hir::lowering::lower_crate; use rustc::hir::lowering::lower_crate;
use rustc_data_structures::blake2b::Blake2bHasher; use rustc_data_structures::blake2b::Blake2bHasher;
use rustc_data_structures::fmt_wrap::FmtWrap; use rustc_data_structures::fmt_wrap::FmtWrap;
@ -63,7 +62,6 @@ use derive_registrar;
#[derive(Clone)] #[derive(Clone)]
pub struct Resolutions { pub struct Resolutions {
pub def_map: DefMap,
pub freevars: FreevarMap, pub freevars: FreevarMap,
pub trait_map: TraitMap, pub trait_map: TraitMap,
pub maybe_unused_trait_imports: NodeSet, pub maybe_unused_trait_imports: NodeSet,
@ -794,7 +792,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
hir_ty_to_ty: NodeMap(), hir_ty_to_ty: NodeMap(),
}, },
resolutions: Resolutions { resolutions: Resolutions {
def_map: resolver.def_map,
freevars: resolver.freevars, freevars: resolver.freevars,
trait_map: resolver.trait_map, trait_map: resolver.trait_map,
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports, maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,

View File

@ -1050,7 +1050,7 @@ pub struct Resolver<'a> {
// The idents for the primitive types. // The idents for the primitive types.
primitive_type_table: PrimitiveTypeTable, primitive_type_table: PrimitiveTypeTable,
pub def_map: DefMap, def_map: DefMap,
pub freevars: FreevarMap, pub freevars: FreevarMap,
freevars_seen: NodeMap<NodeMap<usize>>, freevars_seen: NodeMap<NodeMap<usize>>,
pub export_map: ExportMap, pub export_map: ExportMap,
@ -1183,10 +1183,6 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
self.def_map.get(&id).cloned() 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 { fn definitions(&mut self) -> &mut Definitions {
&mut self.definitions &mut self.definitions
} }