Skip to content

Commit

Permalink
Fallout from collection conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Nov 6, 2014
1 parent cf3b2e4 commit eec145b
Show file tree
Hide file tree
Showing 101 changed files with 418 additions and 417 deletions.
2 changes: 1 addition & 1 deletion src/libgreen/lib.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/sched.rs
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/link.rs
Expand Up @@ -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 => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/session.rs
Expand Up @@ -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 => {}
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/lint/builtin.rs
Expand Up @@ -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!")
};
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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, .. }) => {
Expand Down Expand Up @@ -1637,15 +1637,15 @@ 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
}
}
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) => {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/lint/context.rs
Expand Up @@ -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),
}
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/cstore.rs
Expand Up @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/decoder.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
};
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -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());
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/metadata/tydecode.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tyencode.rs
Expand Up @@ -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 => {}
}
Expand Down
26 changes: 13 additions & 13 deletions src/librustc/middle/astencode.rs
Expand Up @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand Down Expand Up @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand All @@ -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| {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/move_data.rs
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit eec145b

Please sign in to comment.