Fallout from collection conventions

This commit is contained in:
Alexis Beingessner 2014-11-06 12:25:16 -05:00
parent cf3b2e4fe6
commit eec145be3f
101 changed files with 418 additions and 417 deletions

View File

@ -417,7 +417,7 @@ impl SchedPool {
}
// 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

View File

@ -502,7 +502,7 @@ impl Scheduler {
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)

View File

@ -220,7 +220,7 @@ fn symbol_hash(tcx: &ty::ctxt,
}
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 => {}
}

View File

@ -127,7 +127,7 @@ impl Session {
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 => {}
}

View File

@ -403,7 +403,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
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!")
};
@ -994,7 +994,7 @@ impl LintPass for NonSnakeCase {
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);
}
@ -1051,7 +1051,7 @@ impl LintPass for NonUpperCaseGlobals {
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()) {
@ -1211,7 +1211,7 @@ impl LintPass for NonShorthandFieldPatterns {
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()
@ -1368,7 +1368,7 @@ impl LintPass for UnusedAllocation {
_ => 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, .. }) => {
@ -1637,7 +1637,7 @@ impl LintPass for Stability {
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
}
@ -1645,7 +1645,7 @@ impl LintPass for Stability {
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) => {

View File

@ -84,7 +84,7 @@ enum TargetLint {
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),
}
@ -124,7 +124,7 @@ impl LintStore {
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.
@ -147,7 +147,7 @@ impl LintStore {
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);
@ -437,11 +437,11 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
/// 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);
@ -750,7 +750,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
// 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() {

View File

@ -213,7 +213,7 @@ impl CStore {
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)
}
}

View File

@ -1209,7 +1209,7 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
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,
@ -1321,7 +1321,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
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")
};

View File

@ -253,7 +253,7 @@ fn encode_symbol(ecx: &EncodeContext,
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());
@ -397,7 +397,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
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() {
@ -426,7 +426,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
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 {
@ -531,7 +531,7 @@ fn encode_reexports(ecx: &EncodeContext,
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() {
@ -978,7 +978,7 @@ fn should_inline(attrs: &[Attribute]) -> bool {
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() {
@ -994,7 +994,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
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() {
@ -1987,7 +1987,7 @@ fn encode_crate_triple(rbml_w: &mut Encoder, triple: &str) {
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 {

View File

@ -675,16 +675,16 @@ fn parse_builtin_bounds(st: &mut PState, _conv: conv_did) -> ty::BuiltinBounds {
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;

View File

@ -50,7 +50,7 @@ pub struct ty_abbrev {
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 => {}
}

View File

@ -1151,14 +1151,14 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
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| {
@ -1167,7 +1167,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
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| {
@ -1176,7 +1176,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
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| {
@ -1209,7 +1209,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
}
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| {
@ -1219,7 +1219,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
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| {
@ -1228,7 +1228,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
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| {
@ -1238,7 +1238,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
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| {
@ -1247,7 +1247,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
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| {
@ -1256,11 +1256,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
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| {
@ -1273,7 +1273,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
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| {
@ -1299,7 +1299,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
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);

View File

@ -242,7 +242,7 @@ impl MoveData {
* 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;
}
@ -577,7 +577,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
//! 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];

View File

@ -512,7 +512,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
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)
});
@ -610,7 +610,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
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 {

View File

@ -143,7 +143,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
"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(..)) |
@ -162,7 +162,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
}
}
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.

View File

@ -639,7 +639,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
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"),
@ -648,7 +648,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
_ => 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"),
@ -656,7 +656,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
_ => 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"),

View File

@ -95,7 +95,7 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
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) => {

View File

@ -123,7 +123,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
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));
@ -163,7 +163,7 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId)
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));
@ -192,7 +192,7 @@ struct ConstEvalVisitor<'a, 'tcx: 'a> {
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 => {}
}

View File

@ -86,7 +86,7 @@ struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O: 'a> {
}
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);
})
@ -397,7 +397,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
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);

View File

@ -74,7 +74,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
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())
@ -95,7 +95,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
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) => {
@ -493,7 +493,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
// 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() {

View File

@ -158,7 +158,7 @@ fn calculate_type(sess: &session::Session,
// 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,
}
@ -209,7 +209,7 @@ fn add_library(sess: &session::Session,
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

View File

@ -162,7 +162,7 @@ impl OverloadedCallType {
let trait_did =
tcx.unboxed_closures
.borrow()
.find(&closure_did)
.get(&closure_did)
.expect("OverloadedCallType::from_unboxed_closure: didn't \
find closure id")
.kind
@ -535,7 +535,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
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(),
@ -686,7 +686,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
// 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 {

View File

@ -173,7 +173,7 @@ impl<'a> LanguageItemCollector<'a> {
}
// 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) {

View File

@ -322,7 +322,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
}
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
@ -591,7 +591,7 @@ impl<'a, 'tcx> Liveness<'a, '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
@ -719,7 +719,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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")
@ -988,7 +988,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// 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");
@ -1096,7 +1096,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// 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")
@ -1110,7 +1110,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// 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")
@ -1167,7 +1167,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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
@ -1520,7 +1520,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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

View File

@ -389,7 +389,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
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)))
}
@ -402,7 +402,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
}
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)
@ -861,7 +861,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
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
@ -1170,7 +1170,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// 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)

