}
// Jettison the task away!
- self.handles.get_mut(idx).send(TaskFromFriend(task));
+ self.handles[idx].send(TaskFromFriend(task));
}
/// Spawns a new scheduler into this M:N pool. A handle is returned to the
let len = work_queues.len();
let start_index = self.rng.gen_range(0, len);
for index in range(0, len).map(|i| (i + start_index) % len) {
- match work_queues.get_mut(index).steal() {
+ match work_queues[index].steal() {
deque::Data(task) => {
rtdebug!("found task by stealing");
return Some(task)
}
fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> String {
- match ccx.type_hashcodes().borrow().find(&t) {
+ match ccx.type_hashcodes().borrow().get(&t) {
Some(h) => return h.to_string(),
None => {}
}
msg: String) {
let lint_id = lint::LintId::of(lint);
let mut lints = self.lints.borrow_mut();
- match lints.find_mut(&id) {
+ match lints.get_mut(&id) {
Some(arr) => { arr.push((lint_id, sp, msg)); return; }
None => {}
}
libc::c_uint or libc::c_ulong should be used");
}
def::DefTy(..) => {
- let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().find(&ty_id) {
+ let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty_id) {
Some(&ty::atttce_resolved(t)) => t,
_ => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
};
fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
match &p.node {
&ast::PatIdent(_, ref path1, _) => {
- match cx.tcx.def_map.borrow().find(&p.id) {
+ match cx.tcx.def_map.borrow().get(&p.id) {
Some(&def::DefLocal(_)) => {
self.check_snake_case(cx, "variable", path1.node, p.span);
}
fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
// Lint for constants that look like binding identifiers (#7526)
- match (&p.node, cx.tcx.def_map.borrow().find(&p.id)) {
+ match (&p.node, cx.tcx.def_map.borrow().get(&p.id)) {
(&ast::PatIdent(_, ref path1, _), Some(&def::DefConst(..))) => {
let s = token::get_ident(path1.node);
if s.get().chars().any(|c| c.is_lowercase()) {
ast::PatStruct(_, ref v, _) => {
for fieldpat in v.iter()
.filter(|fieldpat| !fieldpat.node.is_shorthand)
- .filter(|fieldpat| def_map.find(&fieldpat.node.pat.id)
+ .filter(|fieldpat| def_map.get(&fieldpat.node.pat.id)
== Some(&def::DefLocal(fieldpat.node.pat.id))) {
match fieldpat.node.pat.node {
ast::PatIdent(_, ident, None) if ident.node.as_str()
_ => return
}
- match cx.tcx.adjustments.borrow().find(&e.id) {
+ match cx.tcx.adjustments.borrow().get(&e.id) {
Some(adjustment) => {
match *adjustment {
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
let id = match e.node {
ast::ExprPath(..) | ast::ExprStruct(..) => {
- match cx.tcx.def_map.borrow().find(&e.id) {
+ match cx.tcx.def_map.borrow().get(&e.id) {
Some(&def) => def.def_id(),
None => return
}
ast::ExprMethodCall(i, _, _) => {
span = i.span;
let method_call = typeck::MethodCall::expr(e.id);
- match cx.tcx.method_map.borrow().find(&method_call) {
+ match cx.tcx.method_map.borrow().get(&method_call) {
Some(method) => {
match method.origin {
typeck::MethodStatic(def_id) => {
impl LintStore {
fn get_level_source(&self, lint: LintId) -> LevelSource {
- match self.levels.find(&lint) {
+ match self.levels.get(&lint) {
Some(&s) => s,
None => (Allow, Default),
}
self.lints.push((*lint, from_plugin));
let id = LintId::of(*lint);
- if !self.by_name.insert(lint.name_lower(), Id(id)) {
+ if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {
let msg = format!("duplicate specification of lint {}", lint.name_lower());
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
pub fn register_group(&mut self, sess: Option<&Session>,
from_plugin: bool, name: &'static str,
to: Vec<LintId>) {
- let new = self.lint_groups.insert(name, (to, from_plugin));
+ let new = self.lint_groups.insert(name, (to, from_plugin)).is_none();
if !new {
let msg = format!("duplicate specification of lint group {}", name);
/// Get the level of `lint` at the current position of the lint
/// traversal.
pub fn current_level(&self, lint: &'static Lint) -> Level {
- self.lints.levels.find(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
+ self.lints.levels.get(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
}
fn lookup_and_emit(&self, lint: &'static Lint, span: Option<Span>, msg: &str) {
- let (level, src) = match self.lints.levels.find(&LintId::of(lint)) {
+ let (level, src) = match self.lints.levels.get(&LintId::of(lint)) {
None => return,
Some(&(Warn, src)) => {
let lint_id = LintId::of(builtin::WARNINGS);
// Output any lints that were previously added to the session.
impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
fn visit_id(&mut self, id: ast::NodeId) {
- match self.tcx.sess.lints.borrow_mut().pop(&id) {
+ match self.tcx.sess.lints.borrow_mut().remove(&id) {
None => {}
Some(lints) => {
for (lint_id, span, msg) in lints.into_iter() {
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
-> Option<ast::CrateNum> {
- self.extern_mod_crate_map.borrow().find(&emod_id).map(|x| *x)
+ self.extern_mod_crate_map.borrow().get(&emod_id).map(|x| *x)
}
}
return ast::DefId { krate: cdata.cnum, node: did.node };
}
- match cdata.cnum_map.find(&did.krate) {
+ match cdata.cnum_map.get(&did.krate) {
Some(&n) => {
ast::DefId {
krate: n,
let cnum = spec.split(':').nth(0).unwrap();
let link = spec.split(':').nth(1).unwrap();
let cnum = from_str(cnum).unwrap();
- let cnum = match cdata.cnum_map.find(&cnum) {
+ let cnum = match cdata.cnum_map.get(&cnum) {
Some(&n) => n,
None => panic!("didn't find a crate in the cnum_map")
};
rbml_w: &mut Encoder,
id: NodeId) {
rbml_w.start_tag(tag_items_data_item_symbol);
- match ecx.item_symbols.borrow().find(&id) {
+ match ecx.item_symbols.borrow().get(&id) {
Some(x) => {
debug!("encode_symbol(id={}, str={})", id, *x);
rbml_w.writer.write(x.as_bytes());
exp: &middle::resolve::Export2)
-> bool {
let impl_items = ecx.tcx.impl_items.borrow();
- match ecx.tcx.inherent_impls.borrow().find(&exp.def_id) {
+ match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
Some(implementations) => {
for base_impl_did in implementations.iter() {
for &method_did in (*impl_items)[*base_impl_did].iter() {
rbml_w: &mut Encoder,
exp: &middle::resolve::Export2)
-> bool {
- match ecx.tcx.trait_items_cache.borrow().find(&exp.def_id) {
+ match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
Some(trait_items) => {
for trait_item in trait_items.iter() {
match *trait_item {
id: NodeId,
path: PathElems) {
debug!("(encoding info for module) encoding reexports for {}", id);
- match ecx.reexports2.find(&id) {
+ match ecx.reexports2.get(&id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
fn encode_inherent_implementations(ecx: &EncodeContext,
rbml_w: &mut Encoder,
def_id: DefId) {
- match ecx.tcx.inherent_impls.borrow().find(&def_id) {
+ match ecx.tcx.inherent_impls.borrow().get(&def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.iter() {
fn encode_extension_implementations(ecx: &EncodeContext,
rbml_w: &mut Encoder,
trait_def_id: DefId) {
- match ecx.tcx.trait_impls.borrow().find(&trait_def_id) {
+ match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.borrow().iter() {
fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
rbml_w.start_tag(tag_dylib_dependency_formats);
- match ecx.tcx.dependency_formats.borrow().find(&config::CrateTypeDylib) {
+ match ecx.tcx.dependency_formats.borrow().get(&config::CrateTypeDylib) {
Some(arr) => {
let s = arr.iter().enumerate().filter_map(|(i, slot)| {
slot.map(|kind| (format!("{}:{}", i + 1, match kind {
loop {
match next(st) {
'S' => {
- builtin_bounds.add(ty::BoundSend);
+ builtin_bounds.insert(ty::BoundSend);
}
'Z' => {
- builtin_bounds.add(ty::BoundSized);
+ builtin_bounds.insert(ty::BoundSized);
}
'P' => {
- builtin_bounds.add(ty::BoundCopy);
+ builtin_bounds.insert(ty::BoundCopy);
}
'T' => {
- builtin_bounds.add(ty::BoundSync);
+ builtin_bounds.insert(ty::BoundSync);
}
'.' => {
return builtin_bounds;
pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>;
pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: ty::t) {
- match cx.abbrevs.borrow_mut().find(&t) {
+ match cx.abbrevs.borrow_mut().get(&t) {
Some(a) => { w.write(a.s.as_bytes()); return; }
None => {}
}
debug!("Encoding side tables for id {}", id);
- for def in tcx.def_map.borrow().find(&id).iter() {
+ for def in tcx.def_map.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_def, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| (*def).encode(rbml_w).unwrap());
})
}
- for &ty in tcx.node_types.borrow().find(&(id as uint)).iter() {
+ for &ty in tcx.node_types.borrow().get(&(id as uint)).iter() {
rbml_w.tag(c::tag_table_node_type, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
})
}
- for &item_substs in tcx.item_substs.borrow().find(&id).iter() {
+ for &item_substs in tcx.item_substs.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_item_subst, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
})
}
- for &fv in tcx.freevars.borrow().find(&id).iter() {
+ for &fv in tcx.freevars.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_freevars, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
}
}
- for &cm in tcx.capture_modes.borrow().find(&id).iter() {
+ for &cm in tcx.capture_modes.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_capture_modes, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
}
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
- for &pty in tcx.tcache.borrow().find(&lid).iter() {
+ for &pty in tcx.tcache.borrow().get(&lid).iter() {
rbml_w.tag(c::tag_table_tcache, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
})
}
- for &type_param_def in tcx.ty_param_defs.borrow().find(&id).iter() {
+ for &type_param_def in tcx.ty_param_defs.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_param_defs, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
}
let method_call = MethodCall::expr(id);
- for &method in tcx.method_map.borrow().find(&method_call).iter() {
+ for &method in tcx.method_map.borrow().get(&method_call).iter() {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
})
}
- for &trait_ref in tcx.object_cast_map.borrow().find(&id).iter() {
+ for &trait_ref in tcx.object_cast_map.borrow().get(&id).iter() {
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
})
}
- for &adjustment in tcx.adjustments.borrow().find(&id).iter() {
+ for &adjustment in tcx.adjustments.borrow().get(&id).iter() {
match *adjustment {
_ if ty::adjust_is_object(adjustment) => {
let method_call = MethodCall::autoobject(id);
- for &method in tcx.method_map.borrow().find(&method_call).iter() {
+ for &method in tcx.method_map.borrow().get(&method_call).iter() {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
assert!(!ty::adjust_is_object(adjustment));
for autoderef in range(0, adj.autoderefs) {
let method_call = MethodCall::autoderef(id, autoderef);
- for &method in tcx.method_map.borrow().find(&method_call).iter() {
+ for &method in tcx.method_map.borrow().get(&method_call).iter() {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
for unboxed_closure in tcx.unboxed_closures
.borrow()
- .find(&ast_util::local_def(id))
+ .get(&ast_util::local_def(id))
.iter() {
rbml_w.tag(c::tag_table_unboxed_closures, |rbml_w| {
rbml_w.id(id);
* base paths that do not yet have an index.
*/
- match self.path_map.borrow().find(&lp) {
+ match self.path_map.borrow().get(&lp) {
Some(&index) => {
return index;
}
//! Returns the kind of a move of `loan_path` by `id`, if one exists.
let mut ret = None;
- for loan_path_index in self.move_data.path_map.borrow().find(&*loan_path).iter() {
+ for loan_path_index in self.move_data.path_map.borrow().get(&*loan_path).iter() {
self.dfcx_moves.each_gen_bit(id, |move_index| {
let the_move = self.move_data.moves.borrow();
let the_move = (*the_move)[move_index];
func_or_rcvr: &ast::Expr,
args: I) -> CFGIndex {
let method_call = typeck::MethodCall::expr(call_expr.id);
- let return_ty = ty::ty_fn_ret(match self.tcx.method_map.borrow().find(&method_call) {
+ let return_ty = ty::ty_fn_ret(match self.tcx.method_map.borrow().get(&method_call) {
Some(method) => method.ty,
None => ty::expr_ty(self.tcx, func_or_rcvr)
});
}
Some(_) => {
- match self.tcx.def_map.borrow().find(&expr.id) {
+ match self.tcx.def_map.borrow().get(&expr.id) {
Some(&def::DefLabel(loop_id)) => {
for l in self.loop_scopes.iter() {
if l.loop_id == loop_id {
"paths in constants may only refer to items without \
type parameters");
}
- match v.tcx.def_map.borrow().find(&e.id) {
+ match v.tcx.def_map.borrow().get(&e.id) {
Some(&DefStatic(..)) |
Some(&DefConst(..)) |
Some(&DefFn(..)) |
}
}
ExprCall(ref callee, _) => {
- match v.tcx.def_map.borrow().find(&callee.id) {
+ match v.tcx.def_map.borrow().get(&callee.id) {
Some(&DefStruct(..)) |
Some(&DefVariant(..)) => {} // OK.
let pat = raw_pat(p);
match pat.node {
PatIdent(..) =>
- match cx.tcx.def_map.borrow().find(&pat.id) {
+ match cx.tcx.def_map.borrow().get(&pat.id) {
Some(&DefConst(..)) =>
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
been rewritten"),
_ => vec!()
},
PatEnum(..) =>
- match cx.tcx.def_map.borrow().find(&pat.id) {
+ match cx.tcx.def_map.borrow().get(&pat.id) {
Some(&DefConst(..)) =>
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
been rewritten"),
_ => vec!(Single)
},
PatStruct(..) =>
- match cx.tcx.def_map.borrow().find(&pat.id) {
+ match cx.tcx.def_map.borrow().get(&pat.id) {
Some(&DefConst(..)) =>
cx.tcx.sess.span_bug(pat.span, "const pattern should've \
been rewritten"),
fn visit_expr(&mut self, e: &ast::Expr) {
match e.node {
ast::ExprPath(..) => {
- match self.def_map.borrow().find(&e.id) {
+ match self.def_map.borrow().get(&e.id) {
Some(&DefStatic(def_id, _)) |
Some(&DefConst(def_id)) if
ast_util::is_local(def_id) => {
Some(_) => None
}
} else {
- match tcx.extern_const_variants.borrow().find(&variant_def) {
+ match tcx.extern_const_variants.borrow().get(&variant_def) {
Some(&ast::DUMMY_NODE_ID) => return None,
Some(&expr_id) => {
return Some(tcx.map.expect_expr(expr_id));
Some(_) => None
}
} else {
- match tcx.extern_const_statics.borrow().find(&def_id) {
+ match tcx.extern_const_statics.borrow().get(&def_id) {
Some(&ast::DUMMY_NODE_ID) => return None,
Some(&expr_id) => {
return Some(tcx.map.expect_expr(expr_id));
impl<'a, 'tcx> ConstEvalVisitor<'a, 'tcx> {
fn classify(&mut self, e: &Expr) -> constness {
let did = ast_util::local_def(e.id);
- match self.ccache.find(&did) {
+ match self.ccache.get(&did) {
Some(&x) => return x,
None => {}
}
}
fn to_cfgidx_or_die(id: ast::NodeId, index: &NodeMap<CFGIndex>) -> CFGIndex {
- let opt_cfgindex = index.find(&id).map(|&i|i);
+ let opt_cfgindex = index.get(&id).map(|&i|i);
opt_cfgindex.unwrap_or_else(|| {
panic!("nodeid_to_index does not have entry for NodeId {}", id);
})
let mut changed = false;
for &node_id in edge.data.exiting_scopes.iter() {
- let opt_cfg_idx = self.nodeid_to_index.find(&node_id).map(|&i|i);
+ let opt_cfg_idx = self.nodeid_to_index.get(&node_id).map(|&i|i);
match opt_cfg_idx {
Some(cfg_idx) => {
let (start, end) = self.compute_id_range(cfg_idx);
}
fn lookup_and_handle_definition(&mut self, id: &ast::NodeId) {
- self.tcx.def_map.borrow().find(id).map(|def| {
+ self.tcx.def_map.borrow().get(id).map(|def| {
match def {
&def::DefConst(_) => {
self.check_def_id(def.def_id())
fn lookup_and_handle_method(&mut self, id: ast::NodeId,
span: codemap::Span) {
let method_call = typeck::MethodCall::expr(id);
- match self.tcx.method_map.borrow().find(&method_call) {
+ match self.tcx.method_map.borrow().get(&method_call) {
Some(method) => {
match method.origin {
typeck::MethodStatic(def_id) => {
// method of a private type is used, but the type itself is never
// called directly.
let impl_items = self.tcx.impl_items.borrow();
- match self.tcx.inherent_impls.borrow().find(&local_def(id)) {
+ match self.tcx.inherent_impls.borrow().get(&local_def(id)) {
None => (),
Some(impl_list) => {
for impl_did in impl_list.iter() {
// Collect what we've got so far in the return vector.
let mut ret = range(1, sess.cstore.next_crate_num()).map(|i| {
- match formats.find(&i).map(|v| *v) {
+ match formats.get(&i).map(|v| *v) {
v @ Some(cstore::RequireDynamic) => v,
_ => None,
}
cnum: ast::CrateNum,
link: cstore::LinkagePreference,
m: &mut HashMap<ast::CrateNum, cstore::LinkagePreference>) {
- match m.find(&cnum) {
+ match m.get(&cnum) {
Some(&link2) => {
// If the linkages differ, then we'd have two copies of the library
// if we continued linking. If the linkages are both static, then we
let trait_did =
tcx.unboxed_closures
.borrow()
- .find(&closure_did)
+ .get(&closure_did)
.expect("OverloadedCallType::from_unboxed_closure: didn't \
find closure id")
.kind
match self.tcx()
.method_map
.borrow()
- .find(&MethodCall::expr(call.id)) {
+ .get(&MethodCall::expr(call.id)) {
Some(ref method_callee) => {
OverloadedCallType::from_method_origin(
self.tcx(),
// process.
fn walk_adjustment(&mut self, expr: &ast::Expr) {
let typer = self.typer;
- match typer.adjustments().borrow().find(&expr.id) {
+ match typer.adjustments().borrow().get(&expr.id) {
None => { }
Some(adjustment) => {
match *adjustment {
}
// Matched.
- *self.items.items.get_mut(item_index) = Some(item_def_id);
+ self.items.items[item_index] = Some(item_def_id);
}
pub fn collect_local_language_items(&mut self, krate: &ast::Crate) {
}
fn variable(&self, node_id: NodeId, span: Span) -> Variable {
- match self.variable_map.find(&node_id) {
+ match self.variable_map.get(&node_id) {
Some(&var) => var,
None => {
self.tcx
}
fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
- match self.ir.live_node_map.find(&node_id) {
+ match self.ir.live_node_map.get(&node_id) {
Some(&ln) => ln,
None => {
// This must be a mismatch between the ir_map construction
Some(_) => {
// Refers to a labeled loop. Use the results of resolve
// to find with one
- match self.ir.tcx.def_map.borrow().find(&id) {
+ match self.ir.tcx.def_map.borrow().get(&id) {
Some(&DefLabel(loop_id)) => loop_id,
_ => self.ir.tcx.sess.span_bug(sp, "label on break/loop \
doesn't refer to a loop")
// the construction of a closure itself is not important,
// but we have to consider the closed over variables.
- let caps = match this.ir.capture_info_map.find(&expr.id) {
+ let caps = match this.ir.capture_info_map.get(&expr.id) {
Some(caps) => caps.clone(),
None => {
this.ir.tcx.sess.span_bug(expr.span, "no registered caps");
// Now that we know the label we're going to,
// look it up in the break loop nodes table
- match self.break_ln.find(&sc) {
+ match self.break_ln.get(&sc) {
Some(&b) => b,
None => self.ir.tcx.sess.span_bug(expr.span,
"break to unknown label")
// Now that we know the label we're going to,
// look it up in the continue loop nodes table
- match self.cont_ln.find(&sc) {
+ match self.cont_ln.get(&sc) {
Some(&b) => b,
None => self.ir.tcx.sess.span_bug(expr.span,
"loop to unknown label")
ExprMethodCall(_, _, ref args) => {
let method_call = typeck::MethodCall::expr(expr.id);
- let method_ty = self.ir.tcx.method_map.borrow().find(&method_call).unwrap().ty;
+ let method_ty = self.ir.tcx.method_map.borrow().get(&method_call).unwrap().ty;
let diverges = ty::ty_fn_ret(method_ty) == ty::FnDiverging;
let succ = if diverges {
self.s.exit_ln
ty::ty_unboxed_closure(closure_def_id, _, _) =>
self.ir.tcx.unboxed_closures()
.borrow()
- .find(&closure_def_id)
+ .get(&closure_def_id)
.unwrap()
.closure_type
.sig
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<ty::t> {
let unadjusted_ty = if_ok!(self.expr_ty(expr));
Ok(ty::adjust_ty(self.tcx(), expr.span, expr.id, unadjusted_ty,
- self.typer.adjustments().borrow().find(&expr.id),
+ self.typer.adjustments().borrow().get(&expr.id),
|method_call| self.typer.node_method_ty(method_call)))
}
}
pub fn cat_expr(&self, expr: &ast::Expr) -> McResult<cmt> {
- match self.typer.adjustments().borrow().find(&expr.id) {
+ match self.typer.adjustments().borrow().get(&expr.id) {
None => {
// No adjustments.
self.cat_expr_unadjusted(expr)
deref_cnt: uint,
implicit: bool)
-> cmt {
- let adjustment = match self.typer.adjustments().borrow().find(&node.id()) {
+ let adjustment = match self.typer.adjustments().borrow().get(&node.id()) {
Some(adj) if ty::adjust_is_object(adj) => typeck::AutoObject,
_ if deref_cnt != 0 => typeck::AutoDeref(deref_cnt),
_ => typeck::NoAdjustment
// variant(..)
}
ast::PatEnum(_, Some(ref subpats)) => {
- match self.tcx().def_map.borrow().find(&pat.id) {
+ match self.tcx().def_map.borrow().get(&pat.id) {
Some(&def::DefVariant(enum_did, _, _)) => {
// variant(x, y, z)
match pat.node {
PatLit(_) | PatRange(_, _) => true,
PatEnum(_, _) | PatIdent(_, _, None) | PatStruct(..) => {
- match dm.borrow().find(&pat.id) {
+ match dm.borrow().get(&pat.id) {
Some(&DefVariant(..)) => true,
_ => false
}
pub fn pat_is_variant_or_struct(dm: &resolve::DefMap, pat: &Pat) -> bool {
match pat.node {
PatEnum(_, _) | PatIdent(_, _, None) | PatStruct(..) => {
- match dm.borrow().find(&pat.id) {
+ match dm.borrow().get(&pat.id) {
Some(&DefVariant(..)) | Some(&DefStruct(..)) => true,
_ => false
}
pub fn pat_is_const(dm: &resolve::DefMap, pat: &Pat) -> bool {
match pat.node {
PatIdent(_, _, None) | PatEnum(..) => {
- match dm.borrow().find(&pat.id) {
+ match dm.borrow().get(&pat.id) {
Some(&DefConst(..)) => true,
_ => false
}
}
debug!("privacy - is {} a public method", did);
- return match self.tcx.impl_or_trait_items.borrow().find(&did) {
+ return match self.tcx.impl_or_trait_items.borrow().get(&did) {
Some(&ty::MethodTraitItem(ref meth)) => {
debug!("privacy - well at least it's a method: {}",
*meth);
debug!("privacy - local {} not public all the way down",
self.tcx.map.node_to_string(did.node));
// return quickly for things in the same module
- if self.parents.find(&did.node) == self.parents.find(&self.curitem) {
+ if self.parents.get(&did.node) == self.parents.get(&self.curitem) {
debug!("privacy - same parent, we're done here");
return Allowable;
}
}
ast::ExprMethodCall(ident, _, _) => {
let method_call = MethodCall::expr(expr.id);
- match self.tcx.method_map.borrow().find(&method_call) {
+ match self.tcx.method_map.borrow().get(&method_call) {
None => {
self.tcx.sess.span_bug(expr.span,
"method call not in \
with private fields");
}
};
- match self.tcx.def_map.borrow().find(&expr.id) {
+ match self.tcx.def_map.borrow().get(&expr.id) {
Some(&def::DefStruct(did)) => {
guard(if is_local(did) {
local_def(self.tcx.map.get_parent(did.node))
}
}
ty::ty_enum(_, _) => {
- match self.tcx.def_map.borrow().find(&pattern.id) {
+ match self.tcx.def_map.borrow().get(&pattern.id) {
Some(&def::DefVariant(_, variant_id, _)) => {
for field in fields.iter() {
self.check_field(pattern.span, variant_id,
match expr.node {
ast::ExprPath(_) => {
- let def = match self.tcx.def_map.borrow().find(&expr.id) {
+ let def = match self.tcx.def_map.borrow().get(&expr.id) {
Some(&def) => def,
None => {
self.tcx.sess.span_bug(expr.span,
impl RegionMaps {
pub fn relate_free_regions(&self, sub: FreeRegion, sup: FreeRegion) {
- match self.free_region_map.borrow_mut().find_mut(&sub) {
+ match self.free_region_map.borrow_mut().get_mut(&sub) {
Some(sups) => {
if !sups.iter().any(|x| x == &sup) {
sups.push(sup);
pub fn opt_encl_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
//! Returns the narrowest scope that encloses `id`, if any.
- self.scope_map.borrow().find(&id).map(|x| *x)
+ self.scope_map.borrow().get(&id).map(|x| *x)
}
#[allow(dead_code)] // used in middle::cfg
pub fn encl_scope(&self, id: ast::NodeId) -> ast::NodeId {
//! Returns the narrowest scope that encloses `id`, if any.
- match self.scope_map.borrow().find(&id) {
+ match self.scope_map.borrow().get(&id) {
Some(&r) => r,
None => { panic!("no enclosing scope for id {}", id); }
}
/*!
* Returns the lifetime of the local variable `var_id`
*/
- match self.var_map.borrow().find(&var_id) {
+ match self.var_map.borrow().get(&var_id) {
Some(&r) => r,
None => { panic!("no enclosing scope for id {}", var_id); }
}
//! Returns the scope when temp created by expr_id will be cleaned up
// check for a designated rvalue scope
- match self.rvalue_scopes.borrow().find(&expr_id) {
+ match self.rvalue_scopes.borrow().get(&expr_id) {
Some(&s) => {
debug!("temporary_scope({}) = {} [custom]", expr_id, s);
return Some(s);
let mut s = subscope;
while superscope != s {
- match self.scope_map.borrow().find(&s) {
+ match self.scope_map.borrow().get(&s) {
None => {
debug!("is_subscope_of({}, {}, s={})=false",
subscope, superscope, s);
let mut result = vec!(scope);
let mut scope = scope;
loop {
- match this.scope_map.borrow().find(&scope) {
+ match this.scope_map.borrow().get(&scope) {
None => return result,
Some(&superscope) => {
result.push(superscope);
let mut import_resolutions = module_.import_resolutions
.borrow_mut();
- match import_resolutions.find_mut(&target) {
+ match import_resolutions.get_mut(&target) {
Some(resolution) => {
debug!("(building import directive) bumping \
reference");
// Search for direct children of the containing module.
self.populate_module_if_necessary(&containing_module);
- match containing_module.children.borrow().find(&source) {
+ match containing_module.children.borrow().get(&source) {
None => {
// Continue.
}
}
// Now search the exported imports within the containing module.
- match containing_module.import_resolutions.borrow().find(&source) {
+ match containing_module.import_resolutions.borrow().get(&source) {
None => {
debug!("(resolving single import) no import");
// The containing module definitely doesn't have an
// Here we merge two import resolutions.
let mut import_resolutions = module_.import_resolutions.borrow_mut();
- match import_resolutions.find_mut(ident) {
+ match import_resolutions.get_mut(ident) {
Some(dest_import_resolution) => {
// Merge the two import resolutions at a finer-grained
// level.
// Check for item conflicts.
let children = module.children.borrow();
- let name_bindings = match children.find(&name) {
+ let name_bindings = match children.get(&name) {
None => {
// There can't be any conflicts.
return
// its immediate children.
self.populate_module_if_necessary(&module_);
- match module_.children.borrow().find(&name) {
+ match module_.children.borrow().get(&name) {
Some(name_bindings)
if name_bindings.defined_in_namespace(namespace) => {
debug!("top name bindings succeeded");
// all its imports in the usual way; this is because chains of
// adjacent import statements are processed as though they mutated the
// current scope.
- match module_.import_resolutions.borrow().find(&name) {
+ match module_.import_resolutions.borrow().get(&name) {
None => {
// Not found; continue.
}
// First, check the direct children of the module.
self.populate_module_if_necessary(&module_);
- match module_.children.borrow().find(&name) {
+ match module_.children.borrow().get(&name) {
Some(name_bindings)
if name_bindings.defined_in_namespace(namespace) => {
debug!("(resolving name in module) found node as child");
}
// Check the list of resolved imports.
- match module_.import_resolutions.borrow().find(&name) {
+ match module_.import_resolutions.borrow().get(&name) {
Some(import_resolution) if allow_private_imports ||
import_resolution.is_public => {
Some(name) => {
self.populate_module_if_necessary(&orig_module);
- match orig_module.children.borrow().find(&name) {
+ match orig_module.children.borrow().get(&name) {
None => {
debug!("!!! (with scope) didn't find `{}` in `{}`",
token::get_name(name),
Some(ref trait_ref) => {
self.resolve_trait_reference(id, trait_ref, TraitImplementation);
- match self.def_map.borrow().find(&trait_ref.ref_id) {
+ match self.def_map.borrow().get(&trait_ref.ref_id) {
Some(def) => {
let did = def.def_id();
Some((did, trait_ref.clone()))
// a type (shadowing any imported modules or types with this name), leading
// to weird user-visible bugs. So we ward this off here. See #15060.
TyPath(ref path, _, path_id) => {
- match self.def_map.borrow().find(&path_id) {
+ match self.def_map.borrow().get(&path_id) {
// FIXME: should we catch other options and give more precise errors?
Some(&DefMod(_)) => {
self.resolve_error(path.span, "inherent implementations are not \
fn check_trait_item(&self, name: Name, span: Span) {
// If there is a TraitRef in scope for an impl, then the method must be in the trait.
for &(did, ref trait_ref) in self.current_trait_ref.iter() {
- if self.trait_item_map.find(&(name, did)).is_none() {
+ if self.trait_item_map.get(&(name, did)).is_none() {
let path_str = self.path_names_to_string(&trait_ref.path);
self.resolve_error(span,
format!("method `{}` is not a member of trait `{}`",
let map_i = self.binding_mode_map(&**p);
for (&key, &binding_0) in map_0.iter() {
- match map_i.find(&key) {
+ match map_i.get(&key) {
None => {
self.resolve_error(
p.span,
// Move down in the graph, if there's an anonymous module rooted here.
let orig_module = self.current_module.clone();
- match orig_module.anonymous_children.borrow().find(&block.id) {
+ match orig_module.anonymous_children.borrow().get(&block.id) {
None => { /* Nothing to do. */ }
Some(anonymous_module) => {
debug!("(resolving block) found anonymous module, moving \
match self.primitive_type_table
.primitive_types
- .find(&id.name) {
+ .get(&id.name) {
Some(&primitive_type) => {
result_def =
token::get_ident(
ident))
.as_slice())
- } else if bindings_list.find(&renamed) ==
+ } else if bindings_list.get(&renamed) ==
Some(&pat_id) {
// Then this is a duplicate variable in the
// same disjunction, which is an error.
// First, search children.
self.populate_module_if_necessary(&containing_module);
- match containing_module.children.borrow().find(&name) {
+ match containing_module.children.borrow().get(&name) {
Some(child_name_bindings) => {
match child_name_bindings.def_for_namespace(namespace) {
Some(def) => {
}
// Next, search import resolutions.
- match containing_module.import_resolutions.borrow().find(&name) {
+ match containing_module.import_resolutions.borrow().get(&name) {
Some(import_resolution) if import_resolution.is_public => {
match (*import_resolution).target_for_namespace(namespace) {
Some(target) => {
let last_name = name_path.last().unwrap();
if name_path.len() == 1 {
- match this.primitive_type_table.primitive_types.find(last_name) {
+ match this.primitive_type_table.primitive_types.get(last_name) {
Some(_) => None,
None => {
- match this.current_module.children.borrow().find(last_name) {
+ match this.current_module.children.borrow().get(last_name) {
Some(child) => child.get_module_if_available(),
None => None
}
if allowed == Everything {
// Look for a field with the same name in the current self_type.
- match self.def_map.borrow().find(&node_id) {
+ match self.def_map.borrow().get(&node_id) {
Some(&DefTy(did, _))
| Some(&DefStruct(did))
- | Some(&DefVariant(_, did, _)) => match self.structs.find(&did) {
+ | Some(&DefVariant(_, did, _)) => match self.structs.get(&did) {
None => {}
Some(fields) => {
if fields.iter().any(|&field_name| name == field_name) {
// Look for a method in the current self type's impl module.
match get_module(self, path.span, name_path.as_slice()) {
- Some(module) => match module.children.borrow().find(&name) {
+ Some(module) => match module.children.borrow().get(&name) {
Some(binding) => {
let p_str = self.path_names_to_string(&path);
match binding.def_for_namespace(ValueNS) {
Some((did, ref trait_ref)) => {
let path_str = self.path_names_to_string(&trait_ref.path);
- match self.trait_item_map.find(&(name, did)) {
+ match self.trait_item_map.get(&(name, did)) {
Some(&StaticMethodTraitItemKind) => {
return TraitMethod(path_str)
}
"unused import".to_string());
}
- let (v_priv, t_priv) = match self.last_private.find(&id) {
+ let (v_priv, t_priv) = match self.last_private.get(&id) {
Some(&LastImport {
value_priv: v,
value_used: _,
{
let cache = self.pick_candidate_cache(&cache_skol_trait_ref);
let hashmap = cache.hashmap.borrow();
- hashmap.find(&cache_skol_trait_ref).map(|c| (*c).clone())
+ hashmap.get(&cache_skol_trait_ref).map(|c| (*c).clone())
}
fn insert_candidate_cache(&mut self,
self_ty.repr(self.tcx()),
obligation.repr(self.tcx()));
- let closure_kind = match self.typer.unboxed_closures().borrow().find(&closure_def_id) {
+ let closure_kind = match self.typer.unboxed_closures().borrow().get(&closure_def_id) {
Some(closure) => closure.kind,
None => {
self.tcx().sess.span_bug(
ty::BoundSync |
ty::BoundSend => {
- if c.bounds.builtin_bounds.contains_elem(bound) {
+ if c.bounds.builtin_bounds.contains(&bound) {
Ok(If(Vec::new()))
} else {
Err(Unimplemented)
ty::BoundSync |
ty::BoundSend => {
- if c.bounds.builtin_bounds.contains_elem(bound) {
+ if c.bounds.builtin_bounds.contains(&bound) {
Ok(If(Vec::new()))
} else {
Err(Unimplemented)
Err(Unimplemented)
}
ty::BoundCopy | ty::BoundSync | ty::BoundSend => {
- if bounds.builtin_bounds.contains_elem(bound) {
+ if bounds.builtin_bounds.contains(&bound) {
Ok(If(Vec::new()))
} else {
Err(Unimplemented)
// is reserve judgement and then intertwine this
// analysis with closure inference.
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
- match self.tcx().freevars.borrow().find(&def_id.node) {
+ match self.tcx().freevars.borrow().get(&def_id.node) {
None => {
// No upvars.
Ok(If(Vec::new()))
closure_def_id.repr(self.tcx()),
substs.repr(self.tcx()));
- let closure_type = match self.typer.unboxed_closures().borrow().find(&closure_def_id) {
+ let closure_type = match self.typer.unboxed_closures().borrow().get(&closure_def_id) {
Some(closure) => closure.closure_type.clone(),
None => {
self.tcx().sess.span_bug(
ty::populate_implementations_for_trait_if_necessary(self.tcx(),
trait_def_id);
- match self.tcx().trait_impls.borrow().find(&trait_def_id) {
+ match self.tcx().trait_impls.borrow().get(&trait_def_id) {
None => Vec::new(),
Some(impls) => impls.borrow().clone()
}
match pat.node {
ast::PatTup(_) => true,
ast::PatStruct(..) => {
- match tcx.def_map.borrow().find(&pat.id) {
+ match tcx.def_map.borrow().get(&pat.id) {
Some(&def::DefVariant(..)) => false,
_ => true,
}
}
ast::PatEnum(..) | ast::PatIdent(_, _, None) => {
- match tcx.def_map.borrow().find(&pat.id) {
+ match tcx.def_map.borrow().get(&pat.id) {
Some(&def::DefStruct(..)) => true,
_ => false
}
/// Decides how to represent a given type.
pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> {
debug!("Representing: {}", ty_to_string(cx.tcx(), t));
- match cx.adt_reprs().borrow().find(&t) {
+ match cx.adt_reprs().borrow().get(&t) {
Some(repr) => return repr.clone(),
None => {}
}
t: ty::t) -> ValueRef {
let name = csearch::get_symbol(&ccx.sess().cstore, did);
let ty = type_of(ccx, t);
- match ccx.externs().borrow_mut().find(&name) {
+ match ccx.externs().borrow_mut().get(&name) {
Some(n) => return *n,
None => ()
}
// Type descriptor and type glue stuff
pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> Rc<tydesc_info> {
- match ccx.tydescs().borrow().find(&t) {
+ match ccx.tydescs().borrow().get(&t) {
Some(inf) => return inf.clone(),
_ => { }
}
let levels = ccx.tcx().node_lint_levels.borrow();
let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCES);
- let lvlsrc = match levels.find(&(id, lint_id)) {
+ let lvlsrc = match levels.get(&(id, lint_id)) {
None | Some(&(lint::Allow, _)) => return,
Some(&lvlsrc) => lvlsrc,
};
fn exported_name(ccx: &CrateContext, id: ast::NodeId,
ty: ty::t, attrs: &[ast::Attribute]) -> String {
- match ccx.external_srcs().borrow().find(&id) {
+ match ccx.external_srcs().borrow().get(&id) {
Some(&did) => {
let sym = csearch::get_symbol(&ccx.sess().cstore, did);
debug!("found item {} in other crate...", sym);
.collect();
let mut reachable: Vec<String> = shared_ccx.reachable().iter().filter_map(|id| {
- shared_ccx.item_symbols().borrow().find(id).map(|s| s.to_string())
+ shared_ccx.item_symbols().borrow().get(id).map(|s| s.to_string())
}).collect();
// For the purposes of LTO, we add to the reachable set all of the upstream
s.push('/');
s.push_str(category);
- let n = match h.find(&s) {
+ let n = match h.get(&s) {
Some(&n) => n,
_ => 0u
};
params: params
};
- match ccx.unboxed_closure_vals().borrow().find(&mono_id) {
+ match ccx.unboxed_closure_vals().borrow().get(&mono_id) {
Some(llfn) => {
debug!("get_or_create_declaration_if_unboxed_closure(): found \
closure");
}
};
- match ccx.closure_bare_wrapper_cache().borrow().find(&fn_ptr) {
+ match ccx.closure_bare_wrapper_cache().borrow().get(&fn_ptr) {
Some(&llval) => return llval,
None => {}
}
}
pub fn def(&self, nid: ast::NodeId) -> def::Def {
- match self.tcx().def_map.borrow().find(&nid) {
+ match self.tcx().def_map.borrow().get(&nid) {
Some(v) => v.clone(),
None => {
self.tcx().sess.bug(format!(
self.tcx()
.method_map
.borrow()
- .find(&method_call)
+ .get(&method_call)
.map(|method| monomorphize_type(self, method.ty))
}
// our boxed-and-length-annotated strings.
pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef {
unsafe {
- match cx.const_cstr_cache().borrow().find(&s) {
+ match cx.const_cstr_cache().borrow().get(&s) {
Some(&llval) => return llval,
None => ()
}
let trait_ref = ty_fold::erase_regions(tcx, trait_ref);
// First check the cache.
- match ccx.trait_cache().borrow().find(&trait_ref) {
+ match ccx.trait_cache().borrow().get(&trait_ref) {
Some(vtable) => {
info!("Cache hit: {}", trait_ref.repr(ccx.tcx()));
return (*vtable).clone();
pub fn const_ptrcast(cx: &CrateContext, a: ValueRef, t: Type) -> ValueRef {
unsafe {
let b = llvm::LLVMConstPointerCast(a, t.ptr_to().to_ref());
- assert!(cx.const_globals().borrow_mut().insert(b as int, a));
+ assert!(cx.const_globals().borrow_mut().insert(b as int, a).is_none());
b
}
}
}
fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef {
- let v = match cx.const_globals().borrow().find(&(v as int)) {
+ let v = match cx.const_globals().borrow().get(&(v as int)) {
Some(&v) => v,
None => v
};
let loop_id = match opt_label {
None => fcx.top_loop_scope(),
Some(_) => {
- match bcx.tcx().def_map.borrow().find(&expr_id) {
+ match bcx.tcx().def_map.borrow().get(&expr_id) {
Some(&def::DefLabel(loop_id)) => loop_id,
ref r => {
bcx.tcx().sess.bug(format!("{} in def-map for label",
cx: &CrateContext,
type_: ty::t,
metadata: DIType) {
- if !self.type_to_metadata.insert(ty::type_id(type_), metadata) {
+ if self.type_to_metadata.insert(ty::type_id(type_), metadata).is_some() {
cx.sess().bug(format!("Type metadata for ty::t '{}' is already in the TypeMap!",
ppaux::ty_to_string(cx.tcx(), type_)).as_slice());
}
cx: &CrateContext,
unique_type_id: UniqueTypeId,
metadata: DIType) {
- if !self.unique_id_to_metadata.insert(unique_type_id, metadata) {
+ if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() {
let unique_type_id_str = self.get_unique_type_id_as_string(unique_type_id);
cx.sess().bug(format!("Type metadata for unique id '{}' is already in the TypeMap!",
unique_type_id_str.as_slice()).as_slice());
},
ty::ty_unboxed_closure(ref def_id, _, ref substs) => {
let closure_ty = cx.tcx().unboxed_closures.borrow()
- .find(def_id).unwrap().closure_type.subst(cx.tcx(), substs);
+ .get(def_id).unwrap().closure_type.subst(cx.tcx(), substs);
self.get_unique_type_id_of_closure_type(cx,
closure_ty,
&mut unique_type_id);
}
ty::ty_unboxed_closure(ref def_id, _, ref substs) => {
let sig = cx.tcx().unboxed_closures.borrow()
- .find(def_id).unwrap().closure_type.sig.subst(cx.tcx(), substs);
+ .get(def_id).unwrap().closure_type.sig.subst(cx.tcx(), substs);
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
}
ty::ty_struct(def_id, ref substs) => {
// Don't skip a conversion from Box<T> to &T, etc.
ty::ty_rptr(..) => {
let method_call = MethodCall::autoderef(expr.id, adj.autoderefs-1);
- let method = bcx.tcx().method_map.borrow().find(&method_call).is_some();
+ let method = bcx.tcx().method_map.borrow().get(&method_call).is_some();
if method {
// Don't skip an overloaded deref.
(adj.autoderefs, true)
let method_ty = ccx.tcx()
.method_map
.borrow()
- .find(&method_call)
+ .get(&method_call)
.map(|method| method.ty);
let base_datum = unpack_datum!(bcx, trans(bcx, &**base));
let method_ty = ccx.tcx()
.method_map
.borrow()
- .find(&method_call)
+ .get(&method_call)
.map(|method| method.ty);
let elt_datum = match method_ty {
Some(method_ty) => {
if ty::type_is_trait(node_id_type(bcx, expr.id)) {
let trait_ref =
bcx.tcx().object_cast_map.borrow()
- .find(&expr.id)
+ .get(&expr.id)
.map(|t| (*t).clone())
.unwrap();
let trait_ref =
def::DefUpvar(nid, _, _) => {
// Can't move upvars, so this is never a ZeroMemLastUse.
let local_ty = node_id_type(bcx, nid);
- match bcx.fcx.llupvars.borrow().find(&nid) {
+ match bcx.fcx.llupvars.borrow().get(&nid) {
Some(&val) => Datum::new(val, local_ty, Lvalue),
None => {
bcx.sess().bug(format!(
}
}
def::DefLocal(nid) => {
- let datum = match bcx.fcx.lllocals.borrow().find(&nid) {
+ let datum = match bcx.fcx.lllocals.borrow().get(&nid) {
Some(&v) => v,
None => {
bcx.sess().bug(format!(
// Check for overloaded deref.
let method_ty = ccx.tcx().method_map.borrow()
- .find(&method_call).map(|method| method.ty);
+ .get(&method_call).map(|method| method.ty);
let datum = match method_ty {
Some(method_ty) => {
// Overloaded. Evaluate `trans_overloaded_op`, which will
debug!("make drop glue for {}", ppaux::ty_to_string(ccx.tcx(), t));
let t = get_drop_glue_type(ccx, t);
debug!("drop glue type {}", ppaux::ty_to_string(ccx.tcx(), t));
- match ccx.drop_glues().borrow().find(&t) {
+ match ccx.drop_glues().borrow().get(&t) {
Some(&glue) => return glue,
_ => { }
}
let llfnty = Type::glue_fn(ccx, llty);
- let (glue, new_sym) = match ccx.available_drop_glues().borrow().find(&t) {
+ let (glue, new_sym) = match ccx.available_drop_glues().borrow().get(&t) {
Some(old_sym) => {
let glue = decl_cdecl_fn(ccx, old_sym.as_slice(), llfnty, ty::mk_nil());
(glue, None)
fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
-> Option<ast::DefId> {
let _icx = push_ctxt("maybe_instantiate_inline");
- match ccx.external().borrow().find(&fn_id) {
+ match ccx.external().borrow().get(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline({}): already inline as node id {}",
let (origin, method_ty) =
bcx.tcx().method_map
.borrow()
- .find(&method_call)
+ .get(&method_call)
.map(|method| (method.origin.clone(), method.ty))
.unwrap();
let impl_items = ccx.tcx().impl_items.borrow();
let impl_items =
- impl_items.find(&impl_id)
+ impl_items.get(&impl_id)
.expect("could not find impl while translating");
let meth_did = impl_items.iter()
.find(|&did| {
// Check the cache.
let cache_key = (box_ty, trait_ref.clone());
- match ccx.vtables().borrow().find(&cache_key) {
+ match ccx.vtables().borrow().get(&cache_key) {
Some(&val) => { return val }
None => { }
}
.unboxed_closures
.borrow();
let closure_info =
- unboxed_closures.find(&closure_def_id)
+ unboxed_closures.get(&closure_def_id)
.expect("get_vtable(): didn't find \
unboxed closure");
if closure_info.kind == ty::FnOnceUnboxedClosureKind {
params: real_substs.types.clone()
};
- match ccx.monomorphized().borrow().find(&hash_id) {
+ match ccx.monomorphized().borrow().get(&hash_id) {
Some(&val) => {
debug!("leaving monomorphic fn {}",
ty::item_path_str(ccx.tcx(), fn_id));
let depth;
{
let mut monomorphizing = ccx.monomorphizing().borrow_mut();
- depth = match monomorphizing.find(&fn_id) {
+ depth = match monomorphizing.get(&fn_id) {
Some(&d) => d, None => 0
};
pub fn associate_type(&self, s: &str, t: &Type) {
assert!(self.named_types.borrow_mut().insert(s.to_string(),
- t.to_ref()));
+ t.to_ref()).is_none());
}
pub fn find_type(&self, s: &str) -> Option<Type> {
}
// Check the cache.
- match cx.lltypes().borrow().find(&t) {
+ match cx.lltypes().borrow().get(&t) {
Some(&llty) => return llty,
None => ()
}
}
pub fn empty_builtin_bounds() -> BuiltinBounds {
- EnumSet::empty()
+ EnumSet::new()
}
pub fn all_builtin_bounds() -> BuiltinBounds {
- let mut set = EnumSet::empty();
- set.add(BoundSend);
- set.add(BoundSized);
- set.add(BoundSync);
+ let mut set = EnumSet::new();
+ set.insert(BoundSend);
+ set.insert(BoundSized);
+ set.insert(BoundSync);
set
}
let key = intern_key { sty: &st };
- match cx.interner.borrow().find(&key) {
+ match cx.interner.borrow().get(&key) {
Some(t) => unsafe { return mem::transmute(&t.sty); },
_ => ()
}
// value for the type contents of list. The correct value is
// TC::OwnsOwned. This manifested as issue #4821.
let ty_id = type_id(ty);
- match cache.find(&ty_id) {
+ match cache.get(&ty_id) {
Some(tc) => { return *tc; }
None => {}
}
- match cx.tc_cache.borrow().find(&ty_id) { // Must check both caches!
+ match cx.tc_cache.borrow().get(&ty_id) { // Must check both caches!
Some(tc) => { return *tc; }
None => {}
}
}
pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
- match cx.trait_refs.borrow().find(&id) {
+ match cx.trait_refs.borrow().get(&id) {
Some(t) => t.clone(),
None => cx.sess.bug(
format!("node_id_to_trait_ref: no trait ref for node `{}`",
}
pub fn node_id_to_type_opt(cx: &ctxt, id: ast::NodeId) -> Option<t> {
- match cx.node_types.borrow().find(&(id as uint)) {
+ match cx.node_types.borrow().get(&(id as uint)) {
Some(&t) => Some(t),
None => None
}
}
pub fn node_id_item_substs(cx: &ctxt, id: ast::NodeId) -> ItemSubsts {
- match cx.item_substs.borrow().find(&id) {
+ match cx.item_substs.borrow().get(&id) {
None => ItemSubsts::empty(),
Some(ts) => ts.clone(),
}
*/
adjust_ty(cx, expr.span, expr.id, expr_ty(cx, expr),
- cx.adjustments.borrow().find(&expr.id),
- |method_call| cx.method_map.borrow().find(&method_call).map(|method| method.ty))
+ cx.adjustments.borrow().get(&expr.id),
+ |method_call| cx.method_map.borrow().get(&method_call).map(|method| method.ty))
}
pub fn expr_span(cx: &ctxt, id: NodeId) -> Span {
}
pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def {
- match tcx.def_map.borrow().find(&expr.id) {
+ match tcx.def_map.borrow().get(&expr.id) {
Some(&def) => def,
None => {
tcx.sess.span_bug(expr.span, format!(
}
ast::ExprCast(..) => {
- match tcx.node_types.borrow().find(&(expr.id as uint)) {
+ match tcx.node_types.borrow().get(&(expr.id as uint)) {
Some(&t) => {
if type_is_trait(t) {
RvalueDpsExpr
ast::ExprBox(ref place, _) => {
// Special case `Box<T>` for now:
- let definition = match tcx.def_map.borrow().find(&place.id) {
+ let definition = match tcx.def_map.borrow().get(&place.id) {
Some(&def) => def,
None => panic!("no def for place"),
};
}
pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
- cx.provided_method_sources.borrow().find(&id).map(|x| *x)
+ cx.provided_method_sources.borrow().get(&id).map(|x| *x)
}
pub fn provided_trait_methods(cx: &ctxt, id: ast::DefId) -> Vec<Rc<Method>> {
pub fn is_associated_type(cx: &ctxt, id: ast::DefId) -> bool {
memoized(&cx.associated_types, id, |id: ast::DefId| {
if id.krate == ast::LOCAL_CRATE {
- match cx.impl_or_trait_items.borrow().find(&id) {
+ match cx.impl_or_trait_items.borrow().get(&id) {
Some(ref item) => {
match **item {
TypeTraitItem(_) => true,
pub fn trait_ref_to_def_id(tcx: &ctxt, tr: &ast::TraitRef) -> ast::DefId {
let def = *tcx.def_map.borrow()
- .find(&tr.ref_id)
+ .get(&tr.ref_id)
.expect("no def-map entry for trait");
def.def_id()
}
//! is a builtin trait.
match tcx.lang_items.to_builtin_kind(trait_def_id) {
- Some(bound) => { builtin_bounds.add(bound); true }
+ Some(bound) => { builtin_bounds.insert(bound); true }
None => false
}
}
/* If struct_id names a struct with a dtor, return Some(the dtor's id).
Otherwise return none. */
pub fn ty_dtor(cx: &ctxt, struct_id: DefId) -> DtorKind {
- match cx.destructor_for_type.borrow().find(&struct_id) {
+ match cx.destructor_for_type.borrow().get(&struct_id) {
Some(&method_def_id) => {
let flag = !has_attr(cx, struct_id, "unsafe_no_drop_flag");
pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
if did.krate == ast::LOCAL_CRATE {
let struct_fields = cx.struct_fields.borrow();
- match struct_fields.find(&did) {
+ match struct_fields.get(&did) {
Some(fields) => (**fields).clone(),
_ => {
cx.sess.bug(
// implemented.
assert!(closure_id.krate == ast::LOCAL_CRATE);
let capture_mode = tcx.capture_modes.borrow().get_copy(&closure_id.node);
- match tcx.freevars.borrow().find(&closure_id.node) {
+ match tcx.freevars.borrow().get(&closure_id.node) {
None => vec![],
Some(ref freevars) => {
freevars.iter().map(|freevar| {
all_bounds: &mut Vec<ty::Region>) {
all_bounds.push_all(region_bounds.as_slice());
- if builtin_bounds.contains_elem(ty::BoundSend) {
+ if builtin_bounds.contains(&ty::BoundSend) {
all_bounds.push(ty::ReStatic);
}
}
pub fn record_trait_implementation(tcx: &ctxt,
trait_def_id: DefId,
impl_def_id: DefId) {
- match tcx.trait_impls.borrow().find(&trait_def_id) {
+ match tcx.trait_impls.borrow().get(&trait_def_id) {
Some(impls_for_trait) => {
impls_for_trait.borrow_mut().push(impl_def_id);
return;
/// Otherwise, return `None`.
pub fn trait_item_of_item(tcx: &ctxt, def_id: ast::DefId)
-> Option<ImplOrTraitItemId> {
- let impl_item = match tcx.impl_or_trait_items.borrow().find(&def_id) {
+ let impl_item = match tcx.impl_or_trait_items.borrow().get(&def_id) {
Some(m) => m.clone(),
None => return None,
};
}
fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<ty::t> {
- self.method_map.borrow().find(&method_call).map(|method| method.ty)
+ self.method_map.borrow().get(&method_call).map(|method| method.ty)
}
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
pub type CaptureModeMap = NodeMap<ast::CaptureClause>;
pub fn with_freevars<T>(tcx: &ty::ctxt, fid: ast::NodeId, f: |&[Freevar]| -> T) -> T {
- match tcx.freevars.borrow().find(&fid) {
+ match tcx.freevars.borrow().get(&fid) {
None => f(&[]),
Some(d) => f(d.as_slice())
}
pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime)
-> ty::Region {
- let r = match tcx.named_region_map.find(&lifetime.id) {
+ let r = match tcx.named_region_map.get(&lifetime.id) {
None => {
// should have been recorded by the `resolve_lifetime` pass
tcx.sess.span_bug(lifetime.span, "unresolved lifetime");
pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> {
match ast_ty.node {
ast::TyPath(ref path, _, id) => {
- let a_def = match tcx.def_map.borrow().find(&id) {
+ let a_def = match tcx.def_map.borrow().get(&id) {
None => {
tcx.sess.span_bug(ast_ty.span,
format!("unbound path {}",
match ast_ty.node {
ast::TyPath(ref path, _, id) => {
- let a_def = match this.tcx().def_map.borrow().find(&id) {
+ let a_def = match this.tcx().def_map.borrow().get(&id) {
None => {
this.tcx()
.sess
// Note that the "bounds must be empty if path is not a trait"
// restriction is enforced in the below case for ty_path, which
// will run after this as long as the path isn't a trait.
- match tcx.def_map.borrow().find(&id) {
+ match tcx.def_map.borrow().get(&id) {
Some(&def::DefPrimTy(ast::TyStr)) => {
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
match ptr_ty {
let tcx = this.tcx();
let mut ast_ty_to_ty_cache = tcx.ast_ty_to_ty_cache.borrow_mut();
- match ast_ty_to_ty_cache.find(&ast_ty.id) {
+ match ast_ty_to_ty_cache.get(&ast_ty.id) {
Some(&ty::atttce_resolved(ty)) => return ty,
Some(&ty::atttce_unresolved) => {
tcx.sess.span_fatal(ast_ty.span,
ty::mk_err()
}
ast::TyPath(ref path, ref bounds, id) => {
- let a_def = match tcx.def_map.borrow().find(&id) {
+ let a_def = match tcx.def_map.borrow().get(&id) {
None => {
tcx.sess
.span_bug(ast_ty.span,
}
}
ast::TyQPath(ref qpath) => {
- match tcx.def_map.borrow().find(&ast_ty.id) {
+ match tcx.def_map.borrow().get(&ast_ty.id) {
None => {
tcx.sess.span_bug(ast_ty.span,
"unbound qualified path")
ast::TraitTyParamBound(ref b) => {
match lookup_def_tcx(tcx, b.path.span, b.ref_id) {
def::DefTrait(trait_did) => {
- match trait_def_ids.find(&trait_did) {
+ match trait_def_ids.get(&trait_did) {
// Already seen this trait. We forbid
// duplicates in the list (for some
// reason).
let item_substs = fcx
.item_substs()
- .find(&pat.id)
+ .get(&pat.id)
.map(|substs| substs.substs.clone())
.unwrap_or_else(|| Substs::empty());
debug!("push_extension_candidates(expr_id={})", expr_id);
let mut duplicates = HashSet::new();
- let opt_applicable_traits = self.fcx.ccx.trait_map.find(&expr_id);
+ let opt_applicable_traits = self.fcx.ccx.trait_map.get(&expr_id);
for applicable_traits in opt_applicable_traits.into_iter() {
for &trait_did in applicable_traits.iter() {
if duplicates.insert(trait_did) {
// metadata if necessary.
ty::populate_implementations_for_type_if_necessary(self.tcx(), did);
- for impl_infos in self.tcx().inherent_impls.borrow().find(&did).iter() {
+ for impl_infos in self.tcx().inherent_impls.borrow().get(&did).iter() {
for impl_did in impl_infos.iter() {
self.push_candidates_from_inherent_impl(*impl_did);
}
.inh
.adjustments
.borrow()
- .find(&expr.id) {
+ .get(&expr.id) {
Some(&ty::AdjustDerefRef(ty::AutoDerefRef {
autoderefs: autoderef_count,
autoref: _
match expr.node {
ast::ExprIndex(ref base_expr, _) => {
let mut base_adjustment =
- match self.fcx.inh.adjustments.borrow().find(&base_expr.id) {
+ match self.fcx.inh.adjustments.borrow().get(&base_expr.id) {
Some(&ty::AdjustDerefRef(ref adr)) => (*adr).clone(),
None => ty::AutoDerefRef { autoderefs: 0, autoref: None },
Some(_) => {
-> Option<Rc<ty::Method>>
{
let impl_items = tcx.impl_items.borrow();
- let impl_items = impl_items.find(&impl_def_id).unwrap();
+ let impl_items = impl_items.get(&impl_def_id).unwrap();
impl_items
.iter()
.map(|&did| ty::impl_or_trait_item(tcx, did.def_id()))
}
fn node_method_ty(&self, method_call: typeck::MethodCall)
-> Option<ty::t> {
- self.inh.method_map.borrow().find(&method_call).map(|m| m.ty)
+ self.inh.method_map.borrow().get(&method_call).map(|m| m.ty)
}
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
&self.inh.adjustments
}
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
- match self.inh.locals.borrow().find(&nid) {
+ match self.inh.locals.borrow().get(&nid) {
Some(&t) => t,
None => {
self.tcx().sess.span_bug(
}
pub fn expr_ty(&self, ex: &ast::Expr) -> ty::t {
- match self.inh.node_types.borrow().find(&ex.id) {
+ match self.inh.node_types.borrow().get(&ex.id) {
Some(&t) => t,
None => {
self.tcx().sess.bug(format!("no type for expr in fcx {}",
*/
let adjustments = self.inh.adjustments.borrow();
- let adjustment = adjustments.find(&expr.id);
+ let adjustment = adjustments.get(&expr.id);
self.adjust_expr_ty(expr, adjustment)
}
raw_ty,
adjustment,
|method_call| self.inh.method_map.borrow()
- .find(&method_call)
+ .get(&method_call)
.map(|method| method.ty))
}
pub fn node_ty(&self, id: ast::NodeId) -> ty::t {
- match self.inh.node_types.borrow().find(&id) {
+ match self.inh.node_types.borrow().get(&id) {
Some(&t) => t,
None => {
self.tcx().sess.bug(
pub fn opt_node_ty_substs(&self,
id: ast::NodeId,
f: |&ty::ItemSubsts|) {
- match self.inh.item_substs.borrow().find(&id) {
+ match self.inh.item_substs.borrow().get(&id) {
Some(s) => { f(s) }
None => { }
}
let (bounds, onceness) = match expr.node {
ast::ExprProc(..) => {
let mut bounds = ty::region_existential_bound(ty::ReStatic);
- bounds.builtin_bounds.add(ty::BoundSend); // FIXME
+ bounds.builtin_bounds.insert(ty::BoundSend); // FIXME
(bounds, ast::Once)
}
_ => {
for field in ast_fields.iter() {
let mut expected_field_type = ty::mk_err();
- let pair = class_field_map.find(&field.ident.node.name).map(|x| *x);
+ let pair = class_field_map.get(&field.ident.node.name).map(|x| *x);
match pair {
None => {
fcx.type_error_message(
}
ast::ExprStruct(ref path, ref fields, ref base_expr) => {
// Resolve the path.
- let def = tcx.def_map.borrow().find(&id).map(|i| *i);
+ let def = tcx.def_map.borrow().get(&id).map(|i| *i);
let struct_id = match def {
Some(def::DefVariant(enum_id, variant_id, true)) => {
check_struct_enum_variant(fcx, id, expr.span, enum_id,
(block_query(b, |e| {
match e.node {
ast::ExprBreak(Some(_)) => {
- match cx.def_map.borrow().find(&e.id) {
+ match cx.def_map.borrow().get(&e.id) {
Some(&def::DefLabel(loop_id)) if id == loop_id => true,
_ => false,
}
fn resolve_method_type(&self, method_call: MethodCall) -> Option<ty::t> {
let method_ty = self.fcx.inh.method_map.borrow()
- .find(&method_call).map(|method| method.ty);
+ .get(&method_call).map(|method| method.ty);
method_ty.map(|method_ty| self.resolve_type(method_ty))
}
} else {
let tcx = self.fcx.tcx();
ty::adjust_ty(tcx, expr.span, expr.id, ty_unadjusted,
- self.fcx.inh.adjustments.borrow().find(&expr.id),
+ self.fcx.inh.adjustments.borrow().get(&expr.id),
|method_call| self.resolve_method_type(method_call))
}
}
// When we enter a function, we can derive
let fn_sig_map = self.fcx.inh.fn_sig_map.borrow();
- let fn_sig = match fn_sig_map.find(&id) {
+ let fn_sig = match fn_sig_map.get(&id) {
Some(f) => f,
None => {
self.tcx().sess.bug(
{
debug!("visit_region_obligations: node_id={}", node_id);
let region_obligations = self.fcx.inh.region_obligations.borrow();
- match region_obligations.find(&node_id) {
+ match region_obligations.get(&node_id) {
None => { }
Some(vec) => {
for r_o in vec.iter() {
let has_method_map = rcx.fcx.inh.method_map.borrow().contains_key(&method_call);
// Check any autoderefs or autorefs that appear.
- for &adjustment in rcx.fcx.inh.adjustments.borrow().find(&expr.id).iter() {
+ for &adjustment in rcx.fcx.inh.adjustments.borrow().get(&expr.id).iter() {
debug!("adjustment={}", adjustment);
match *adjustment {
ty::AdjustDerefRef(ty::AutoDerefRef {autoderefs, autoref: ref opt_autoref}) => {
ast::ExprUnary(ast::UnDeref, ref base) => {
// For *a, the lifetime of a must enclose the deref
let method_call = MethodCall::expr(expr.id);
- let base_ty = match rcx.fcx.inh.method_map.borrow().find(&method_call) {
+ let base_ty = match rcx.fcx.inh.method_map.borrow().get(&method_call) {
Some(method) => {
constrain_call(rcx, expr, Some(&**base),
None::<ast::Expr>.iter(), true);
let raw_var_ty = rcx.resolve_node_type(var_node_id);
let upvar_id = ty::UpvarId { var_id: var_node_id,
closure_expr_id: expr.id };
- let var_ty = match rcx.fcx.inh.upvar_borrow_map.borrow().find(&upvar_id) {
+ let var_ty = match rcx.fcx.inh.upvar_borrow_map.borrow().get(&upvar_id) {
Some(upvar_borrow) => {
ty::mk_rptr(rcx.tcx(),
upvar_borrow.region,
i, derefs);
let method_call = MethodCall::autoderef(deref_expr.id, i);
- derefd_ty = match rcx.fcx.inh.method_map.borrow().find(&method_call) {
+ derefd_ty = match rcx.fcx.inh.method_map.borrow().get(&method_call) {
Some(method) => {
// Treat overloaded autoderefs as if an AutoRef adjustment
// was applied on the base type, as that is always the case.
// report errors later on in the writeback phase.
let ty0 = rcx.resolve_node_type(id);
let ty = ty::adjust_ty(tcx, origin.span(), id, ty0,
- rcx.fcx.inh.adjustments.borrow().find(&id),
+ rcx.fcx.inh.adjustments.borrow().get(&id),
|method_call| rcx.resolve_method_type(method_call));
debug!("constrain_regions_in_type_of_node(\
ty={}, ty0={}, id={}, minimum_lifetime={})",
mc::NoteUpvarRef(ref upvar_id) => {
let mut upvar_borrow_map =
rcx.fcx.inh.upvar_borrow_map.borrow_mut();
- match upvar_borrow_map.find_mut(upvar_id) {
+ match upvar_borrow_map.get_mut(upvar_id) {
Some(upvar_borrow) => {
// Adjust mutability that we infer for the upvar
// so it can accommodate being borrowed with
let mut upvar_borrow_map = rcx.fcx.inh.upvar_borrow_map.borrow_mut();
let inner_borrow = upvar_borrow_map.get_copy(&inner_upvar_id);
- match upvar_borrow_map.find_mut(&outer_upvar_id) {
+ 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 visit_adjustments(&self, reason: ResolveReason, id: ast::NodeId) {
- match self.fcx.inh.adjustments.borrow_mut().pop(&id) {
+ match self.fcx.inh.adjustments.borrow_mut().remove(&id) {
None => {
debug!("No adjustments for node {}", id);
}
// FIXME(eddyb) #2190 Allow only statically resolved
// bare functions to coerce to a closure to avoid
// constructing (slower) indirect call wrappers.
- match self.tcx().def_map.borrow().find(&id) {
+ match self.tcx().def_map.borrow().get(&id) {
Some(&def::DefFn(..)) |
Some(&def::DefStaticMethod(..)) |
Some(&def::DefVariant(..)) |
reason: ResolveReason,
method_call: MethodCall) {
// Resolve any method map entry
- match self.fcx.inh.method_map.borrow_mut().pop(&method_call) {
+ match self.fcx.inh.method_map.borrow_mut().remove(&method_call) {
Some(method) => {
debug!("writeback::resolve_method_map_entry(call={}, entry={})",
method_call,
}
fn add_inherent_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
- match self.inherent_impls.borrow().find(&base_def_id) {
+ match self.inherent_impls.borrow().get(&base_def_id) {
Some(implementation_list) => {
implementation_list.borrow_mut().push(impl_def_id);
return;
fn push_impls_of_trait(&self,
trait_def_id: ast::DefId,
out: &mut Vec<ast::DefId>) {
- match self.tcx.trait_impls.borrow().find(&trait_def_id) {
+ match self.tcx.trait_impls.borrow().get(&trait_def_id) {
Some(impls) => { out.push_all(impls.borrow().as_slice()); }
None => { /* no impls */ }
}
let result = convert_field(ccx, &pty.generics, f, local_def(id));
if result.name != special_idents::unnamed_field.name {
- let dup = match seen_fields.find(&result.name) {
+ let dup = match seen_fields.get(&result.name) {
Some(prev_span) => {
span_err!(tcx.sess, f.span, E0124,
"field `{}` is already declared",
pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> {
let def_id = local_def(it.id);
let tcx = ccx.tcx;
- match tcx.trait_defs.borrow().find(&def_id) {
+ match tcx.trait_defs.borrow().get(&def_id) {
Some(def) => return def.clone(),
_ => {}
}
-> ty::Polytype {
let def_id = local_def(it.id);
let tcx = ccx.tcx;
- match tcx.tcache.borrow().find(&def_id) {
+ match tcx.tcache.borrow().get(&def_id) {
Some(pty) => return pty.clone(),
_ => {}
}
return pty;
}
ast::ItemTy(ref t, ref generics) => {
- match tcx.tcache.borrow_mut().find(&local_def(it.id)) {
+ match tcx.tcache.borrow_mut().get(&local_def(it.id)) {
Some(pty) => return pty.clone(),
None => { }
}
-> ty::TypeParameterDef
where AC: AstConv<'tcx>
{
- match this.tcx().ty_param_defs.borrow().find(¶m.id) {
+ match this.tcx().ty_param_defs.borrow().get(¶m.id) {
Some(d) => { return (*d).clone(); }
None => { }
}
span: Span) {
// Currently the only bound which is incompatible with other bounds is
// Sized/Unsized.
- if !param_bounds.builtin_bounds.contains_elem(ty::BoundSized) {
+ if !param_bounds.builtin_bounds.contains(&ty::BoundSized) {
ty::each_bound_trait_and_supertraits(
tcx,
param_bounds.trait_bounds.as_slice(),
|trait_ref| {
let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id);
- if trait_def.bounds.builtin_bounds.contains_elem(ty::BoundSized) {
+ if trait_def.bounds.builtin_bounds.contains(&ty::BoundSized) {
span_err!(tcx.sess, span, E0129,
"incompatible bounds on type parameter `{}`, \
bound `{}` does not allow unsized type",
let predicate_param_id =
tcx.def_map
.borrow()
- .find(&predicate.id)
+ .get(&predicate.id)
.expect("compute_bounds(): resolve didn't resolve the type \
parameter identifier in a `where` clause")
.def_id();
ty_queue.push(&*mut_ty.ty);
}
ast::TyPath(ref path, ref bounds, id) => {
- let a_def = match self.tcx.def_map.borrow().find(&id) {
+ let a_def = match self.tcx.def_map.borrow().get(&id) {
None => {
self.tcx
.sess
debug!("RegionVarBindings: add_constraint({})",
constraint.repr(self.tcx));
- if self.constraints.borrow_mut().insert(constraint, origin) {
+ if self.constraints.borrow_mut().insert(constraint, origin).is_none() {
if self.in_snapshot() {
self.undo_log.borrow_mut().push(AddConstraint(constraint));
}
new_r: Region|)
-> Region {
let vars = TwoRegions { a: a, b: b };
- match self.combine_map(t).borrow().find(&vars) {
+ match self.combine_map(t).borrow().get(&vars) {
Some(&c) => {
return ReInfer(ReVar(c));
}
debug!("expansion: constraint={} origin={}",
constraint.repr(self.tcx),
self.constraints.borrow()
- .find(constraint)
+ .get(constraint)
.unwrap()
.repr(self.tcx));
match *constraint {
debug!("contraction: constraint={} origin={}",
constraint.repr(self.tcx),
self.constraints.borrow()
- .find(constraint)
+ .get(constraint)
.unwrap()
.repr(self.tcx));
match *constraint {
// e.g., fn:Copy() <: fn(), because the former is a function
// that only closes over copyable things, but the latter is
// any function at all.
- if a.contains(b) {
+ if a.is_superset(&b) {
Ok(a)
} else {
Err(ty::terr_builtin_bounds(expected_found(self, a, b)))
}
}
pub fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> def::Def {
- match tcx.def_map.borrow().find(&id) {
+ match tcx.def_map.borrow().get(&id) {
Some(x) => x.clone(),
_ => {
tcx.sess.span_fatal(sp, "internal error looking up a definition")
index: index,
param_id: param_id,
term: term });
- let newly_added = self.inferred_map.insert(param_id, inf_index);
+ let newly_added = self.inferred_map.insert(param_id, inf_index).is_none();
assert!(newly_added);
debug!("add_inferred(item_id={}, \
if self.num_inferred() == inferreds_on_entry {
let newly_added = self.tcx.item_variance_map.borrow_mut().insert(
ast_util::local_def(item.id),
- self.empty_variances.clone());
+ self.empty_variances.clone()).is_none();
assert!(newly_added);
}
}
fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
- match self.terms_cx.inferred_map.find(¶m_id) {
+ match self.terms_cx.inferred_map.get(¶m_id) {
Some(&index) => index,
None => {
self.tcx().sess.bug(format!(
fn find_binding_for_lifetime(&self, param_id: ast::NodeId) -> ast::NodeId {
let tcx = self.terms_cx.tcx;
assert!(is_lifetime(&tcx.map, param_id));
- match tcx.named_region_map.find(¶m_id) {
+ match tcx.named_region_map.get(¶m_id) {
Some(&rl::DefEarlyBoundRegion(_, _, lifetime_decl_id))
=> lifetime_decl_id,
Some(_) => panic!("should not encounter non early-bound cases"),
ty::ty_param(ty::ParamTy { ref def_id, .. }) => {
assert_eq!(def_id.krate, ast::LOCAL_CRATE);
- match self.terms_cx.inferred_map.find(&def_id.node) {
+ match self.terms_cx.inferred_map.get(&def_id.node) {
Some(&index) => {
self.add_constraint(index, variance);
}
}
let newly_added = tcx.item_variance_map.borrow_mut()
- .insert(item_def_id, Rc::new(item_variances));
+ .insert(item_def_id, Rc::new(item_variances)).is_none();
assert!(newly_added);
}
}
let mut queue = vec!(source);
let mut i = 0;
while i < queue.len() {
- match edges_map.find(&queue[i]) {
+ match edges_map.get(&queue[i]) {
Some(edges) => {
for target in edges.iter() {
if *target == destination {
k: |&T| -> K
) -> U {
let key = k(&arg);
- let result = cache.borrow().find(&key).map(|result| result.clone());
+ let result = cache.borrow().get(&key).map(|result| result.clone());
match result {
Some(result) => result,
None => {
ty_str => "str".to_string(),
ty_unboxed_closure(ref did, _, ref substs) => {
let unboxed_closures = cx.unboxed_closures.borrow();
- unboxed_closures.find(did).map(|cl| {
+ unboxed_closures.get(did).map(|cl| {
closure_to_string(cx, &cl.closure_type.subst(cx, substs))
}).unwrap_or_else(|| "closure".to_string())
}
impl UserString for ty::ExistentialBounds {
fn user_string(&self, tcx: &ctxt) -> String {
- if self.builtin_bounds.contains_elem(ty::BoundSend) &&
+ if self.builtin_bounds.contains(&ty::BoundSend) &&
self.region_bound == ty::ReStatic
{ // Region bound is implied by builtin bounds:
return self.builtin_bounds.repr(tcx);
fn user_string(&self, tcx: &ctxt) -> String {
let id = self.idx;
let did = self.def_id;
- let ident = match tcx.ty_param_defs.borrow().find(&did.node) {
+ let ident = match tcx.ty_param_defs.borrow().get(&did.node) {
Some(def) => token::get_name(def.name).get().to_string(),
// This can only happen when a type mismatch error happens and
Some(tcx) => tcx,
None => return None,
};
- let def = match tcx.def_map.borrow().find(&id) {
+ let def = match tcx.def_map.borrow().get(&id) {
Some(def) => *def,
None => return None,
};
ty::populate_implementations_for_type_if_necessary(tcx, did);
let mut impls = Vec::new();
- match tcx.inherent_impls.borrow().find(&did) {
+ match tcx.inherent_impls.borrow().get(&did) {
None => {}
Some(i) => {
impls.extend(i.iter().map(|&did| { build_impl(cx, tcx, did) }));
let (name, attrs) = if self.name == unnamed_field.name {
(None, None)
} else {
- (Some(self.name), Some(attr_map.find(&self.id.node).unwrap()))
+ (Some(self.name), Some(attr_map.get(&self.id.node).unwrap()))
};
let ty = ty::lookup_item_type(cx.tcx(), self.id);
None => return Primitive(Bool),
};
debug!("searching for {} in defmap", id);
- let def = match tcx.def_map.borrow().find(&id) {
+ let def = match tcx.def_map.borrow().get(&id) {
Some(&k) => k,
None => panic!("unresolved id not in defmap")
};
fn resolve_def(cx: &DocContext, id: ast::NodeId) -> Option<ast::DefId> {
cx.tcx_opt().and_then(|tcx| {
- tcx.def_map.borrow().find(&id).map(|&def| register_def(cx, def))
+ tcx.def_map.borrow().get(&id).map(|&def| register_def(cx, def))
})
}
}
},
|cache| {
- match cache.paths.find(&did) {
+ match cache.paths.get(&did) {
None => None,
Some(&(ref fqp, shortty)) => Some((fqp.clone(), shortty))
}
name: &str) -> fmt::Result {
let m = cache_key.get().unwrap();
let mut needs_termination = false;
- match m.primitive_locations.find(&prim) {
+ match m.primitive_locations.get(&prim) {
Some(&ast::LOCAL_CRATE) => {
let loc = current_location_key.get().unwrap();
let len = if loc.len() == 0 {0} else {loc.len() - 1};
// Make sure our hyphenated ID is unique for this page
let map = used_header_map.get().unwrap();
- let id = match map.borrow_mut().find_mut(&id) {
+ let id = match map.borrow_mut().get_mut(&id) {
None => id,
Some(a) => { *a += 1; format!("{}-{}", id, *a - 1) }
};
// has since been learned.
for &(pid, ref item) in orphan_methods.iter() {
let did = ast_util::local_def(pid);
- match paths.find(&did) {
+ match paths.get(&did) {
Some(&(ref fqp, _)) => {
search_index.push(IndexItem {
ty: shortty(item),
item.desc.to_json().to_string()));
match item.parent {
Some(nodeid) => {
- let pathid = *nodeid_to_pathid.find(&nodeid).unwrap();
+ let pathid = *nodeid_to_pathid.get(&nodeid).unwrap();
try!(write!(&mut w, ",{}", pathid));
}
None => {}
try!(write!(&mut w, r#"],"paths":["#));
for (i, &did) in pathid_to_nodeid.iter().enumerate() {
- let &(ref fqp, short) = cache.paths.find(&did).unwrap();
+ let &(ref fqp, short) = cache.paths.get(&did).unwrap();
if i > 0 {
try!(write!(&mut w, ","));
}
//
// FIXME: this is a vague explanation for why this can't be a `get`, in
// theory it should be...
- let &(ref remote_path, remote_item_type) = match cache.paths.find(&did) {
+ let &(ref remote_path, remote_item_type) = match cache.paths.get(&did) {
Some(p) => p,
None => continue,
};
} else {
let last = self.parent_stack.last().unwrap();
let did = *last;
- let path = match self.paths.find(&did) {
+ let path = match self.paths.get(&did) {
Some(&(_, item_type::Trait)) =>
Some(self.stack[..self.stack.len() - 1]),
// The current stack not necessarily has correlation for
&Item{ cx: cx, item: it }));
} else {
let mut url = "../".repeat(cx.current.len());
- match cache_key.get().unwrap().paths.find(&it.def_id) {
+ match cache_key.get().unwrap().paths.get(&it.def_id) {
Some(&(ref names, _)) => {
for name in names[..names.len() - 1].iter() {
url.push_str(name.as_slice());
<h2 id='implementors'>Implementors</h2>
<ul class='item-list' id='implementors-list'>
"));
- match cache.implementors.find(&it.def_id) {
+ match cache.implementors.get(&it.def_id) {
Some(implementors) => {
for i in implementors.iter() {
try!(writeln!(w, "<li>{}<code>impl{} {} for {}{}</code></li>",
}
fn render_methods(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
- match cache_key.get().unwrap().impls.find(&it.def_id) {
+ match cache_key.get().unwrap().impls.get(&it.def_id) {
Some(v) => {
let (non_trait, traits) = v.partitioned(|i| i.impl_.trait_.is_none());
if non_trait.len() > 0 {
match i.impl_.trait_ {
Some(clean::ResolvedPath { did, .. }) => {
try!({
- match cache_key.get().unwrap().traits.find(&did) {
+ match cache_key.get().unwrap().traits.get(&did) {
Some(t) => try!(render_default_methods(w, t, &i.impl_)),
None => {}
}
Ok(json::Object(obj)) => {
let mut obj = obj;
// Make sure the schema is what we expect
- match obj.pop(&"schema".to_string()) {
+ match obj.remove(&"schema".to_string()) {
Some(json::String(version)) => {
if version.as_slice() != SCHEMA_VERSION {
return Err(format!(
Some(..) => return Err("malformed json".to_string()),
None => return Err("expected a schema version".to_string()),
}
- let krate = match obj.pop(&"crate".to_string()) {
+ let krate = match obj.remove(&"crate".to_string()) {
Some(json) => {
let mut d = json::Decoder::new(json);
Decodable::decode(&mut d).unwrap()
// The following match takes a mutable borrow on the map. In order to insert
// our data if the key isn't present, we need to let the match end first.
- let data = match (map.find_mut(&keyval), data) {
+ let data = match (map.get_mut(&keyval), data) {
(None, Some(data)) => {
// The key doesn't exist and we need to insert it. To make borrowck
// happy, return it up a scope and insert it there.
};
let keyval = key_to_key_value(self);
- match map.find(&keyval) {
+ match map.get(&keyval) {
Some(slot) => {
let value_box = slot.box_ptr as *mut TLDValueBox<T>;
if unsafe { *(*value_box).refcount.get() } >= 1 {
d.read_seq(|d, len| {
let mut list = DList::new();
for i in range(0u, len) {
- list.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
+ list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
}
Ok(list)
})
d.read_seq(|d, len| {
let mut deque: RingBuf<T> = RingBuf::new();
for i in range(0u, len) {
- deque.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
+ deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
}
Ok(deque)
})
> Decodable<D, E> for EnumSet<T> {
fn decode(d: &mut D) -> Result<EnumSet<T>, E> {
let bits = try!(d.read_uint());
- let mut set = EnumSet::empty();
+ let mut set = EnumSet::new();
for bit in range(0, uint::BITS) {
if bits & (1 << bit) != 0 {
- set.add(CLike::from_uint(1 << bit));
+ set.insert(CLike::from_uint(1 << bit));
}
}
Ok(set)
let name = match self.pop() {
String(s) => s,
Object(mut o) => {
- let n = match o.pop(&"variant".to_string()) {
+ let n = match o.remove(&"variant".to_string()) {
Some(String(s)) => s,
Some(val) => {
return Err(ExpectedError("String".to_string(), format!("{}", val)))
return Err(MissingFieldError("variant".to_string()))
}
};
- match o.pop(&"fields".to_string()) {
+ match o.remove(&"fields".to_string()) {
Some(List(l)) => {
for field in l.into_iter().rev() {
self.stack.push(field);
debug!("read_struct_field(name={}, idx={})", name, idx);
let mut obj = try!(expect!(self.pop(), Object));
- let value = match obj.pop(&name.to_string()) {
+ let value = match obj.remove(&name.to_string()) {
None => {
// Add a Null and try to parse it as an Option<_>
// to get None as a default value.
\"fields\":[\"Henry\", 349]}}";
let mut map: TreeMap<string::String, Animal> = super::decode(s).unwrap();
- assert_eq!(map.pop(&"a".to_string()), Some(Dog));
- assert_eq!(map.pop(&"b".to_string()), Some(Frog("Henry".to_string(), 349)));
+ assert_eq!(map.remove(&"a".to_string()), Some(Dog));
+ assert_eq!(map.remove(&"b".to_string()), Some(Frog("Henry".to_string(), 349)));
}
#[test]
/// as `Err(IoError)`. See `read()` for more details.
fn push(&mut self, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> {
let start_len = buf.len();
- buf.reserve_additional(len);
+ buf.reserve(len);
let n = {
let s = unsafe { slice_vec_capacity(buf, start_len, start_len + len) };
}
let start_len = buf.len();
- buf.reserve_additional(len);
+ buf.reserve(len);
// we can't just use self.read_at_least(min, slice) because we need to push
// successful reads onto the vector before any returned errors.
cmd.env("path", "foo");
cmd.env("Path", "bar");
let env = &cmd.env.unwrap();
- let val = env.find(&EnvKey("PATH".to_c_str()));
+ let val = env.get(&EnvKey("PATH".to_c_str()));
assert!(val.unwrap() == &"bar".to_c_str());
}
}
()
});
with_used_diagnostics(|diagnostics| {
- match diagnostics.swap(code.name, span) {
+ match diagnostics.insert(code.name, span) {
Some(previous_span) => {
ecx.span_warn(span, format!(
"diagnostic code {} already used", token::get_ident(code).get()
_ => unreachable!()
};
with_registered_diagnostics(|diagnostics| {
- if !diagnostics.insert(code.name, description) {
+ if diagnostics.insert(code.name, description).is_some() {
ecx.span_err(span, format!(
"diagnostic code {} already registered", token::get_ident(*code).get()
).as_slice());
pub fn find(&self, k: &Name) -> Option<Rc<SyntaxExtension>> {
for frame in self.chain.iter().rev() {
- match frame.map.find(k) {
+ match frame.map.get(k) {
Some(v) => return Some(v.clone()),
None => {}
}
}
Named(name) => {
- let span = match self.names.find(&name) {
+ let span = match self.names.get(&name) {
Some(e) => e.span,
None => {
let msg = format!("there is no argument named `{}`", name);
return;
}
};
- self.verify_same(span, &ty, self.name_types.find(&name));
+ self.verify_same(span, &ty, self.name_types.get(&name));
if !self.name_types.contains_key(&name) {
self.name_types.insert(name.clone(), ty);
}
heads.push(self.ecx.expr_addr_of(e.span, e));
}
for name in self.name_ordering.iter() {
- let e = match self.names.pop(name) {
+ let e = match self.names.remove(name) {
Some(e) => e,
None => continue
};
- let arg_ty = match self.name_types.find(name) {
+ let arg_ty = match self.name_types.get(name) {
Some(ty) => ty,
None => continue
};
resolve_table: &mut ResolveTable) -> Name {
let key = (id.name, id.ctxt);
- match resolve_table.find(&key) {
+ match resolve_table.get(&key) {
Some(&name) => return name,
None => {}
}
pub fn intern(&self, val: T) -> Name {
let mut map = self.map.borrow_mut();
- match (*map).find(&val) {
+ match (*map).get(&val) {
Some(&idx) => return idx,
None => (),
}
let MetricMap(ref selfmap) = *self;
let MetricMap(ref old) = *old;
for (k, vold) in old.iter() {
- let r = match selfmap.find(k) {
+ let r = match selfmap.get(k) {
None => MetricRemoved,
Some(v) => {
let delta = v.value - vold.value;
let diff1 = m2.compare_to_old(&m1, None);
- assert_eq!(*(diff1.find(&"in-both-noise".to_string()).unwrap()), LikelyNoise);
- assert_eq!(*(diff1.find(&"in-first-noise".to_string()).unwrap()), MetricRemoved);
- assert_eq!(*(diff1.find(&"in-second-noise".to_string()).unwrap()), MetricAdded);
- assert_eq!(*(diff1.find(&"in-both-want-downwards-but-regressed".to_string()).unwrap()),
+ assert_eq!(*(diff1.get(&"in-both-noise".to_string()).unwrap()), LikelyNoise);
+ assert_eq!(*(diff1.get(&"in-first-noise".to_string()).unwrap()), MetricRemoved);
+ assert_eq!(*(diff1.get(&"in-second-noise".to_string()).unwrap()), MetricAdded);
+ assert_eq!(*(diff1.get(&"in-both-want-downwards-but-regressed".to_string()).unwrap()),
Regression(100.0));
- assert_eq!(*(diff1.find(&"in-both-want-downwards-and-improved".to_string()).unwrap()),
+ assert_eq!(*(diff1.get(&"in-both-want-downwards-and-improved".to_string()).unwrap()),
Improvement(50.0));
- assert_eq!(*(diff1.find(&"in-both-want-upwards-but-regressed".to_string()).unwrap()),
+ assert_eq!(*(diff1.get(&"in-both-want-upwards-but-regressed".to_string()).unwrap()),
Regression(50.0));
- assert_eq!(*(diff1.find(&"in-both-want-upwards-and-improved".to_string()).unwrap()),
+ assert_eq!(*(diff1.get(&"in-both-want-upwards-and-improved".to_string()).unwrap()),
Improvement(100.0));
assert_eq!(diff1.len(), 7);
let diff2 = m2.compare_to_old(&m1, Some(200.0));
- assert_eq!(*(diff2.find(&"in-both-noise".to_string()).unwrap()), LikelyNoise);
- assert_eq!(*(diff2.find(&"in-first-noise".to_string()).unwrap()), MetricRemoved);
- assert_eq!(*(diff2.find(&"in-second-noise".to_string()).unwrap()), MetricAdded);
- assert_eq!(*(diff2.find(&"in-both-want-downwards-but-regressed".to_string()).unwrap()),
+ assert_eq!(*(diff2.get(&"in-both-noise".to_string()).unwrap()), LikelyNoise);
+ assert_eq!(*(diff2.get(&"in-first-noise".to_string()).unwrap()), MetricRemoved);
+ assert_eq!(*(diff2.get(&"in-second-noise".to_string()).unwrap()), MetricAdded);
+ assert_eq!(*(diff2.get(&"in-both-want-downwards-but-regressed".to_string()).unwrap()),
LikelyNoise);
- assert_eq!(*(diff2.find(&"in-both-want-downwards-and-improved".to_string()).unwrap()),
+ assert_eq!(*(diff2.get(&"in-both-want-downwards-and-improved".to_string()).unwrap()),
LikelyNoise);
- assert_eq!(*(diff2.find(&"in-both-want-upwards-but-regressed".to_string()).unwrap()),
+ assert_eq!(*(diff2.get(&"in-both-want-upwards-but-regressed".to_string()).unwrap()),
LikelyNoise);
- assert_eq!(*(diff2.find(&"in-both-want-upwards-and-improved".to_string()).unwrap()),
+ assert_eq!(*(diff2.get(&"in-both-want-upwards-and-improved".to_string()).unwrap()),
LikelyNoise);
assert_eq!(diff2.len(), 7);
}
let (diff1, ok1) = m2.ratchet(&pth, None);
assert_eq!(ok1, false);
assert_eq!(diff1.len(), 2);
- assert_eq!(*(diff1.find(&"runtime".to_string()).unwrap()), Regression(10.0));
- assert_eq!(*(diff1.find(&"throughput".to_string()).unwrap()), LikelyNoise);
+ assert_eq!(*(diff1.get(&"runtime".to_string()).unwrap()), Regression(10.0));
+ assert_eq!(*(diff1.get(&"throughput".to_string()).unwrap()), LikelyNoise);
// Check that it was not rewritten.
let m3 = MetricMap::load(&pth);
let MetricMap(m3) = m3;
assert_eq!(m3.len(), 2);
- assert_eq!(*(m3.find(&"runtime".to_string()).unwrap()), Metric::new(1000.0, 2.0));
- assert_eq!(*(m3.find(&"throughput".to_string()).unwrap()), Metric::new(50.0, 2.0));
+ assert_eq!(*(m3.get(&"runtime".to_string()).unwrap()), Metric::new(1000.0, 2.0));
+ assert_eq!(*(m3.get(&"throughput".to_string()).unwrap()), Metric::new(50.0, 2.0));
// Ask for a ratchet with an explicit noise-percentage override,
// that should advance.
let (diff2, ok2) = m2.ratchet(&pth, Some(10.0));
assert_eq!(ok2, true);
assert_eq!(diff2.len(), 2);
- assert_eq!(*(diff2.find(&"runtime".to_string()).unwrap()), LikelyNoise);
- assert_eq!(*(diff2.find(&"throughput".to_string()).unwrap()), LikelyNoise);
+ assert_eq!(*(diff2.get(&"runtime".to_string()).unwrap()), LikelyNoise);
+ assert_eq!(*(diff2.get(&"throughput".to_string()).unwrap()), LikelyNoise);
// Check that it was rewritten.
let m4 = MetricMap::load(&pth);
let MetricMap(m4) = m4;
assert_eq!(m4.len(), 2);
- assert_eq!(*(m4.find(&"runtime".to_string()).unwrap()), Metric::new(1100.0, 2.0));
- assert_eq!(*(m4.find(&"throughput".to_string()).unwrap()), Metric::new(50.0, 2.0));
+ assert_eq!(*(m4.get(&"runtime".to_string()).unwrap()), Metric::new(1100.0, 2.0));
+ assert_eq!(*(m4.get(&"throughput".to_string()).unwrap()), Metric::new(50.0, 2.0));
}
}
impl MutableMap for TreeMap<uint, uint> {
fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k) }
- fn find(&self, k: &uint) -> Option<&uint> { self.find(k) }
+ fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
+ fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
}
impl MutableMap for HashMap<uint, uint> {
fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k) }
- fn find(&self, k: &uint) -> Option<&uint> { self.find(k) }
+ fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
+ fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
}
impl MutableMap for TrieMap<uint> {
fn insert(&mut self, k: uint, v: uint) { self.insert(k, v); }
- fn remove(&mut self, k: &uint) -> bool { self.remove(k) }
- fn find(&self, k: &uint) -> Option<&uint> { self.find(k) }
+ fn remove(&mut self, k: &uint) -> bool { self.remove(k).is_some() }
+ fn find(&self, k: &uint) -> Option<&uint> { self.get(k) }
}
fn ascending<M: MutableMap>(map: &mut M, n_keys: uint) {
creatures_met += 2;
- to_creature.get_mut(fst_creature.name).send(snd_creature);
- to_creature.get_mut(snd_creature.name).send(fst_creature);
+ to_creature[fst_creature.name].send(snd_creature);
+ to_creature[snd_creature.name].send(fst_creature);
}
// tell each creature to stop
result.push(a_i);
}
let result_len = result.len();
- result.get_mut(result_len - 1).p = LOOKUP_SCALE;
+ result[result_len - 1].p = LOOKUP_SCALE;
result
}
next: None,
};
c.f(&mut *entry);
- *self.items.get_mut(index as uint) = Some(entry);
+ self.items[index as uint] = Some(entry);
return;
}
}
{
- let entry = self.items.get_mut(index as uint).as_mut().unwrap();
+ let entry = self.items[index as uint].as_mut().unwrap();
if entry.code == key {
c.f(&mut **entry);
return;
fn filter_masks(masks: &mut Vec<Vec<Vec<u64>>>) {
for i in range(0, masks.len()) {
for j in range(0, (*masks)[i].len()) {
- *masks.get_mut(i).get_mut(j) =
+ masks[i][j] =
(*masks)[i][j].iter().map(|&m| m)
.filter(|&m| !is_board_unfeasible(m, masks))
.collect();
let id = '0' as u8 + get_id(m);
for i in range(0u, 50) {
if m & 1 << i != 0 {
- *sol.get_mut(i) = id;
+ sol[i] = id;
}
}
}
}
for (i, variant) in variant_strs.iter().enumerate() {
- println!("{} {}", variant, counts.get_mut(i).get());
+ println!("{} {}", variant, counts[i].get());
}
println!("");
println!("{}", ilen);
let mut vec = Vec::with_capacity(CHUNK);
loop {
// workaround: very fast growing
- if vec.capacity() - vec.len() < CHUNK {
+ let len = vec.len();
+ if vec.capacity() - len < CHUNK {
let cap = vec.capacity();
let mult = if cap < 256 * 1024 * 1024 {
16
} else {
2
};
- vec.reserve_exact(mult * cap);
+ vec.reserve_exact(mult * cap - len);
}
match r.push_at_least(1, CHUNK, &mut vec) {
Ok(_) => {}
if comps.len() == 3u {
let row = from_str::<uint>(comps[0]).unwrap() as u8;
let col = from_str::<uint>(comps[1]).unwrap() as u8;
- *g.get_mut(row as uint).get_mut(col as uint) =
+ g[row as uint][col as uint] =
from_str::<uint>(comps[2]).unwrap() as u8;
}
else {
// find first remaining color that is available
let next = avail.next();
- *self.grid.get_mut(row as uint).get_mut(col as uint) = next;
+ self.grid[row as uint][col as uint] = next;
return 0u8 != next;
}
- *self.grid.get_mut(row as uint).get_mut(col as uint) = 0u8;
+ self.grid[row as uint][col as uint] = 0u8;
return false;
}
// Create an immutable pointer into p's contents:
let q: &int = &p[0];
- *p.get_mut(0) = 5; //~ ERROR cannot borrow
+ p[0] = 5; //~ ERROR cannot borrow
println!("{}", *q);
}
borrow(
p.as_slice(),
- || *p.get_mut(0) = 5); //~ ERROR cannot borrow `p` as mutable
+ || p[0] = 5); //~ ERROR cannot borrow `p` as mutable
}
fn c() {
// modification:
let mut p = vec!(1);
borrow(p.as_slice(), ||{});
- *p.get_mut(0) = 5;
+ p[0] = 5;
}
fn main() {
for &x in vector.iter() {
let cap = vector.capacity();
vector.grow(cap, 0u); //~ ERROR cannot borrow
- *vector.get_mut(1u) = 5u; //~ ERROR cannot borrow
+ vector[1u] = 5u; //~ ERROR cannot borrow
}
}
takes_imm_elt(
&v[0],
|| { //~ ERROR cannot borrow `v` as mutable
- *v.get_mut(1) = 4;
+ v[1] = 4;
})
}
let mut a: Vec<int> = vec!(-1, -1, -1, -1);
let mut p: int = 0;
two(|i| {
- two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; })
+ two(|j| { a[p as uint] = 10 * i + j; p += 1; })
});
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
mapper_done => { num_mappers -= 1; }
find_reducer(k, cc) => {
let mut c;
- match reducers.find(&str::from_utf8(
+ match reducers.get(&str::from_utf8(
k.as_slice()).unwrap().to_string()) {
Some(&_c) => { c = _c; }
None => { c = 0; }
// element is:
// 1) potentially large
// 2) needs to be modified
- let row = self.lines.get_mut(v);
- *row.get_mut(h) = self.fill;
+ let row = &mut self.lines[v];
+ row[h] = self.fill;
}
}
}
impl HasNested {
fn method_push_local(&mut self) {
- self.nest.get_mut(0).push(0);
+ self.nest[0].push(0);
}
}
assert_eq!(*(*p).borrow(), Point {x: 3, y: 5});
let v = Rc::new(RefCell::new(vec!(1i, 2, 3)));
- *(*(*v).borrow_mut()).get_mut(0) = 3;
- *(*(*v).borrow_mut()).get_mut(1) += 3;
+ (*(*v).borrow_mut())[0] = 3;
+ (*(*v).borrow_mut())[1] += 3;
assert_eq!(((*(*v).borrow())[0],
(*(*v).borrow())[1],
(*(*v).borrow())[2]), (3, 5, 3));
pub fn main() {
let mut map: HashMap<SendStr, uint> = HashMap::new();
- assert!(map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_string()), 42));
- assert!(!map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_string()), 42));
+ assert!(map.insert(Slice("foo"), 42).is_none());
+ assert!(map.insert(Owned("foo".to_string()), 42).is_some());
+ assert!(map.insert(Slice("foo"), 42).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 42).is_some());
- assert!(!map.insert(Slice("foo"), 43));
- assert!(!map.insert(Owned("foo".to_string()), 44));
- assert!(!map.insert(Slice("foo"), 45));
- assert!(!map.insert(Owned("foo".to_string()), 46));
+ assert!(map.insert(Slice("foo"), 43).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 44).is_some());
+ assert!(map.insert(Slice("foo"), 45).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 46).is_some());
let v = 46;
- assert_eq!(map.find(&Owned("foo".to_string())), Some(&v));
- assert_eq!(map.find(&Slice("foo")), Some(&v));
+ assert_eq!(map.get(&Owned("foo".to_string())), Some(&v));
+ assert_eq!(map.get(&Slice("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
- assert!(map.insert(Slice("abc"), a));
- assert!(map.insert(Owned("bcd".to_string()), b));
- assert!(map.insert(Slice("cde"), c));
- assert!(map.insert(Owned("def".to_string()), d));
+ assert!(map.insert(Slice("abc"), a).is_none());
+ assert!(map.insert(Owned("bcd".to_string()), b).is_none());
+ assert!(map.insert(Slice("cde"), c).is_none());
+ assert!(map.insert(Owned("def".to_string()), d).is_none());
- assert!(!map.insert(Slice("abc"), a));
- assert!(!map.insert(Owned("bcd".to_string()), b));
- assert!(!map.insert(Slice("cde"), c));
- assert!(!map.insert(Owned("def".to_string()), d));
+ assert!(map.insert(Slice("abc"), a).is_some());
+ assert!(map.insert(Owned("bcd".to_string()), b).is_some());
+ assert!(map.insert(Slice("cde"), c).is_some());
+ assert!(map.insert(Owned("def".to_string()), d).is_some());
- assert!(!map.insert(Owned("abc".to_string()), a));
- assert!(!map.insert(Slice("bcd"), b));
- assert!(!map.insert(Owned("cde".to_string()), c));
- assert!(!map.insert(Slice("def"), d));
+ assert!(map.insert(Owned("abc".to_string()), a).is_some());
+ assert!(map.insert(Slice("bcd"), b).is_some());
+ assert!(map.insert(Owned("cde".to_string()), c).is_some());
+ assert!(map.insert(Slice("def"), d).is_some());
assert_eq!(map.find_equiv("abc"), Some(&a));
assert_eq!(map.find_equiv("bcd"), Some(&b));
pub fn main() {
let mut map: TreeMap<SendStr, uint> = TreeMap::new();
- assert!(map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_string()), 42));
- assert!(!map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_string()), 42));
+ assert!(map.insert(Slice("foo"), 42).is_none());
+ assert!(map.insert(Owned("foo".to_string()), 42).is_some());
+ assert!(map.insert(Slice("foo"), 42).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 42).is_some());
- assert!(!map.insert(Slice("foo"), 43));
- assert!(!map.insert(Owned("foo".to_string()), 44));
- assert!(!map.insert(Slice("foo"), 45));
- assert!(!map.insert(Owned("foo".to_string()), 46));
+ assert!(map.insert(Slice("foo"), 43).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 44).is_some());
+ assert!(map.insert(Slice("foo"), 45).is_some());
+ assert!(map.insert(Owned("foo".to_string()), 46).is_some());
let v = 46;
- assert_eq!(map.find(&Owned("foo".to_string())), Some(&v));
- assert_eq!(map.find(&Slice("foo")), Some(&v));
+ assert_eq!(map.get(&Owned("foo".to_string())), Some(&v));
+ assert_eq!(map.get(&Slice("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
- assert!(map.insert(Slice("abc"), a));
- assert!(map.insert(Owned("bcd".to_string()), b));
- assert!(map.insert(Slice("cde"), c));
- assert!(map.insert(Owned("def".to_string()), d));
+ assert!(map.insert(Slice("abc"), a).is_none());
+ assert!(map.insert(Owned("bcd".to_string()), b).is_none());
+ assert!(map.insert(Slice("cde"), c).is_none());
+ assert!(map.insert(Owned("def".to_string()), d).is_none());
- assert!(!map.insert(Slice("abc"), a));
- assert!(!map.insert(Owned("bcd".to_string()), b));
- assert!(!map.insert(Slice("cde"), c));
- assert!(!map.insert(Owned("def".to_string()), d));
+ assert!(map.insert(Slice("abc"), a).is_some());
+ assert!(map.insert(Owned("bcd".to_string()), b).is_some());
+ assert!(map.insert(Slice("cde"), c).is_some());
+ assert!(map.insert(Owned("def".to_string()), d).is_some());
- assert!(!map.insert(Owned("abc".to_string()), a));
- assert!(!map.insert(Slice("bcd"), b));
- assert!(!map.insert(Owned("cde".to_string()), c));
- assert!(!map.insert(Slice("def"), d));
+ assert!(map.insert(Owned("abc".to_string()), a).is_some());
+ assert!(map.insert(Slice("bcd"), b).is_some());
+ assert!(map.insert(Owned("cde".to_string()), c).is_some());
+ assert!(map.insert(Slice("def"), d).is_some());
- assert_eq!(map.find(&Slice("abc")), Some(&a));
- assert_eq!(map.find(&Slice("bcd")), Some(&b));
- assert_eq!(map.find(&Slice("cde")), Some(&c));
- assert_eq!(map.find(&Slice("def")), Some(&d));
+ assert_eq!(map.get(&Slice("abc")), Some(&a));
+ assert_eq!(map.get(&Slice("bcd")), Some(&b));
+ assert_eq!(map.get(&Slice("cde")), Some(&c));
+ assert_eq!(map.get(&Slice("def")), Some(&d));
- assert_eq!(map.find(&Owned("abc".to_string())), Some(&a));
- assert_eq!(map.find(&Owned("bcd".to_string())), Some(&b));
- assert_eq!(map.find(&Owned("cde".to_string())), Some(&c));
- assert_eq!(map.find(&Owned("def".to_string())), Some(&d));
+ assert_eq!(map.get(&Owned("abc".to_string())), Some(&a));
+ assert_eq!(map.get(&Owned("bcd".to_string())), Some(&b));
+ assert_eq!(map.get(&Owned("cde".to_string())), Some(&c));
+ assert_eq!(map.get(&Owned("def".to_string())), Some(&d));
- assert!(map.pop(&Slice("foo")).is_some());
+ assert!(map.remove(&Slice("foo")).is_some());
assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v))
.collect::<Vec<String>>()
.concat(),
assert_eq!(a[2], 4);
assert_eq!(a[4], 2);
let mut n = 42;
- swap(&mut n, a.get_mut(0));
+ swap(&mut n, &mut a[0]);
assert_eq!(a[0], 42);
assert_eq!(n, 0);
}
assert_eq!(*b[0], 10);
// This should only modify the value in a, not b
- **a.get_mut(0) = 20;
+ *a[0] = 20;
assert_eq!(*a[0], 20);
assert_eq!(*b[0], 10);