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

@ -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