View File

@ -34,7 +34,7 @@ pub fn pat_is_refutable(dm: &resolve::DefMap, pat: &Pat) -> bool {
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
}
@ -47,7 +47,7 @@ pub fn pat_is_refutable(dm: &resolve::DefMap, pat: &Pat) -> bool {
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
}
@ -59,7 +59,7 @@ pub fn pat_is_variant_or_struct(dm: &resolve::DefMap, pat: &Pat) -> bool {
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
}

View File

@ -399,7 +399,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
}
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);
@ -462,7 +462,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
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;
}
@ -855,7 +855,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
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 \
@ -909,7 +909,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
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))
@ -986,7 +986,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
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,

View File

@ -106,7 +106,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
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,

View File

@ -103,7 +103,7 @@ struct RegionResolutionVisitor<'a> {
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);
@ -149,13 +149,13 @@ impl RegionMaps {
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); }
}
@ -165,7 +165,7 @@ impl RegionMaps {
/*!
* 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); }
}
@ -175,7 +175,7 @@ impl RegionMaps {
//! 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);
@ -232,7 +232,7 @@ impl RegionMaps {
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);
@ -356,7 +356,7 @@ impl RegionMaps {
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);

View File

@ -2234,7 +2234,7 @@ impl<'a> Resolver<'a> {
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");
@ -2552,7 +2552,7 @@ impl<'a> Resolver<'a> {
// 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.
}
@ -2588,7 +2588,7 @@ impl<'a> Resolver<'a> {
}
// 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
@ -2853,7 +2853,7 @@ impl<'a> Resolver<'a> {
// 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.
@ -3046,7 +3046,7 @@ impl<'a> Resolver<'a> {
// 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
@ -3432,7 +3432,7 @@ impl<'a> Resolver<'a> {
// 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");
@ -3448,7 +3448,7 @@ impl<'a> Resolver<'a> {
// 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.
}
@ -3705,7 +3705,7 @@ impl<'a> Resolver<'a> {
// 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");
@ -3728,7 +3728,7 @@ impl<'a> Resolver<'a> {
}
// 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 => {
@ -3967,7 +3967,7 @@ impl<'a> Resolver<'a> {
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),
@ -4691,7 +4691,7 @@ impl<'a> Resolver<'a> {
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()))
@ -4767,7 +4767,7 @@ impl<'a> Resolver<'a> {
// 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 \
@ -4785,7 +4785,7 @@ impl<'a> Resolver<'a> {
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 `{}`",
@ -4849,7 +4849,7 @@ impl<'a> Resolver<'a> {
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,
@ -4908,7 +4908,7 @@ impl<'a> Resolver<'a> {
// 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 \
@ -4943,7 +4943,7 @@ impl<'a> Resolver<'a> {
match self.primitive_type_table
.primitive_types
.find(&id.name) {
.get(&id.name) {
Some(&primitive_type) => {
result_def =
@ -5181,7 +5181,7 @@ impl<'a> Resolver<'a> {
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.
@ -5407,7 +5407,7 @@ impl<'a> Resolver<'a> {
// 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) => {
@ -5426,7 +5426,7 @@ impl<'a> Resolver<'a> {
}
// 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) => {
@ -5715,10 +5715,10 @@ impl<'a> Resolver<'a> {
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
}
@ -5746,10 +5746,10 @@ impl<'a> Resolver<'a> {
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) {
@ -5765,7 +5765,7 @@ impl<'a> Resolver<'a> {
// 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) {
@ -5790,7 +5790,7 @@ impl<'a> Resolver<'a> {
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)
}
@ -6270,7 +6270,7 @@ impl<'a> Resolver<'a> {
"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: _,

View File

@ -906,7 +906,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
{
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,
@ -1032,7 +1032,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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(
@ -1282,7 +1282,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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)
@ -1306,7 +1306,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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)
@ -1323,7 +1323,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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)
@ -1428,7 +1428,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// 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()))
@ -1690,7 +1690,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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(
@ -1973,7 +1973,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
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()
}

View File

@ -696,13 +696,13 @@ fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: uint) -> bool {
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
}

View File

@ -147,7 +147,7 @@ pub fn represent_node(bcx: Block, node: ast::NodeId) -> Rc<Repr> {
/// 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 => {}
}

View File

@ -316,7 +316,7 @@ pub fn get_extern_const(ccx: &CrateContext, did: ast::DefId,
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 => ()
}
@ -409,7 +409,7 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu
// 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(),
_ => { }
}
@ -2100,7 +2100,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
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,
};
@ -2645,7 +2645,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
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);
@ -3123,7 +3123,7 @@ pub fn trans_crate<'tcx>(analysis: CrateAnalysis<'tcx>)
.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

View File

@ -81,7 +81,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
s.push('/');
s.push_str(category);
let n = match h.find(&s) {
let n = match h.get(&s) {
Some(&n) => n,
_ => 0u
};

View File

@ -438,7 +438,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'blk, 'tcx>(bcx: Block<'blk,
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");
@ -564,7 +564,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
}
};
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 => {}
}

View File

@ -466,7 +466,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
}
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!(
@ -505,7 +505,7 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
self.tcx()
.method_map
.borrow()
.find(&method_call)
.get(&method_call)
.map(|method| monomorphize_type(self, method.ty))
}
@ -647,7 +647,7 @@ pub fn C_u8(ccx: &CrateContext, i: uint) -> ValueRef {
// 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 => ()
}
@ -813,7 +813,7 @@ pub fn fulfill_obligation(ccx: &CrateContext,
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();

View File

@ -90,7 +90,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
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
}
}
@ -125,7 +125,7 @@ pub fn const_addr_of(cx: &CrateContext, cv: ValueRef, mutbl: ast::Mutability) ->
}
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
};

View File

@ -421,7 +421,7 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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",

View File

@ -282,7 +282,7 @@ impl TypeMap {
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());
}
@ -294,7 +294,7 @@ impl TypeMap {
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());
@ -468,7 +468,7 @@ impl TypeMap {
},
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);
@ -2939,7 +2939,7 @@ fn type_metadata(cx: &CrateContext,
}
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) => {

View File

@ -212,7 +212,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// 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)
@ -601,7 +601,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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));
@ -736,7 +736,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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) => {
@ -1114,7 +1114,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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 =
@ -1232,7 +1232,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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!(
@ -1242,7 +1242,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
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!(
@ -2089,7 +2089,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// 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

View File

@ -144,7 +144,7 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef {
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,
_ => { }
}
@ -157,7 +157,7 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef {
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)

View File

@ -21,7 +21,7 @@ use syntax::ast_util::{local_def, PostExpansionMethod};
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 {}",

View File

@ -116,7 +116,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let (origin, method_ty) =
bcx.tcx().method_map
.borrow()
.find(&method_call)
.get(&method_call)
.map(|method| (method.origin.clone(), method.ty))
.unwrap();
@ -308,7 +308,7 @@ fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name)
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| {
@ -559,7 +559,7 @@ pub fn get_vtable(bcx: Block,
// 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 => { }
}
@ -599,7 +599,7 @@ pub fn get_vtable(bcx: Block,
.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 {

View File

@ -54,7 +54,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
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));
@ -106,7 +106,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
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
};

View File

@ -332,7 +332,7 @@ impl TypeNames {
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> {

View File

@ -272,7 +272,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
}
// Check the cache.
match cx.lltypes().borrow().find(&t) {
match cx.lltypes().borrow().get(&t) {
Some(&llty) => return llty,
None => ()
}

View File

@ -1080,14 +1080,14 @@ pub enum BuiltinBound {
}
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
}
@ -1584,7 +1584,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
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); },
_ => ()
}
@ -2418,11 +2418,11 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
// 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 => {}
}
@ -3192,7 +3192,7 @@ pub fn array_element_ty(t: t) -> Option<t> {
}
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 `{}`",
@ -3214,14 +3214,14 @@ pub fn node_id_to_type(cx: &ctxt, id: ast::NodeId) -> t {
}
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(),
}
@ -3361,8 +3361,8 @@ pub fn expr_ty_adjusted(cx: &ctxt, expr: &ast::Expr) -> t {
*/
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 {
@ -3553,7 +3553,7 @@ pub fn unsize_ty(cx: &ctxt,
}
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!(
@ -3690,7 +3690,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
}
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
@ -3736,7 +3736,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
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"),
};
@ -4003,7 +4003,7 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
}
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>> {
@ -4113,7 +4113,7 @@ pub fn impl_or_trait_item(cx: &ctxt, id: ast::DefId) -> ImplOrTraitItem {
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,
@ -4198,7 +4198,7 @@ pub fn impl_trait_ref(cx: &ctxt, id: ast::DefId) -> Option<Rc<TraitRef>> {
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()
}
@ -4215,7 +4215,7 @@ pub fn try_add_builtin_trait(
//! 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
}
}
@ -4346,7 +4346,7 @@ impl DtorKind {
/* 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");
@ -4569,7 +4569,7 @@ pub fn lookup_field_type(tcx: &ctxt,
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(
@ -4632,7 +4632,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
// 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| {
@ -4898,7 +4898,7 @@ pub fn required_region_bounds(tcx: &ctxt,
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);
}
}
@ -4921,7 +4921,7 @@ pub fn item_variances(tcx: &ctxt, item_id: ast::DefId) -> Rc<ItemVariances> {
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;
@ -5094,7 +5094,7 @@ pub fn trait_of_item(tcx: &ctxt, def_id: ast::DefId) -> Option<ast::DefId> {
/// 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,
};
@ -5449,7 +5449,7 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> {
}
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>> {
@ -5561,7 +5561,7 @@ pub type FreevarMap = NodeMap<Vec<Freevar>>;
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())
}

View File

@ -99,7 +99,7 @@ pub trait AstConv<'tcx> {
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");
@ -467,7 +467,7 @@ fn check_path_args(tcx: &ty::ctxt,
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 {}",
@ -524,7 +524,7 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
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
@ -675,7 +675,7 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
// 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 {
@ -802,7 +802,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
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,
@ -900,7 +900,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
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,
@ -990,7 +990,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
}
}
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")
@ -1549,7 +1549,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
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).

View File

@ -324,7 +324,7 @@ pub fn check_pat_struct(pcx: &pat_ctxt, pat: &ast::Pat,
let item_substs = fcx
.item_substs()
.find(&pat.id)
.get(&pat.id)
.map(|substs| substs.substs.clone())
.unwrap_or_else(|| Substs::empty());

View File

@ -678,7 +678,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
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) {
@ -912,7 +912,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
// 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);
}
@ -1627,7 +1627,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
.inh
.adjustments
.borrow()
.find(&expr.id) {
.get(&expr.id) {
Some(&ty::AdjustDerefRef(ty::AutoDerefRef {
autoderefs: autoderef_count,
autoref: _
@ -1658,7 +1658,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
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(_) => {
@ -1839,7 +1839,7 @@ fn impl_method(tcx: &ty::ctxt,
-> 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()))

View File

@ -298,7 +298,7 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> {
}
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
@ -1556,7 +1556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
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(
@ -1808,7 +1808,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
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 {}",
@ -1824,7 +1824,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
*/
let adjustments = self.inh.adjustments.borrow();
let adjustment = adjustments.find(&expr.id);
let adjustment = adjustments.get(&expr.id);
self.adjust_expr_ty(expr, adjustment)
}
@ -1845,12 +1845,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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(
@ -1868,7 +1868,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 => { }
}
@ -3554,7 +3554,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
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)
}
_ => {
@ -3763,7 +3763,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
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(
@ -4422,7 +4422,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
}
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,
@ -5603,7 +5603,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool {
(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,
}

View File

@ -327,7 +327,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
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))
}
@ -339,7 +339,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
} 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))
}
}
@ -351,7 +351,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
// 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(
@ -370,7 +370,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
{
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() {
@ -594,7 +594,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
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}) => {
@ -686,7 +686,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
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);
@ -950,7 +950,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
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,
@ -1195,7 +1195,7 @@ fn constrain_autoderefs(rcx: &mut Rcx,
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.
@ -1301,7 +1301,7 @@ fn type_of_node_must_outlive(
// 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={})",
@ -1582,7 +1582,7 @@ fn link_reborrowed_region(rcx: &Rcx,
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
@ -1845,7 +1845,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx,
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);
}

View File

@ -263,7 +263,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
}
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);
}
@ -275,7 +275,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
// 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(..)) |
@ -320,7 +320,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
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,

