Remove resolver.record_resolution()
.
This commit is contained in:
parent
8fe525dd1c
commit
c871637e43
@ -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;
|
||||
@ -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",
|
||||
@ -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 {
|
||||
@ -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,
|
||||
@ -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 {
|
||||
@ -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> {
|
||||
@ -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,
|
||||
|
@ -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;
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user