Skip to content

Commit

Permalink
fallout from deprecating find_copy and get_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Nov 16, 2014
1 parent 64efd26 commit dfb7a81
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 94 deletions.
4 changes: 2 additions & 2 deletions src/librustc/lint/builtin.rs
Expand Up @@ -391,7 +391,7 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {

impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
match self.cx.tcx.def_map.borrow().get_copy(&path_id) {
match self.cx.tcx.def_map.borrow()[path_id].clone() {
def::DefPrimTy(ast::TyInt(ast::TyI)) => {
self.cx.span_lint(IMPROPER_CTYPES, sp,
"found rust type `int` in foreign module, while \
Expand Down Expand Up @@ -866,7 +866,7 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext {
node: m.id
};

match cx.tcx.impl_or_trait_items.borrow().find_copy(&did) {
match cx.tcx.impl_or_trait_items.borrow().get(&did).cloned() {
None => cx.sess().span_bug(m.span, "missing method descriptor?!"),
Some(md) => {
match md {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/encoder.rs
Expand Up @@ -1863,7 +1863,7 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
match item.node {
ItemImpl(_, Some(ref trait_ref), _, _) => {
let def_map = &self.ecx.tcx.def_map;
let trait_def = def_map.borrow().get_copy(&trait_ref.ref_id);
let trait_def = def_map.borrow()[trait_ref.ref_id].clone();
let def_id = trait_def.def_id();

// Load eagerly if this is an implementation of the Drop trait
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tydecode.rs
Expand Up @@ -440,7 +440,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
pos: pos,
len: len };

match st.tcx.rcache.borrow().find_copy(&key) {
match st.tcx.rcache.borrow().get(&key).cloned() {
Some(tt) => return tt,
None => {}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/astencode.rs
Expand Up @@ -1200,8 +1200,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
var_id: var_id,
closure_expr_id: id
};
let upvar_borrow = tcx.upvar_borrow_map.borrow()
.get_copy(&upvar_id);
let upvar_borrow = tcx.upvar_borrow_map.borrow()[upvar_id].clone();
var_id.encode(rbml_w);
upvar_borrow.encode(rbml_w);
})
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/move_data.rs
Expand Up @@ -295,7 +295,7 @@ impl MoveData {

fn existing_move_path(&self, lp: &Rc<LoanPath>)
-> Option<MovePathIndex> {
self.path_map.borrow().find_copy(lp)
self.path_map.borrow().get(lp).cloned()
}

fn existing_base_paths(&self, lp: &Rc<LoanPath>)
Expand All @@ -312,7 +312,7 @@ impl MoveData {
* paths of `lp` to `result`, but does not add new move paths
*/

match self.path_map.borrow().find_copy(lp) {
match self.path_map.borrow().get(lp).cloned() {
Some(index) => {
self.each_base_path(index, |p| {
result.push(p);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/check_match.rs
Expand Up @@ -360,7 +360,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
fn fold_pat(&mut self, pat: P<Pat>) -> P<Pat> {
match pat.node {
PatIdent(..) | PatEnum(..) => {
let def = self.tcx.def_map.borrow().find_copy(&pat.id);
let def = self.tcx.def_map.borrow().get(&pat.id).cloned();
match def {
Some(DefConst(did)) => match lookup_const_by_id(self.tcx, did) {
Some(const_expr) => {
Expand Down Expand Up @@ -753,7 +753,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
Some(Vec::from_elem(arity, DUMMY_WILD_PAT)),

&PatIdent(_, _, _) => {
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat_id);
let opt_def = cx.tcx.def_map.borrow().get(&pat_id).cloned();
match opt_def {
Some(DefConst(..)) =>
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
Expand All @@ -768,7 +768,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
}

&PatEnum(_, ref args) => {
let def = cx.tcx.def_map.borrow().get_copy(&pat_id);
let def = cx.tcx.def_map.borrow()[pat_id].clone();
match def {
DefConst(..) =>
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
Expand All @@ -786,7 +786,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],

&PatStruct(_, ref pattern_fields, _) => {
// Is this a struct or an enum variant?
let def = cx.tcx.def_map.borrow().get_copy(&pat_id);
let def = cx.tcx.def_map.borrow()[pat_id].clone();
let class_id = match def {
DefConst(..) =>
cx.tcx.sess.span_bug(pat_span, "const pattern should've \
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/const_eval.rs
Expand Up @@ -85,7 +85,7 @@ pub fn join_all<It: Iterator<constness>>(mut cs: It) -> constness {
}

fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> {
let opt_def = tcx.def_map.borrow().find_copy(&e.id);
let opt_def = tcx.def_map.borrow().get(&e.id).cloned();
match opt_def {
Some(def::DefConst(def_id)) => {
lookup_const_by_id(tcx, def_id)
Expand Down Expand Up @@ -321,7 +321,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<Pat> {
PatTup(exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr)).collect()),

ExprCall(ref callee, ref args) => {
let def = tcx.def_map.borrow().get_copy(&callee.id);
let def = tcx.def_map.borrow()[callee.id].clone();
match tcx.def_map.borrow_mut().entry(expr.id) {
Vacant(entry) => { entry.set(def); }
_ => {}
Expand Down Expand Up @@ -353,7 +353,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<Pat> {
}

ExprPath(ref path) => {
let opt_def = tcx.def_map.borrow().find_copy(&expr.id);
let opt_def = tcx.def_map.borrow().get(&expr.id).cloned();
match opt_def {
Some(def::DefStruct(..)) =>
PatStruct(path.clone(), vec![], false),
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -850,7 +850,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {

// Each match binding is effectively an assignment to the
// binding being produced.
let def = def_map.borrow().get_copy(&pat.id);
let def = def_map.borrow()[pat.id].clone();
match mc.cat_def(pat.id, pat.span, pat_ty, def) {
Ok(binding_cmt) => {
delegate.mutate(pat.id, pat.span, binding_cmt, Init);
Expand Down Expand Up @@ -957,8 +957,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
// inferred by regionbk
let upvar_id = ty::UpvarId { var_id: id_var,
closure_expr_id: closure_expr.id };
let upvar_borrow = self.tcx().upvar_borrow_map.borrow()
.get_copy(&upvar_id);
let upvar_borrow = self.tcx().upvar_borrow_map.borrow()[upvar_id].clone();

self.delegate.borrow(closure_expr.id,
closure_expr.span,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/liveness.rs
Expand Up @@ -449,7 +449,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
match expr.node {
// live nodes required for uses or definitions of variables:
ExprPath(_) => {
let def = ir.tcx.def_map.borrow().get_copy(&expr.id);
let def = ir.tcx.def_map.borrow()[expr.id].clone();
debug!("expr {}: path that leads to {}", expr.id, def);
match def {
DefLocal(..) => ir.add_live_node_for_node(expr.id, ExprNode(expr.span)),
Expand Down Expand Up @@ -1316,7 +1316,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {

fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
-> LiveNode {
match self.ir.tcx.def_map.borrow().get_copy(&expr.id) {
match self.ir.tcx.def_map.borrow()[expr.id].clone() {
DefLocal(nid) => {
let ln = self.live_node(expr.id, expr.span);
if acc != 0u {
Expand Down Expand Up @@ -1582,7 +1582,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn check_lvalue(&mut self, expr: &Expr) {
match expr.node {
ExprPath(_) => {
match self.ir.tcx.def_map.borrow().get_copy(&expr.id) {
match self.ir.tcx.def_map.borrow()[expr.id].clone() {
DefLocal(nid) => {
// Assignment to an immutable variable or argument: only legal
// if there is no later assignment. If this local is actually
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/privacy.rs
Expand Up @@ -245,7 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
ast::ItemImpl(_, _, ref ty, ref impl_items) => {
let public_ty = match ty.node {
ast::TyPath(_, _, id) => {
match self.tcx.def_map.borrow().get_copy(&id) {
match self.tcx.def_map.borrow()[id].clone() {
def::DefPrimTy(..) => true,
def => {
let did = def.def_id();
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
ast::ItemTy(ref ty, _) if public_first => {
match ty.node {
ast::TyPath(_, _, id) => {
match self.tcx.def_map.borrow().get_copy(&id) {
match self.tcx.def_map.borrow()[id].clone() {
def::DefPrimTy(..) | def::DefTyParam(..) => {},
def => {
let did = def.def_id();
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
ast::TyPath(_, _, id) => id,
_ => return Some((err_span, err_msg, None)),
};
let def = self.tcx.def_map.borrow().get_copy(&id);
let def = self.tcx.def_map.borrow()[id].clone();
let did = def.def_id();
assert!(is_local(did));
match self.tcx.map.get(did.node) {
Expand Down Expand Up @@ -706,7 +706,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
// Checks that a path is in scope.
fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
debug!("privacy - path {}", self.nodestr(path_id));
let orig_def = self.tcx.def_map.borrow().get_copy(&path_id);
let orig_def = self.tcx.def_map.borrow()[path_id].clone();
let ck = |tyname: &str| {
let ck_public = |def: ast::DefId| {
let name = token::get_ident(path.segments
Expand Down Expand Up @@ -789,7 +789,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
// def map is not. Therefore the names we work out below will not always
// be accurate and we can get slightly wonky error messages (but type
// checking is always correct).
match self.tcx.def_map.borrow().get_copy(&path_id) {
match self.tcx.def_map.borrow()[path_id].clone() {
def::DefStaticMethod(..) => ck("static method"),
def::DefFn(..) => ck("function"),
def::DefStatic(..) => ck("static"),
Expand Down Expand Up @@ -873,7 +873,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
ty::ty_enum(_, _) => {
match self.tcx.def_map.borrow().get_copy(&expr.id) {
match self.tcx.def_map.borrow()[expr.id].clone() {
def::DefVariant(_, variant_id, _) => {
for field in fields.iter() {
self.check_field(expr.span, variant_id,
Expand Down Expand Up @@ -1254,7 +1254,7 @@ struct CheckTypeForPrivatenessVisitor<'a, 'b: 'a, 'tcx: 'b> {

impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
fn path_is_private_type(&self, path_id: ast::NodeId) -> bool {
let did = match self.tcx.def_map.borrow().find_copy(&path_id) {
let did = match self.tcx.def_map.borrow().get(&path_id).cloned() {
// `int` etc. (None doesn't seem to occur.)
None | Some(def::DefPrimTy(..)) => return false,
Some(def) => def.def_id()
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/middle/resolve.rs
Expand Up @@ -1097,7 +1097,7 @@ impl<'a> Resolver<'a> {
sp);

// Add or reuse the child.
let child = module_.children.borrow().find_copy(&name);
let child = module_.children.borrow().get(&name).cloned();
match child {
None => {
let child = Rc::new(NameBindings::new());
Expand Down Expand Up @@ -1381,7 +1381,7 @@ impl<'a> Resolver<'a> {
let mod_name = path.segments.last().unwrap().identifier.name;

let parent_opt = parent.module().children.borrow()
.find_copy(&mod_name);
.get(&mod_name).cloned();
let new_parent = match parent_opt {
// It already exists
Some(ref child) if child.get_module_if_available()
Expand Down Expand Up @@ -2676,7 +2676,7 @@ impl<'a> Resolver<'a> {
BoundResult(..) => {}
_ => {
match containing_module.external_module_children.borrow_mut()
.find_copy(&source) {
.get(&source).cloned() {
None => {} // Continue.
Some(module) => {
debug!("(resolving single import) found external \
Expand Down Expand Up @@ -3191,7 +3191,7 @@ impl<'a> Resolver<'a> {
fn search_parent_externals(needle: Name, module: &Rc<Module>)
-> Option<Rc<Module>> {
module.external_module_children.borrow()
.find_copy(&needle)
.get(&needle).cloned()
.map(|_| module.clone())
.or_else(|| {
match module.parent_link.clone() {
Expand Down Expand Up @@ -3478,7 +3478,7 @@ impl<'a> Resolver<'a> {

// Search for external modules.
if namespace == TypeNS {
match module_.external_module_children.borrow().find_copy(&name) {
match module_.external_module_children.borrow().get(&name).cloned() {
None => {}
Some(module) => {
let name_bindings =
Expand Down Expand Up @@ -3763,7 +3763,7 @@ impl<'a> Resolver<'a> {

// Finally, search through external children.
if namespace == TypeNS {
match module_.external_module_children.borrow().find_copy(&name) {
match module_.external_module_children.borrow().get(&name).cloned() {
None => {}
Some(module) => {
let name_bindings =
Expand Down Expand Up @@ -4043,7 +4043,7 @@ impl<'a> Resolver<'a> {
// item, it's ok
match def {
DefTyParam(_, did, _) if {
self.def_map.borrow().find_copy(&did.node)
self.def_map.borrow().get(&did.node).cloned()
== Some(DefTyParamBinder(item_id))
} => {} // ok
DefSelfTy(did) if did == item_id => {} // ok
Expand Down Expand Up @@ -4096,7 +4096,7 @@ impl<'a> Resolver<'a> {
// item, it's ok
match def {
DefTyParam(_, did, _) if {
self.def_map.borrow().find_copy(&did.node)
self.def_map.borrow().get(&did.node).cloned()
== Some(DefTyParamBinder(item_id))
} => {} // ok
DefSelfTy(did) if did == item_id => {} // ok
Expand Down Expand Up @@ -4148,7 +4148,7 @@ impl<'a> Resolver<'a> {
// FIXME #4950: Try caching?

for (i, rib) in ribs.iter().enumerate().rev() {
match rib.bindings.find_copy(&name) {
match rib.bindings.get(&name).cloned() {
Some(def_like) => {
return self.upvarify(ribs[i + 1..], def_like, span);
}
Expand Down Expand Up @@ -5440,7 +5440,7 @@ impl<'a> Resolver<'a> {
// Finally, search through external children.
if namespace == TypeNS {
match containing_module.external_module_children.borrow()
.find_copy(&name) {
.get(&name).cloned() {
None => {}
Some(module) => {
match module.def_id.get() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Expand Up @@ -139,7 +139,7 @@ pub fn lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
lookup(tcx, trait_method_id)
}
_ if is_local(id) => {
tcx.stability.borrow().local.find_copy(&id.node)
tcx.stability.borrow().local.get(&id.node).cloned()
}
_ => {
let stab = csearch::get_stability(&tcx.sess.cstore, id);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/_match.rs
Expand Up @@ -568,7 +568,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast::PatLit(ref l) => ConstantValue(ConstantExpr(&**l)),
ast::PatIdent(..) | ast::PatEnum(..) | ast::PatStruct(..) => {
// This is either an enum variant or a variable binding.
let opt_def = tcx.def_map.borrow().find_copy(&cur.id);
let opt_def = tcx.def_map.borrow().get(&cur.id).cloned();
match opt_def {
Some(def::DefVariant(enum_id, var_id, _)) => {
let variant = ty::enum_variant_with_id(tcx, enum_id, var_id);
Expand Down Expand Up @@ -1642,7 +1642,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ast::PatEnum(_, ref sub_pats) => {
let opt_def = bcx.tcx().def_map.borrow().find_copy(&pat.id);
let opt_def = bcx.tcx().def_map.borrow().get(&pat.id).cloned();
match opt_def {
Some(def::DefVariant(enum_id, var_id, _)) => {
let repr = adt::represent_node(bcx, pat.id);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -2274,7 +2274,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
static");
}

let v = ccx.static_values().borrow().get_copy(&item.id);
let v = ccx.static_values().borrow()[item.id].clone();
unsafe {
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
ccx.sess().span_fatal(expr.span, "static assertion failed");
Expand Down Expand Up @@ -2666,7 +2666,7 @@ fn contains_null(s: &str) -> bool {
pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
debug!("get_item_val(id=`{}`)", id);

match ccx.item_vals().borrow().find_copy(&id) {
match ccx.item_vals().borrow().get(&id).cloned() {
Some(v) => return v,
None => {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/common.rs
Expand Up @@ -526,12 +526,12 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
}

fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow {
self.tcx().upvar_borrow_map.borrow().get_copy(&upvar_id)
self.tcx().upvar_borrow_map.borrow()[upvar_id].clone()
}

fn capture_mode(&self, closure_expr_id: ast::NodeId)
-> ast::CaptureClause {
self.tcx().capture_modes.borrow().get_copy(&closure_expr_id)
self.tcx().capture_modes.borrow()[closure_expr_id].clone()
}
}

Expand Down

13 comments on commit dfb7a81

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at Gankra@dfb7a81

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Gankro/rust/cloned = dfb7a81 into auto

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gankro/rust/cloned = dfb7a81 merged ok, testing candidate = 12488a66

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at Gankra@dfb7a81

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Gankro/rust/cloned = dfb7a81 into auto

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gankro/rust/cloned = dfb7a81 merged ok, testing candidate = 066497ab

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at Gankra@dfb7a81

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Gankro/rust/cloned = dfb7a81 into auto

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gankro/rust/cloned = dfb7a81 merged ok, testing candidate = edfb83c

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on dfb7a81 Nov 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = edfb83c

Please sign in to comment.