View File

@ -294,7 +294,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
}
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;

View File

@ -114,7 +114,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
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 */ }
}

View File

@ -1243,7 +1243,7 @@ pub fn convert_struct(ccx: &CrateCtxt,
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",
@ -1386,7 +1386,7 @@ fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc<ty::TraitDef> {
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(),
_ => {}
}
@ -1486,7 +1486,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
-> 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(),
_ => {}
}
@ -1528,7 +1528,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
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 => { }
}
@ -1933,7 +1933,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
-> ty::TypeParameterDef
where AC: AstConv<'tcx>
{
match this.tcx().ty_param_defs.borrow().find(&param.id) {
match this.tcx().ty_param_defs.borrow().get(&param.id) {
Some(d) => { return (*d).clone(); }
None => { }
}
@ -2027,13 +2027,13 @@ fn check_bounds_compatible(tcx: &ty::ctxt,
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",
@ -2136,7 +2136,7 @@ fn merge_param_bounds<'a>(tcx: &ty::ctxt,
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();

View File

@ -1240,7 +1240,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
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

View File

@ -367,7 +367,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
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));
}
@ -559,7 +559,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
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));
}
@ -991,7 +991,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
debug!("expansion: constraint={} origin={}",
constraint.repr(self.tcx),
self.constraints.borrow()
.find(constraint)
.get(constraint)
.unwrap()
.repr(self.tcx));
match *constraint {
@ -1075,7 +1075,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
debug!("contraction: constraint={} origin={}",
constraint.repr(self.tcx),
self.constraints.borrow()
.find(constraint)
.get(constraint)
.unwrap()
.repr(self.tcx));
match *constraint {

View File

@ -113,7 +113,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
// 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)))

View File

@ -301,7 +301,7 @@ pub fn write_substs_to_tcx(tcx: &ty::ctxt,
}
}
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")

View File

@ -322,7 +322,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
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={}, \
@ -376,7 +376,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
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);
}
@ -556,7 +556,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
match self.terms_cx.inferred_map.find(&param_id) {
match self.terms_cx.inferred_map.get(&param_id) {
Some(&index) => index,
None => {
self.tcx().sess.bug(format!(
@ -569,7 +569,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
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(&param_id) {
match tcx.named_region_map.get(&param_id) {
Some(&rl::DefEarlyBoundRegion(_, _, lifetime_decl_id))
=> lifetime_decl_id,
Some(_) => panic!("should not encounter non early-bound cases"),
@ -810,7 +810,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
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);
}
@ -1060,7 +1060,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
}
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);
}
}

View File

@ -139,7 +139,7 @@ pub fn can_reach<S,H:Hasher<S>,T:Eq+Clone+Hash<S>>(
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 {
@ -200,7 +200,7 @@ pub fn memoized_with_key<T, K: Hash<S> + Eq, U: Clone, S, H: Hasher<S>>(
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 => {

View File

@ -451,7 +451,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String {
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())
}
@ -1108,7 +1108,7 @@ impl UserString for ty::ParamBounds {
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);
@ -1277,7 +1277,7 @@ impl UserString for ParamTy {
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

View File

@ -45,7 +45,7 @@ pub fn try_inline(cx: &DocContext, id: ast::NodeId, into: Option<ast::Ident>)
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,
};
@ -223,7 +223,7 @@ fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
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) }));

