]> git.lizzy.rs Git - rust.git/commitdiff
fallout from deprecating find_copy and get_copy
authorAlexis Beingessner <a.beingessner@gmail.com>
Fri, 7 Nov 2014 19:35:18 +0000 (14:35 -0500)
committerAlexis Beingessner <a.beingessner@gmail.com>
Sun, 16 Nov 2014 15:40:25 +0000 (10:40 -0500)
29 files changed:
src/librustc/lint/builtin.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/tydecode.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/move_data.rs
src/librustc/middle/check_match.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/liveness.rs
src/librustc/middle/privacy.rs
src/librustc/middle/resolve.rs
src/librustc/middle/stability.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/type_of.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/coherence/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/libstd/collections/hash/map.rs
src/libsyntax/ext/tt/transcribe.rs

index 86dd967026b846604711107812320574483de9b3..c2bb702d5c0ac94c151e2dce411867637886cf7e 100644 (file)
@@ -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 \
@@ -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 {
index 251b7c0c141772a74491f2f61bda414f2213e092..322191701e29012dda6374964a43f04e4c9648a4 100644 (file)
@@ -1863,7 +1863,7 @@ fn visit_item(&mut self, item: &Item) {
         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
index 26b2afd2f3c319c6a8c6709f111e0f5d6638c696..364cc298e8cbd9c0522b12a2273dd45b2070d3bc 100644 (file)
@@ -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 => {}
         }
index 0ca53054f1c154ad0e14482cefa1fbcdf9929af9..e20a7901e656a763692911ec632971d7433089b8 100644 (file)
@@ -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);
                         })
index becc0dbf6246987208b47afa39b3058f1a754670..b38246647d6d55a9d1a556c6c372d01453c04e89 100644 (file)
@@ -295,7 +295,7 @@ pub fn move_path(&self,
 
     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>)
@@ -312,7 +312,7 @@ fn add_existing_base_paths(&self, lp: &Rc<LoanPath>,
          * 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);
index a893f8e89598dc75984b70620789e3cacbc23941..74a438190fa867d528d9e4a5e0918990bd80869b 100644 (file)
@@ -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) => {
@@ -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 \
@@ -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 \
@@ -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 \
index fdda5f1a860e6dce1248bec81427880393582d8a..1a3267492d2a99340256601a3510b65e876a4fc5 100644 (file)
@@ -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)
@@ -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); }
               _ => {}
