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 \
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 {
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
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 => {}
}
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);
})
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>)
* 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);
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) => {
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 \
}
&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 \
&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 \
}
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)
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); }
_ => {}
}
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),
// 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);
// 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,
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)),
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 {
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
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();
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();
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) {
// 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
// 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"),
}
}
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,
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()
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());
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()
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 \
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() {
// 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 =
// 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 =
// 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
// 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
// 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);
}
// 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() {
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);
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);
}
}
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);
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");
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 => {}
}
}
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()
}
}
}
}
- 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) {
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) => {
_ => 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);
// 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) {
}
}
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);
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() {
}
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,
_ => {}
}
}
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
// 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 */}
};
// 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.
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,
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,
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);
// 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 => {
current_key.push(name);
let existing_node = debug_context(cx).namespace_map.borrow()
- .find_copy(¤t_key);
+ .get(¤t_key).cloned();
let current_node = match existing_node {
Some(existing_node) => existing_node,
None => {
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);
}
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(
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 => {}
}
// 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 => ()
}
}
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 {
* 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 => { }
}
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);
// 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) => {
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()
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
}
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")
})
}
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,
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),
}
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)
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);
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, _) =>
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);
}
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 `{}`",
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 {
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);
}
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()));
}
_ => {}
}
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)
});
}
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
})
}
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);
});
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);
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.
};
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
};
ConstrainVarSubReg(_, region) => {
state.result.push(RegionAndOrigin {
region: region,
- origin: this.constraints.borrow().get_copy(&edge.data)
+ origin: this.constraints.borrow()[edge.data].clone()
});
}
}
};
// 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
}
#[test]
+ #[allow(deprecated)]
fn test_find_copy() {
let mut m = HashMap::new();
assert!(m.get(&1i).is_none());
}
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))
}