View File

@ -1395,7 +1395,7 @@ impl Clean<Item> for ty::field_ty {
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);
@ -2090,7 +2090,7 @@ fn resolve_type(cx: &DocContext, path: Path,
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")
};
@ -2159,7 +2159,7 @@ fn resolve_use_source(cx: &DocContext, path: Path, id: ast::NodeId) -> ImportSou
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))
})
}

View File

@ -208,7 +208,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
}
},
|cache| {
match cache.paths.find(&did) {
match cache.paths.get(&did) {
None => None,
Some(&(ref fqp, shortty)) => Some((fqp.clone(), shortty))
}
@ -313,7 +313,7 @@ fn primitive_link(f: &mut fmt::Formatter,
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};

View File

@ -242,7 +242,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
// 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) }
};

View File

@ -389,7 +389,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
// 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),
@ -443,7 +443,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
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 => {}
@ -454,7 +454,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
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, ","));
}
@ -543,7 +543,7 @@ fn write_shared(cx: &Context,
//
// 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,
};
@ -838,7 +838,7 @@ impl DocFolder for Cache {
} 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
@ -1170,7 +1170,7 @@ impl Context {
&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());
@ -1735,7 +1735,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
<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>",
@ -1992,7 +1992,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
}
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 {
@ -2080,7 +2080,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
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 => {}
}