@@ -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),
index 95ebdd8214ec6a08fde8063588bbc2bd98fca964..16e8adb8adf89b59ec09aabfad948c06d92e344c 100644 (file)
@@ -850,7 +850,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt, pat: &ast::Pat) {
 
                 // 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);
@@ -957,8 +957,7 @@ fn walk_by_ref_captures(&mut self,
             // 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,
index dff9c45611aa9f634cf6f736e01068a9717921ed..d1f78cf0417018e6be6d6d6d54283e3fad3dc694 100644 (file)
@@ -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)),
@@ -1316,7 +1316,7 @@ fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
 
     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 {
@@ -1582,7 +1582,7 @@ fn check_ret(&self,
     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
index 1ecdf6b5d158b46dd4b4a4f445d9ba0dea7a1257..e9884d0376de1f4404a1a3f7fa791029da9a1673 100644 (file)
@@ -245,7 +245,7 @@ fn visit_item(&mut self, item: &ast::Item) {
             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();
@@ -313,7 +313,7 @@ fn visit_item(&mut self, item: &ast::Item) {
             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();
@@ -620,7 +620,7 @@ fn ensure_public(&self, span: Span, to_check: ast::DefId,
                             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) {
@@ -706,7 +706,7 @@ fn check_static_method(&mut self,
     // 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
@@ -789,7 +789,7 @@ fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
         // 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"),
@@ -873,7 +873,7 @@ fn visit_expr(&mut self, expr: &ast::Expr) {
                         }
                     }
                     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,
@@ -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()
index 62d1e13d41f0665071e370fe0490b0291b4b907b..e4a6b14767f1a1391475f4cb45314346984a9788 100644 (file)
@@ -1097,7 +1097,7 @@ fn add_child(&self,
                                                                    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());
@@ -1381,7 +1381,7 @@ fn build_reduced_graph_for_item(&mut self,
                         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()
@@ -2676,7 +2676,7 @@ fn get_binding(this: &mut Resolver,
             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 \
@@ -3191,7 +3191,7 @@ fn resolve_module_path_from_root(&mut self,
         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() {
@@ -3478,7 +3478,7 @@ fn resolve_item_in_lexical_scope(&mut self,
 
         // 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 =
@@ -3763,7 +3763,7 @@ fn resolve_name_in_module(&mut self,
 
         // 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 =
@@ -4043,7 +4043,7 @@ fn upvarify(&self,
                             // 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
@@ -4096,7 +4096,7 @@ fn upvarify(&self,
                             // 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
@@ -4148,7 +4148,7 @@ fn search_ribs(&self,
         // 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);
                 }
@@ -5440,7 +5440,7 @@ fn resolve_definition_of_name_in_module(&mut self,
         // 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() {
index 3b7ad9e8f6b344cf4358556134c12c14381dd42c..49bbfd0be479a2422ec334123d3b5290b4d6e17e 100644 (file)
@@ -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);
index 7b0ebe631e0e16331d82feb369fa09853c188d27..46a72ae8dc0a152301b0c341c21097275d68ac5a 100644 (file)
@@ -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);
@@ -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);
index d02c5dfa9e9fc012d4deae72e14e6a0a7797a2fd..d79d703336fe0f56a3be45254b5bdae9f83bd79e 100644 (file)
@@ -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");
@@ -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 => {}
     }
index c0380f87036b6359a22492ea91e2cd01a29fad0d..dbc4c58020f62889ed02628d760ad34dd6945bd0 100644 (file)
@@ -526,12 +526,12 @@ fn unboxed_closures<'a>(&'a self)
     }
 
     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()
     }
 }
 
index 409809e0cb33b006324e2ec9683c7b385c822ff3..6c8ae8b45ffeeebed41371018044c46163e562c9 100644 (file)
@@ -185,7 +185,7 @@ pub fn get_const_val(cx: &CrateContext,
         }
     }
 
-    cx.const_values().borrow().get_copy(&def_id.node)
+    cx.const_values().borrow()[def_id.node].clone()
 }
 
 pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) {
@@ -193,7 +193,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) {
     let mut llconst = llconst;
     let ety = ty::expr_ty(cx.tcx(), e);
     let mut ety_adjusted = ty::expr_ty_adjusted(cx.tcx(), e);
-    let opt_adj = cx.tcx().adjustments.borrow().find_copy(&e.id);
+    let opt_adj = cx.tcx().adjustments.borrow().get(&e.id).cloned();
     match opt_adj {
         None => { }
         Some(adj) => {
@@ -552,7 +552,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                       _ => break,
                   }
               }
-              let opt_def = cx.tcx().def_map.borrow().find_copy(&cur.id);
+              let opt_def = cx.tcx().def_map.borrow().get(&cur.id).cloned();
               match opt_def {
                   Some(def::DefStatic(def_id, _)) => {
                       let ty = ty::expr_ty(cx.tcx(), e);
@@ -627,7 +627,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
             // Assert that there are no type parameters in this path.
             assert!(pth.segments.iter().all(|seg| !seg.parameters.has_types()));
 
-            let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id);
+            let opt_def = cx.tcx().def_map.borrow().get(&e.id).cloned();
             match opt_def {
                 Some(def::DefFn(def_id, _)) => {
                     if !ast_util::is_local(def_id) {
@@ -661,7 +661,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
             }
           }
           ast::ExprCall(ref callee, ref args) => {
-              let opt_def = cx.tcx().def_map.borrow().find_copy(&callee.id);
+              let opt_def = cx.tcx().def_map.borrow().get(&callee.id).cloned();
               match opt_def {
                   Some(def::DefStruct(_)) => {
                       let ety = ty::expr_ty(cx.tcx(), e);
@@ -703,7 +703,7 @@ pub fn trans_static(ccx: &CrateContext, m: ast::Mutability, id: ast::NodeId) {
         let g = base::get_item_val(ccx, id);
         // At this point, get_item_val has already translated the
         // constant's initializer to determine its LLVM type.
-        let v = ccx.static_values().borrow().get_copy(&id);
+        let v = ccx.static_values().borrow()[id].clone();
         // boolean SSA values are i1, but they have to be stored in i8 slots,
         // otherwise some LLVM optimization passes don't work as expected
         let v = if llvm::LLVMTypeOf(v) == Type::i1(ccx).to_ref() {
index 2ba01aa922a743d0cc712b46f95664a0c24ae06b..aa3d9ae83fa7de44f9bfd3dfa2df13438895b7b1 100644 (file)
@@ -519,7 +519,7 @@ pub fn tydesc_type(&self) -> Type {
     }
 
     pub fn get_intrinsic(&self, key: & &'static str) -> ValueRef {
-        match self.intrinsics().borrow().find_copy(key) {
+        match self.intrinsics().borrow().get(key).cloned() {
             Some(v) => return v,
             _ => {}
         }
index fb6347af698162dd51b49c42fd55e291086b3134..ebf05f51e73cbfc3d935de25e82d26d22cff3a4e 100644 (file)
@@ -301,11 +301,11 @@ fn register_unique_id_with_metadata(&mut self,
     }
 
     fn find_metadata_for_type(&self, type_: ty::t) -> Option<DIType> {
-        self.type_to_metadata.find_copy(&type_)
+        self.type_to_metadata.get(&type_).cloned()
     }
 
     fn find_metadata_for_unique_id(&self, unique_type_id: UniqueTypeId) -> Option<DIType> {
-        self.unique_id_to_metadata.find_copy(&unique_type_id)
+        self.unique_id_to_metadata.get(&unique_type_id).cloned()
     }
 
     // Get the string representation of a UniqueTypeId. This method will fail if
@@ -341,7 +341,7 @@ fn get_unique_type_id_of_type(&mut self, cx: &CrateContext, type_: ty::t) -> Uni
         // unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
         // gc box               -> {GC_BOX<:pointee-uid:>}
 
-        match self.type_to_unique_id.find_copy(&type_) {
+        match self.type_to_unique_id.get(&type_).cloned() {
             Some(unique_type_id) => return unique_type_id,
             None => { /* generate one */}
         };
@@ -497,7 +497,7 @@ fn from_def_id_and_substs(type_map: &mut TypeMap,
             // First, find out the 'real' def_id of the type. Items inlined from
             // other crates have to be mapped back to their source.
             let source_def_id = if def_id.krate == ast::LOCAL_CRATE {
-                match cx.external_srcs().borrow().find_copy(&def_id.node) {
+                match cx.external_srcs().borrow().get(&def_id.node).cloned() {
                     Some(source_def_id) => {
                         // The given def_id identifies the inlined copy of a
                         // type definition, let's take the source of the copy.
@@ -851,7 +851,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
     pat_util::pat_bindings(def_map, &*local.pat, |_, node_id, span, path1| {
         let var_ident = path1.node;
 
-        let datum = match bcx.fcx.lllocals.borrow().find_copy(&node_id) {
+        let datum = match bcx.fcx.lllocals.borrow().get(&node_id).cloned() {
             Some(datum) => datum,
             None => {
                 bcx.sess().span_bug(span,
@@ -1014,7 +1014,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
     let scope_metadata = bcx.fcx.debug_context.get_ref(cx, arg.pat.span).fn_metadata;
 
     pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, span, path1| {
-        let llarg = match bcx.fcx.lllocals.borrow().find_copy(&node_id) {
+        let llarg = match bcx.fcx.lllocals.borrow().get(&node_id).cloned() {
             Some(v) => v,
             None => {
                 bcx.sess().span_bug(span,
@@ -1706,7 +1706,7 @@ fn scope_metadata(fcx: &FunctionContext,
     let scope_map = &fcx.debug_context
                         .get_ref(fcx.ccx, error_reporting_span)
                         .scope_map;
-    match scope_map.borrow().find_copy(&node_id) {
+    match scope_map.borrow().get(&node_id).cloned() {
         Some(scope_metadata) => scope_metadata,
         None => {
             let node = fcx.ccx.tcx().map.get(node_id);
@@ -2415,7 +2415,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
         // this cache.
         let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types
                                                                  .borrow()
-                                                                 .find_copy(&enum_def_id);
+                                                                 .get(&enum_def_id).cloned();
         match cached_discriminant_type_metadata {
             Some(discriminant_type_metadata) => discriminant_type_metadata,
             None => {
@@ -3982,7 +3982,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
             current_key.push(name);
 
             let existing_node = debug_context(cx).namespace_map.borrow()
-                                                 .find_copy(&current_key);
+                                                 .get(&current_key).cloned();
             let current_node = match existing_node {
                 Some(existing_node) => existing_node,
                 None => {
index 4b61f0c1409116a003c7004f6867ff7e87bf8e91..ea590a669d0f98bb82e56d6c281233713a3aedba 100644 (file)
@@ -184,7 +184,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     let mut bcx = bcx;
     let mut datum = datum;
-    let adjustment = match bcx.tcx().adjustments.borrow().find_copy(&expr.id) {
+    let adjustment = match bcx.tcx().adjustments.borrow().get(&expr.id).cloned() {
         None => {
             return DatumBlock::new(bcx, datum);
         }
@@ -1293,7 +1293,7 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt,
                         ty.repr(tcx)).as_slice());
                 }
                 Some(node_id) => {
-                    let def = tcx.def_map.borrow().get_copy(&node_id);
+                    let def = tcx.def_map.borrow()[node_id].clone();
                     match def {
                         def::DefVariant(enum_id, variant_id, _) => {
                             let variant_info = ty::enum_variant_with_id(
index 098b82fe38c181e8a16d34496898b3c45546567f..553e0b22d5c704bed8011c8667015d19d2de76b6 100644 (file)
@@ -301,7 +301,7 @@ pub fn trans_static_method_callee(bcx: Block,
 
 fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name)
                     -> ast::DefId {
-    match ccx.impl_method_cache().borrow().find_copy(&(impl_id, name)) {
+    match ccx.impl_method_cache().borrow().get(&(impl_id, name)).cloned() {
         Some(m) => return m,
         None => {}
     }
index 9530c86a94c111416a8ddd155f25892370fc0681..092fe2d1fa91e60b16a7015df653cd87069ee037 100644 (file)
@@ -175,7 +175,7 @@ pub fn type_of_fn_from_ty(cx: &CrateContext, fty: ty::t) -> Type {
 //     recursive types. For example, enum types rely on this behavior.
 
 pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
-    match cx.llsizingtypes().borrow().find_copy(&t) {
+    match cx.llsizingtypes().borrow().get(&t).cloned() {
         Some(t) => return t,
         None => ()
     }
index 0a3c4e76fa0096b45cc506d24ac90bba01dcf063..8ec5e381b92c5b050109f0104ee93d7cf27f7596 100644 (file)
@@ -3194,7 +3194,7 @@ pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
 }
 
 pub fn try_node_id_to_type(cx: &ctxt, id: ast::NodeId) -> Option<t> {
-    cx.node_types.borrow().find_copy(&id)
+    cx.node_types.borrow().get(&id).cloned()
 }
 
 pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> t {
@@ -4055,7 +4055,7 @@ fn lookup_locally_or_in_crate_store<V:Clone>(
      * the crate loading code (and cache the result for the future).
      */
 
-    match map.find_copy(&def_id) {
+    match map.get(&def_id).cloned() {
         Some(v) => { return v; }
         None => { }
     }
@@ -4077,7 +4077,7 @@ pub fn trait_item(cx: &ctxt, trait_did: ast::DefId, idx: uint)
 pub fn trait_items(cx: &ctxt, trait_did: ast::DefId)
                    -> Rc<Vec<ImplOrTraitItem>> {
     let mut trait_items = cx.trait_items_cache.borrow_mut();
-    match trait_items.find_copy(&trait_did) {
+    match trait_items.get(&trait_did).cloned() {
         Some(trait_items) => trait_items,
         None => {
             let def_ids = ty::trait_item_def_ids(cx, trait_did);
@@ -4627,7 +4627,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
     // This may change if abstract return types of some sort are
     // implemented.
     assert!(closure_id.krate == ast::LOCAL_CRATE);
-    let capture_mode = tcx.capture_modes.borrow().get_copy(&closure_id.node);
+    let capture_mode = tcx.capture_modes.borrow()[closure_id.node].clone();
     match tcx.freevars.borrow().get(&closure_id.node) {
         None => vec![],
         Some(ref freevars) => {
@@ -4636,10 +4636,10 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
                 let freevar_ty = node_id_to_type(tcx, freevar_def_id.node);
                 let mut freevar_ty = freevar_ty.subst(tcx, substs);
                 if capture_mode == ast::CaptureByRef {
-                    let borrow = tcx.upvar_borrow_map.borrow().get_copy(&ty::UpvarId {
+                    let borrow = tcx.upvar_borrow_map.borrow()[ty::UpvarId {
                         var_id: freevar_def_id.node,
                         closure_expr_id: closure_id.node
-                    });
+                    }].clone();
                     freevar_ty = mk_rptr(tcx, borrow.region, ty::mt {
                         ty: freevar_ty,
                         mutbl: borrow.kind.to_mutbl_lossy()
@@ -4738,7 +4738,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeNormalizer<'a, 'tcx> {
         fn tcx(&self) -> &ctxt<'tcx> { let TypeNormalizer(c) = *self; c }
 
         fn fold_ty(&mut self, t: ty::t) -> ty::t {
-            match self.tcx().normalized_cache.borrow().find_copy(&t) {
+            match self.tcx().normalized_cache.borrow().get(&t).cloned() {
                 None => {}
                 Some(u) => return u
             }
@@ -4902,7 +4902,7 @@ fn push_region_bounds(region_bounds: &[ty::Region],
 
 pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, String> {
     tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| {
-        tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item)
+        tcx.intrinsic_defs.borrow().get(&tydesc_lang_item).cloned()
             .expect("Failed to resolve TyDesc")
     })
 }
@@ -5053,7 +5053,7 @@ pub fn impl_of_method(tcx: &ctxt, def_id: ast::DefId)
             ImplContainer(def_id) => Some(def_id),
         };
     }
-    match tcx.impl_or_trait_items.borrow().find_copy(&def_id) {
+    match tcx.impl_or_trait_items.borrow().get(&def_id).cloned() {
         Some(trait_item) => {
             match trait_item.container() {
                 TraitContainer(_) => None,
@@ -5071,7 +5071,7 @@ pub fn trait_of_item(tcx: &ctxt, def_id: ast::DefId) -> Option<ast::DefId> {
     if def_id.krate != LOCAL_CRATE {
         return csearch::get_trait_of_item(&tcx.sess.cstore, def_id, tcx);
     }
-    match tcx.impl_or_trait_items.borrow().find_copy(&def_id) {
+    match tcx.impl_or_trait_items.borrow().get(&def_id).cloned() {
         Some(impl_or_trait_item) => {
             match impl_or_trait_item.container() {
                 TraitContainer(def_id) => Some(def_id),
@@ -5461,12 +5461,12 @@ fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId> {
     }
 
     fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow {
-        self.upvar_borrow_map.borrow().get_copy(&upvar_id)
+        self.upvar_borrow_map.borrow()[upvar_id].clone()
     }
 
     fn capture_mode(&self, closure_expr_id: ast::NodeId)
                     -> ast::CaptureClause {
-        self.capture_modes.borrow().get_copy(&closure_expr_id)
+        self.capture_modes.borrow()[closure_expr_id].clone()
     }
 
     fn unboxed_closures<'a>(&'a self)
index c15b6e6ddae2e86df9067156348936e33e6bb1bd..90c3d8c4f3f1d6c1a5e681f856eb2d77a230ccfe 100644 (file)
@@ -71,7 +71,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
             demand::eqtype(fcx, pat.span, expected, lhs_ty);
         }
         ast::PatEnum(..) | ast::PatIdent(..) if pat_is_const(&tcx.def_map, pat) => {
-            let const_did = tcx.def_map.borrow().get_copy(&pat.id).def_id();
+            let const_did = tcx.def_map.borrow()[pat.id].clone().def_id();
             let const_pty = ty::lookup_item_type(tcx, const_did);
             fcx.write_ty(pat.id, const_pty.ty);
             demand::suptype(fcx, pat.span, expected, const_pty.ty);
@@ -296,7 +296,7 @@ pub fn check_pat_struct(pcx: &pat_ctxt, pat: &ast::Pat,
     let fcx = pcx.fcx;
     let tcx = pcx.fcx.ccx.tcx;
 
-    let def = tcx.def_map.borrow().get_copy(&pat.id);
+    let def = tcx.def_map.borrow()[pat.id].clone();
     let def_type = ty::lookup_item_type(tcx, def.def_id());
     let (enum_def_id, variant_def_id) = match ty::get(def_type.ty).sty {
         ty::ty_struct(struct_def_id, _) =>
@@ -341,7 +341,7 @@ pub fn check_pat_enum(pcx: &pat_ctxt, pat: &ast::Pat,
     let fcx = pcx.fcx;
     let tcx = pcx.fcx.ccx.tcx;
 
-    let def = tcx.def_map.borrow().get_copy(&pat.id);
+    let def = tcx.def_map.borrow()[pat.id].clone();
     let enum_def = def.variant_def_ids()
         .map_or_else(|| def.def_id(), |(enum_def, _)| enum_def);
 
@@ -449,7 +449,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
             }
             Vacant(vacant) => {
                 vacant.set(span);
-                field_type_map.find_copy(&field.ident.name)
+                field_type_map.get(&field.ident.name).cloned()
                     .unwrap_or_else(|| {
                         span_err!(tcx.sess, span, E0026,
                             "struct `{}` does not have a field named `{}`",
index cac702d6ac0c32c1b7b4e7f0413dc7801a39383d..0cf5069218ede4c12f5bac928f77092b6746b811 100644 (file)
@@ -309,7 +309,7 @@ fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId> {
         self.tcx().temporary_scope(rvalue_id)
     }
     fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow {
-        self.inh.upvar_borrow_map.borrow().get_copy(&upvar_id)
+        self.inh.upvar_borrow_map.borrow()[upvar_id].clone()
     }
     fn capture_mode(&self, closure_expr_id: ast::NodeId)
                     -> ast::CaptureClause {
@@ -450,7 +450,7 @@ fn visit_local(&mut self, local: &ast::Local) {
         debug!("Local variable {} is assigned type {}",
                self.fcx.pat_to_string(&*local.pat),
                self.fcx.infcx().ty_to_string(
-                   self.fcx.inh.locals.borrow().get_copy(&local.id)));
+                   self.fcx.inh.locals.borrow()[local.id].clone()));
         visit::walk_local(self, local);
     }
 
@@ -467,7 +467,7 @@ fn visit_pat(&mut self, p: &ast::Pat) {
                     debug!("Pattern binding {} is assigned to {} with type {}",
                            token::get_ident(path1.node),
                            self.fcx.infcx().ty_to_string(
-                               self.fcx.inh.locals.borrow().get_copy(&p.id)),
+                               self.fcx.inh.locals.borrow()[p.id].clone()),
                            var_ty.repr(self.fcx.tcx()));
                 }
             _ => {}
index 9aa047e068f61801ecbb4d7ddde625df62f19239..c63e8944dbdcac2906af9c88d8be786d6fdbc294 100644 (file)
@@ -479,12 +479,12 @@ fn temporary_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
     }
 
     fn upvar_borrow(&self, id: ty::UpvarId) -> ty::UpvarBorrow {
-        self.fcx.inh.upvar_borrow_map.borrow().get_copy(&id)
+        self.fcx.inh.upvar_borrow_map.borrow()[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()
     }
 
     fn unboxed_closures<'a>(&'a self)
@@ -871,7 +871,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
             });
         }
         ty::ty_unboxed_closure(_, region, _) => {
-            if tcx.capture_modes.borrow().get_copy(&expr.id) == ast::CaptureByRef {
+            if tcx.capture_modes.borrow()[expr.id].clone() == ast::CaptureByRef {
                 ty::with_freevars(tcx, expr.id, |freevars| {
                     if !freevars.is_empty() {
                         // Variables being referenced must be constrained and registered
@@ -896,7 +896,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
             })
         }
         ty::ty_unboxed_closure(..) => {
-            if tcx.capture_modes.borrow().get_copy(&expr.id) == ast::CaptureByRef {
+            if tcx.capture_modes.borrow()[expr.id].clone() == ast::CaptureByRef {
                 ty::with_freevars(tcx, expr.id, |freevars| {
                     propagate_upupvar_borrow_kind(rcx, expr, freevars);
                 });
@@ -1847,7 +1847,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx,
            inner_upvar_id, outer_upvar_id);
 
     let mut upvar_borrow_map = rcx.fcx.inh.upvar_borrow_map.borrow_mut();
-    let inner_borrow = upvar_borrow_map.get_copy(&inner_upvar_id);
+    let inner_borrow = upvar_borrow_map[inner_upvar_id].clone();
     match upvar_borrow_map.get_mut(&outer_upvar_id) {
         Some(outer_borrow) => {
             adjust_upvar_borrow_kind(rcx, outer_upvar_id, outer_borrow, inner_borrow.kind);
index 898d987ace7cb0367422f8ba7a0e2ac3ee0fb062..9e4728195b6d576320cdc397774b824235f3b3ed 100644 (file)
@@ -317,7 +317,7 @@ fn add_trait_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
 
     fn get_self_type_for_implementation(&self, impl_did: DefId)
                                         -> Polytype {
-        self.crate_context.tcx.tcache.borrow().get_copy(&impl_did)
+        self.crate_context.tcx.tcache.borrow()[impl_did].clone()
     }
 
     // Converts an implementation in the AST to a vector of items.
@@ -428,7 +428,7 @@ fn populate_destructor_table(&self) {
         };
 
         let impl_items = tcx.impl_items.borrow();
-        let trait_impls = match tcx.trait_impls.borrow().find_copy(&drop_trait) {
+        let trait_impls = match tcx.trait_impls.borrow().get(&drop_trait).cloned() {
             None => return, // No types with (new-style) dtors present.
             Some(found_impls) => found_impls
         };
index dcf618d94c29d57745bb56dcc66a9d1d5af60bff..d57343e004bab8896daf4606f2518cf6f5ceb75e 100644 (file)
@@ -1520,7 +1520,7 @@ fn process_edges(this: &RegionVarBindings,
                     ConstrainVarSubReg(_, region) => {
                         state.result.push(RegionAndOrigin {
                             region: region,
-                            origin: this.constraints.borrow().get_copy(&edge.data)
+                            origin: this.constraints.borrow()[edge.data].clone()
                         });
                     }
                 }
index b4e78d1064b08aae4a9e851ed4adeed5a43307b7..779cd425d2a6ee70c70acf47fec846bd6590be43 100644 (file)
@@ -37,7 +37,6 @@
 };
 
 // FIXME(conventions): update capacity management to match other collections (no auto-shrink)
-// FIXME(conventions): axe find_copy/get_copy in favour of Option.cloned (also implement that)
 
 const INITIAL_LOG2_CAP: uint = 5;
 pub const INITIAL_CAPACITY: uint = 1 << INITIAL_LOG2_CAP; // 2^5
@@ -1826,6 +1825,7 @@ fn test_find() {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn test_find_copy() {
         let mut m = HashMap::new();
         assert!(m.get(&1i).is_none());
index 5842afe11ce2ccf67cfdef4c1f9ad5cf34bc3091..3cb861aac20c13c6ef5318bbb1e918f77ed6a944 100644 (file)
@@ -94,7 +94,7 @@ fn lookup_cur_matched_by_matched(r: &TtReader, start: Rc<NamedMatch>) -> Rc<Name
 }
 
 fn lookup_cur_matched(r: &TtReader, name: Ident) -> Option<Rc<NamedMatch>> {
-    let matched_opt = r.interpolations.find_copy(&name);
+    let matched_opt = r.interpolations.get(&name).cloned();
     matched_opt.map(|s| lookup_cur_matched_by_matched(r, s))
 }