Skip to content

Commit dfb7a81

Browse files
committed
fallout from deprecating find_copy and get_copy
1 parent 64efd26 commit dfb7a81

29 files changed

+92
-94
lines changed

src/librustc/lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
391391

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

869-
match cx.tcx.impl_or_trait_items.borrow().find_copy(&did) {
869+
match cx.tcx.impl_or_trait_items.borrow().get(&did).cloned() {
870870
None => cx.sess().span_bug(m.span, "missing method descriptor?!"),
871871
Some(md) => {
872872
match md {

src/librustc/metadata/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
18631863
match item.node {
18641864
ItemImpl(_, Some(ref trait_ref), _, _) => {
18651865
let def_map = &self.ecx.tcx.def_map;
1866-
let trait_def = def_map.borrow().get_copy(&trait_ref.ref_id);
1866+
let trait_def = def_map.borrow()[trait_ref.ref_id].clone();
18671867
let def_id = trait_def.def_id();
18681868

18691869
// Load eagerly if this is an implementation of the Drop trait

src/librustc/metadata/tydecode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
440440
pos: pos,
441441
len: len };
442442

443-
match st.tcx.rcache.borrow().find_copy(&key) {
443+
match st.tcx.rcache.borrow().get(&key).cloned() {
444444
Some(tt) => return tt,
445445
None => {}
446446
}

src/librustc/middle/astencode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1200,8 +1200,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12001200
var_id: var_id,
12011201
closure_expr_id: id
12021202
};
1203-
let upvar_borrow = tcx.upvar_borrow_map.borrow()
1204-
.get_copy(&upvar_id);
1203+
let upvar_borrow = tcx.upvar_borrow_map.borrow()[upvar_id].clone();
12051204
var_id.encode(rbml_w);
12061205
upvar_borrow.encode(rbml_w);
12071206
})

src/librustc/middle/borrowck/move_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl MoveData {
295295

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

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

315-
match self.path_map.borrow().find_copy(lp) {
315+
match self.path_map.borrow().get(lp).cloned() {
316316
Some(index) => {
317317
self.each_base_path(index, |p| {
318318
result.push(p);

src/librustc/middle/check_match.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
360360
fn fold_pat(&mut self, pat: P<Pat>) -> P<Pat> {
361361
match pat.node {
362362
PatIdent(..) | PatEnum(..) => {
363-
let def = self.tcx.def_map.borrow().find_copy(&pat.id);
363+
let def = self.tcx.def_map.borrow().get(&pat.id).cloned();
364364
match def {
365365
Some(DefConst(did)) => match lookup_const_by_id(self.tcx, did) {
366366
Some(const_expr) => {
@@ -753,7 +753,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
753753
Some(Vec::from_elem(arity, DUMMY_WILD_PAT)),
754754

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

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

787787
&PatStruct(_, ref pattern_fields, _) => {
788788
// Is this a struct or an enum variant?
789-
let def = cx.tcx.def_map.borrow().get_copy(&pat_id);
789+
let def = cx.tcx.def_map.borrow()[pat_id].clone();
790790
let class_id = match def {
791791
DefConst(..) =>
792792
cx.tcx.sess.span_bug(pat_span, "const pattern should've \

src/librustc/middle/const_eval.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn join_all<It: Iterator<constness>>(mut cs: It) -> constness {
8585
}
8686

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

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

355355
ExprPath(ref path) => {
356-
let opt_def = tcx.def_map.borrow().find_copy(&expr.id);
356+
let opt_def = tcx.def_map.borrow().get(&expr.id).cloned();
357357
match opt_def {
358358
Some(def::DefStruct(..)) =>
359359
PatStruct(path.clone(), vec![], false),

src/librustc/middle/expr_use_visitor.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
850850

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

963962
self.delegate.borrow(closure_expr.id,
964963
closure_expr.span,

src/librustc/middle/liveness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
449449
match expr.node {
450450
// live nodes required for uses or definitions of variables:
451451
ExprPath(_) => {
452-
let def = ir.tcx.def_map.borrow().get_copy(&expr.id);
452+
let def = ir.tcx.def_map.borrow()[expr.id].clone();
453453
debug!("expr {}: path that leads to {}", expr.id, def);
454454
match def {
455455
DefLocal(..) => ir.add_live_node_for_node(expr.id, ExprNode(expr.span)),
@@ -1316,7 +1316,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13161316

13171317
fn access_path(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
13181318
-> LiveNode {
1319-
match self.ir.tcx.def_map.borrow().get_copy(&expr.id) {
1319+
match self.ir.tcx.def_map.borrow()[expr.id].clone() {
13201320
DefLocal(nid) => {
13211321
let ln = self.live_node(expr.id, expr.span);
13221322
if acc != 0u {
@@ -1582,7 +1582,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15821582
fn check_lvalue(&mut self, expr: &Expr) {
15831583
match expr.node {
15841584
ExprPath(_) => {
1585-
match self.ir.tcx.def_map.borrow().get_copy(&expr.id) {
1585+
match self.ir.tcx.def_map.borrow()[expr.id].clone() {
15861586
DefLocal(nid) => {
15871587
// Assignment to an immutable variable or argument: only legal
15881588
// if there is no later assignment. If this local is actually

src/librustc/middle/privacy.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
245245
ast::ItemImpl(_, _, ref ty, ref impl_items) => {
246246
let public_ty = match ty.node {
247247
ast::TyPath(_, _, id) => {
248-
match self.tcx.def_map.borrow().get_copy(&id) {
248+
match self.tcx.def_map.borrow()[id].clone() {
249249
def::DefPrimTy(..) => true,
250250
def => {
251251
let did = def.def_id();
@@ -313,7 +313,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
313313
ast::ItemTy(ref ty, _) if public_first => {
314314
match ty.node {
315315
ast::TyPath(_, _, id) => {
316-
match self.tcx.def_map.borrow().get_copy(&id) {
316+
match self.tcx.def_map.borrow()[id].clone() {
317317
def::DefPrimTy(..) | def::DefTyParam(..) => {},
318318
def => {
319319
let did = def.def_id();
@@ -620,7 +620,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
620620
ast::TyPath(_, _, id) => id,
621621
_ => return Some((err_span, err_msg, None)),
622622
};
623-
let def = self.tcx.def_map.borrow().get_copy(&id);
623+
let def = self.tcx.def_map.borrow()[id].clone();
624624
let did = def.def_id();
625625
assert!(is_local(did));
626626
match self.tcx.map.get(did.node) {
@@ -706,7 +706,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
706706
// Checks that a path is in scope.
707707
fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
708708
debug!("privacy - path {}", self.nodestr(path_id));
709-
let orig_def = self.tcx.def_map.borrow().get_copy(&path_id);
709+
let orig_def = self.tcx.def_map.borrow()[path_id].clone();
710710
let ck = |tyname: &str| {
711711
let ck_public = |def: ast::DefId| {
712712
let name = token::get_ident(path.segments
@@ -789,7 +789,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
789789
// def map is not. Therefore the names we work out below will not always
790790
// be accurate and we can get slightly wonky error messages (but type
791791
// checking is always correct).
792-
match self.tcx.def_map.borrow().get_copy(&path_id) {
792+
match self.tcx.def_map.borrow()[path_id].clone() {
793793
def::DefStaticMethod(..) => ck("static method"),
794794
def::DefFn(..) => ck("function"),
795795
def::DefStatic(..) => ck("static"),
@@ -873,7 +873,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
873873
}
874874
}
875875
ty::ty_enum(_, _) => {
876-
match self.tcx.def_map.borrow().get_copy(&expr.id) {
876+
match self.tcx.def_map.borrow()[expr.id].clone() {
877877
def::DefVariant(_, variant_id, _) => {
878878
for field in fields.iter() {
879879
self.check_field(expr.span, variant_id,
@@ -1254,7 +1254,7 @@ struct CheckTypeForPrivatenessVisitor<'a, 'b: 'a, 'tcx: 'b> {
12541254

12551255
impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
12561256
fn path_is_private_type(&self, path_id: ast::NodeId) -> bool {
1257-
let did = match self.tcx.def_map.borrow().find_copy(&path_id) {
1257+
let did = match self.tcx.def_map.borrow().get(&path_id).cloned() {
12581258
// `int` etc. (None doesn't seem to occur.)
12591259
None | Some(def::DefPrimTy(..)) => return false,
12601260
Some(def) => def.def_id()

src/librustc/middle/resolve.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ impl<'a> Resolver<'a> {
10971097
sp);
10981098

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

13831383
let parent_opt = parent.module().children.borrow()
1384-
.find_copy(&mod_name);
1384+
.get(&mod_name).cloned();
13851385
let new_parent = match parent_opt {
13861386
// It already exists
13871387
Some(ref child) if child.get_module_if_available()
@@ -2676,7 +2676,7 @@ impl<'a> Resolver<'a> {
26762676
BoundResult(..) => {}
26772677
_ => {
26782678
match containing_module.external_module_children.borrow_mut()
2679-
.find_copy(&source) {
2679+
.get(&source).cloned() {
26802680
None => {} // Continue.
26812681
Some(module) => {
26822682
debug!("(resolving single import) found external \
@@ -3191,7 +3191,7 @@ impl<'a> Resolver<'a> {
31913191
fn search_parent_externals(needle: Name, module: &Rc<Module>)
31923192
-> Option<Rc<Module>> {
31933193
module.external_module_children.borrow()
3194-
.find_copy(&needle)
3194+
.get(&needle).cloned()
31953195
.map(|_| module.clone())
31963196
.or_else(|| {
31973197
match module.parent_link.clone() {
@@ -3478,7 +3478,7 @@ impl<'a> Resolver<'a> {
34783478

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

37643764
// Finally, search through external children.
37653765
if namespace == TypeNS {
3766-
match module_.external_module_children.borrow().find_copy(&name) {
3766+
match module_.external_module_children.borrow().get(&name).cloned() {
37673767
None => {}
37683768
Some(module) => {
37693769
let name_bindings =
@@ -4043,7 +4043,7 @@ impl<'a> Resolver<'a> {
40434043
// item, it's ok
40444044
match def {
40454045
DefTyParam(_, did, _) if {
4046-
self.def_map.borrow().find_copy(&did.node)
4046+
self.def_map.borrow().get(&did.node).cloned()
40474047
== Some(DefTyParamBinder(item_id))
40484048
} => {} // ok
40494049
DefSelfTy(did) if did == item_id => {} // ok
@@ -4096,7 +4096,7 @@ impl<'a> Resolver<'a> {
40964096
// item, it's ok
40974097
match def {
40984098
DefTyParam(_, did, _) if {
4099-
self.def_map.borrow().find_copy(&did.node)
4099+
self.def_map.borrow().get(&did.node).cloned()
41004100
== Some(DefTyParamBinder(item_id))
41014101
} => {} // ok
41024102
DefSelfTy(did) if did == item_id => {} // ok
@@ -4148,7 +4148,7 @@ impl<'a> Resolver<'a> {
41484148
// FIXME #4950: Try caching?
41494149

41504150
for (i, rib) in ribs.iter().enumerate().rev() {
4151-
match rib.bindings.find_copy(&name) {
4151+
match rib.bindings.get(&name).cloned() {
41524152
Some(def_like) => {
41534153
return self.upvarify(ribs[i + 1..], def_like, span);
41544154
}
@@ -5440,7 +5440,7 @@ impl<'a> Resolver<'a> {
54405440
// Finally, search through external children.
54415441
if namespace == TypeNS {
54425442
match containing_module.external_module_children.borrow()
5443-
.find_copy(&name) {
5443+
.get(&name).cloned() {
54445444
None => {}
54455445
Some(module) => {
54465446
match module.def_id.get() {

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
139139
lookup(tcx, trait_method_id)
140140
}
141141
_ if is_local(id) => {
142-
tcx.stability.borrow().local.find_copy(&id.node)
142+
tcx.stability.borrow().local.get(&id.node).cloned()
143143
}
144144
_ => {
145145
let stab = csearch::get_stability(&tcx.sess.cstore, id);

src/librustc/middle/trans/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
568568
ast::PatLit(ref l) => ConstantValue(ConstantExpr(&**l)),
569569
ast::PatIdent(..) | ast::PatEnum(..) | ast::PatStruct(..) => {
570570
// This is either an enum variant or a variable binding.
571-
let opt_def = tcx.def_map.borrow().find_copy(&cur.id);
571+
let opt_def = tcx.def_map.borrow().get(&cur.id).cloned();
572572
match opt_def {
573573
Some(def::DefVariant(enum_id, var_id, _)) => {
574574
let variant = ty::enum_variant_with_id(tcx, enum_id, var_id);
@@ -1642,7 +1642,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16421642
}
16431643
}
16441644
ast::PatEnum(_, ref sub_pats) => {
1645-
let opt_def = bcx.tcx().def_map.borrow().find_copy(&pat.id);
1645+
let opt_def = bcx.tcx().def_map.borrow().get(&pat.id).cloned();
16461646
match opt_def {
16471647
Some(def::DefVariant(enum_id, var_id, _)) => {
16481648
let repr = adt::represent_node(bcx, pat.id);

src/librustc/middle/trans/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
22742274
static");
22752275
}
22762276

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

2669-
match ccx.item_vals().borrow().find_copy(&id) {
2669+
match ccx.item_vals().borrow().get(&id).cloned() {
26702670
Some(v) => return v,
26712671
None => {}
26722672
}

src/librustc/middle/trans/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,12 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
526526
}
527527

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

532532
fn capture_mode(&self, closure_expr_id: ast::NodeId)
533533
-> ast::CaptureClause {
534-
self.tcx().capture_modes.borrow().get_copy(&closure_expr_id)
534+
self.tcx().capture_modes.borrow()[closure_expr_id].clone()
535535
}
536536
}
537537

0 commit comments

Comments
 (0)