View File

@ -417,7 +417,7 @@ fn json_input(input: &str) -> Result<Output, String> {
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!(
@ -428,7 +428,7 @@ fn json_input(input: &str) -> Result<Output, String> {
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()

View File

@ -186,7 +186,7 @@ impl<T: 'static> KeyValue<T> {
// 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.
@ -266,7 +266,7 @@ impl<T: 'static> KeyValue<T> {
};
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 {

View File

@ -39,7 +39,7 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for DList<T> {
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)
})
@ -66,7 +66,7 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for RingBuf<T> {
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)
})
@ -165,10 +165,10 @@ impl<
> 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)

View File

@ -2113,7 +2113,7 @@ impl ::Decoder<DecoderError> for Decoder {
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)))
@ -2122,7 +2122,7 @@ impl ::Decoder<DecoderError> for Decoder {
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);
@ -2192,7 +2192,7 @@ impl ::Decoder<DecoderError> for Decoder {
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.
@ -3072,8 +3072,8 @@ mod tests {
\"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]

View File

@ -627,7 +627,7 @@ pub trait Reader {
/// 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) };
@ -658,7 +658,7 @@ pub trait Reader {
}
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.

View File

@ -1137,7 +1137,7 @@ mod tests {
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());
}
}

View File

@ -63,7 +63,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
()
});
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()
@ -93,7 +93,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
_ => 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());

