Replace uses of DefLike with Def (only the DlDef variant of DefLike was being used)

This commit is contained in:
Jeffrey Seyfried 2016-03-12 04:49:25 +00:00
parent 1744f55ad7
commit 07fecf8098

View File

@ -51,7 +51,7 @@ use rustc::dep_graph::DepNode;
use rustc::front::map as hir_map; use rustc::front::map as hir_map;
use rustc::session::Session; use rustc::session::Session;
use rustc::lint; use rustc::lint;
use rustc::middle::cstore::{CrateStore, DefLike, DlDef}; use rustc::middle::cstore::CrateStore;
use rustc::middle::def::*; use rustc::middle::def::*;
use rustc::middle::def_id::DefId; use rustc::middle::def_id::DefId;
use rustc::middle::pat_util::pat_bindings; use rustc::middle::pat_util::pat_bindings;
@ -756,7 +756,7 @@ enum BareIdentifierPatternResolution {
/// One local scope. /// One local scope.
#[derive(Debug)] #[derive(Debug)]
struct Rib<'a> { struct Rib<'a> {
bindings: HashMap<Name, DefLike>, bindings: HashMap<Name, Def>,
kind: RibKind<'a>, kind: RibKind<'a>,
} }
@ -1594,7 +1594,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
/// Searches the current set of local scopes for labels. /// Searches the current set of local scopes for labels.
/// Stops after meeting a closure. /// Stops after meeting a closure.
fn search_label(&self, name: Name) -> Option<DefLike> { fn search_label(&self, name: Name) -> Option<Def> {
for rib in self.label_ribs.iter().rev() { for rib in self.label_ribs.iter().rev() {
match rib.kind { match rib.kind {
NormalRibKind => { NormalRibKind => {
@ -1753,13 +1753,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
seen_bindings.insert(name); seen_bindings.insert(name);
// plain insert (no renaming) // plain insert (no renaming)
function_type_rib.bindings let def_id = self.ast_map.local_def_id(type_parameter.id);
.insert(name, let def = Def::TyParam(space, index as u32, def_id, name);
DlDef(Def::TyParam(space, function_type_rib.bindings.insert(name, def);
index as u32,
self.ast_map
.local_def_id(type_parameter.id),
name)));
} }
self.type_ribs.push(function_type_rib); self.type_ribs.push(function_type_rib);
} }
@ -1948,7 +1944,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// plain insert (no renaming, types are not currently hygienic....) // plain insert (no renaming, types are not currently hygienic....)
let name = special_names::type_self; let name = special_names::type_self;
self_type_rib.bindings.insert(name, DlDef(self_def)); self_type_rib.bindings.insert(name, self_def);
self.type_ribs.push(self_type_rib); self.type_ribs.push(self_type_rib);
f(self); f(self);
if !self.resolved { if !self.resolved {
@ -2328,7 +2324,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
if !bindings_list.contains_key(&renamed) { if !bindings_list.contains_key(&renamed) {
let this = &mut *self; let this = &mut *self;
let last_rib = this.value_ribs.last_mut().unwrap(); let last_rib = this.value_ribs.last_mut().unwrap();
last_rib.bindings.insert(renamed, DlDef(def)); last_rib.bindings.insert(renamed, def);
bindings_list.insert(renamed, pat_id); bindings_list.insert(renamed, pat_id);
} else if mode == ArgumentIrrefutableMode && } else if mode == ArgumentIrrefutableMode &&
bindings_list.contains_key(&renamed) { bindings_list.contains_key(&renamed) {
@ -2869,25 +2865,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let name = match namespace { ValueNS => ident.name, TypeNS => ident.unhygienic_name }; let name = match namespace { ValueNS => ident.name, TypeNS => ident.unhygienic_name };
for i in (0 .. self.get_ribs(namespace).len()).rev() { for i in (0 .. self.get_ribs(namespace).len()).rev() {
if let Some(def_like) = self.get_ribs(namespace)[i].bindings.get(&name).cloned() { if let Some(def) = self.get_ribs(namespace)[i].bindings.get(&name).cloned() {
match def_like { return Some(LocalDef {
DlDef(def) => { ribs: Some((namespace, i)),
debug!("(resolving path in local ribs) resolved `{}` to {:?} at {}", def: def,
name, });
def,
i);
return Some(LocalDef {
ribs: Some((namespace, i)),
def: def,
});
}
def_like => {
debug!("(resolving path in local ribs) resolved `{}` to pseudo-def {:?}",
name,
def_like);
return None;
}
}
} }
if let ModuleRibKind(module) = self.get_ribs(namespace)[i].kind { if let ModuleRibKind(module) = self.get_ribs(namespace)[i].kind {
@ -3230,11 +3212,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ExprLoop(_, Some(label)) | ExprWhile(_, _, Some(label)) => { ExprLoop(_, Some(label)) | ExprWhile(_, _, Some(label)) => {
self.with_label_rib(|this| { self.with_label_rib(|this| {
let def_like = DlDef(Def::Label(expr.id)); let def = Def::Label(expr.id);
{ {
let rib = this.label_ribs.last_mut().unwrap(); let rib = this.label_ribs.last_mut().unwrap();
rib.bindings.insert(label.name, def_like); rib.bindings.insert(label.name, def);
} }
intravisit::walk_expr(this, expr); intravisit::walk_expr(this, expr);
@ -3249,7 +3231,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
label.span, label.span,
ResolutionError::UndeclaredLabel(&label.node.name.as_str())) ResolutionError::UndeclaredLabel(&label.node.name.as_str()))
} }
Some(DlDef(def @ Def::Label(_))) => { Some(def @ Def::Label(_)) => {
// Since this def is a label, it is never read. // Since this def is a label, it is never read.
self.record_def(expr.id, self.record_def(expr.id,
PathResolution { PathResolution {