View File

@ -768,7 +768,7 @@ impl SyntaxEnv {
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 => {}
}

View File

@ -252,7 +252,7 @@ impl<'a, 'b> Context<'a, 'b> {
}
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);
@ -260,7 +260,7 @@ impl<'a, 'b> Context<'a, 'b> {
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);
}
@ -555,11 +555,11 @@ impl<'a, 'b> Context<'a, 'b> {
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
};

View File

@ -182,7 +182,7 @@ fn resolve_internal(id: Ident,
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 => {}
}

View File

@ -45,7 +45,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
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 => (),
}

View File

@ -1209,7 +1209,7 @@ impl MetricMap {
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;
@ -1678,31 +1678,31 @@ mod tests {
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);
}
@ -1727,29 +1727,29 @@ mod tests {
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));
}
}

View File

@ -30,18 +30,18 @@ trait MutableMap {
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) {

View File

@ -197,8 +197,8 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
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

View File

@ -100,7 +100,7 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
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
}

View File

@ -171,13 +171,13 @@ impl Table {
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;

View File

@ -194,7 +194,7 @@ fn is_board_unfeasible(board: u64, masks: &Vec<Vec<Vec<u64>>>) -> bool {
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();
@ -217,7 +217,7 @@ fn to_vec(raw_sol: &List<u64>) -> Vec<u8> {
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;
}
}
}

View File

@ -114,7 +114,7 @@ fn main() {
}
for (i, variant) in variant_strs.iter().enumerate() {
println!("{} {}", variant, counts.get_mut(i).get());
println!("{} {}", variant, counts[i].get());
}
println!("");
println!("{}", ilen);

View File

@ -112,14 +112,15 @@ fn read_to_end<R: Reader>(r: &mut R) -> IoResult<Vec<u8>> {
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(_) => {}

View File

@ -79,7 +79,7 @@ impl Sudoku {
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 {
@ -139,10 +139,10 @@ impl Sudoku {
// 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;
}

View File

@ -19,7 +19,7 @@ fn a() {
// 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);
}
@ -34,7 +34,7 @@ fn b() {
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() {
@ -42,7 +42,7 @@ fn c() {
// modification:
let mut p = vec!(1);
borrow(p.as_slice(), ||{});
*p.get_mut(0) = 5;
p[0] = 5;
}
fn main() {

View File

@ -13,7 +13,7 @@ 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
}
}

View File

@ -26,7 +26,7 @@ fn has_mut_vec_but_tries_to_change_it() {
takes_imm_elt(
&v[0],
|| { //~ ERROR cannot borrow `v` as mutable
*v.get_mut(1) = 4;
v[1] = 4;
})
}

View File

@ -15,7 +15,7 @@ pub fn main() {
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);

View File

@ -83,7 +83,7 @@ mod map_reduce {
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; }

View File

@ -86,8 +86,8 @@ impl AsciiArt {
// 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;
}
}
}

View File

@ -15,7 +15,7 @@ struct HasNested {
impl HasNested {
fn method_push_local(&mut self) {
self.nest.get_mut(0).push(0);
self.nest[0].push(0);
}
}

View File

@ -44,8 +44,8 @@ pub fn main() {
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));

View File

@ -16,37 +16,37 @@ use std::option::Some;
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));

View File

@ -17,49 +17,49 @@ use std::option::Some;
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(),

View File

@ -16,7 +16,7 @@ pub fn main() {
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);
}

Some files were not shown because too many files have changed in this diff Show More