Skip to content

Commit eec145b

Browse files
committed
Fallout from collection conventions
1 parent cf3b2e4 commit eec145b

File tree

101 files changed

+418
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+418
-417
lines changed

src/libgreen/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl SchedPool {
417417
}
418418

419419
// Jettison the task away!
420-
self.handles.get_mut(idx).send(TaskFromFriend(task));
420+
self.handles[idx].send(TaskFromFriend(task));
421421
}
422422

423423
/// Spawns a new scheduler into this M:N pool. A handle is returned to the

src/libgreen/sched.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl Scheduler {
502502
let len = work_queues.len();
503503
let start_index = self.rng.gen_range(0, len);
504504
for index in range(0, len).map(|i| (i + start_index) % len) {
505-
match work_queues.get_mut(index).steal() {
505+
match work_queues[index].steal() {
506506
deque::Data(task) => {
507507
rtdebug!("found task by stealing");
508508
return Some(task)

src/librustc/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn symbol_hash(tcx: &ty::ctxt,
220220
}
221221

222222
fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> String {
223-
match ccx.type_hashcodes().borrow().find(&t) {
223+
match ccx.type_hashcodes().borrow().get(&t) {
224224
Some(h) => return h.to_string(),
225225
None => {}
226226
}

src/librustc/driver/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Session {
127127
msg: String) {
128128
let lint_id = lint::LintId::of(lint);
129129
let mut lints = self.lints.borrow_mut();
130-
match lints.find_mut(&id) {
130+
match lints.get_mut(&id) {
131131
Some(arr) => { arr.push((lint_id, sp, msg)); return; }
132132
None => {}
133133
}

src/librustc/lint/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
403403
libc::c_uint or libc::c_ulong should be used");
404404
}
405405
def::DefTy(..) => {
406-
let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().find(&ty_id) {
406+
let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty_id) {
407407
Some(&ty::atttce_resolved(t)) => t,
408408
_ => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
409409
};
@@ -994,7 +994,7 @@ impl LintPass for NonSnakeCase {
994994
fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
995995
match &p.node {
996996
&ast::PatIdent(_, ref path1, _) => {
997-
match cx.tcx.def_map.borrow().find(&p.id) {
997+
match cx.tcx.def_map.borrow().get(&p.id) {
998998
Some(&def::DefLocal(_)) => {
999999
self.check_snake_case(cx, "variable", path1.node, p.span);
10001000
}
@@ -1051,7 +1051,7 @@ impl LintPass for NonUpperCaseGlobals {
10511051

10521052
fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
10531053
// Lint for constants that look like binding identifiers (#7526)
1054-
match (&p.node, cx.tcx.def_map.borrow().find(&p.id)) {
1054+
match (&p.node, cx.tcx.def_map.borrow().get(&p.id)) {
10551055
(&ast::PatIdent(_, ref path1, _), Some(&def::DefConst(..))) => {
10561056
let s = token::get_ident(path1.node);
10571057
if s.get().chars().any(|c| c.is_lowercase()) {
@@ -1211,7 +1211,7 @@ impl LintPass for NonShorthandFieldPatterns {
12111211
ast::PatStruct(_, ref v, _) => {
12121212
for fieldpat in v.iter()
12131213
.filter(|fieldpat| !fieldpat.node.is_shorthand)
1214-
.filter(|fieldpat| def_map.find(&fieldpat.node.pat.id)
1214+
.filter(|fieldpat| def_map.get(&fieldpat.node.pat.id)
12151215
== Some(&def::DefLocal(fieldpat.node.pat.id))) {
12161216
match fieldpat.node.pat.node {
12171217
ast::PatIdent(_, ident, None) if ident.node.as_str()
@@ -1368,7 +1368,7 @@ impl LintPass for UnusedAllocation {
13681368
_ => return
13691369
}
13701370

1371-
match cx.tcx.adjustments.borrow().find(&e.id) {
1371+
match cx.tcx.adjustments.borrow().get(&e.id) {
13721372
Some(adjustment) => {
13731373
match *adjustment {
13741374
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
@@ -1637,15 +1637,15 @@ impl LintPass for Stability {
16371637

16381638
let id = match e.node {
16391639
ast::ExprPath(..) | ast::ExprStruct(..) => {
1640-
match cx.tcx.def_map.borrow().find(&e.id) {
1640+
match cx.tcx.def_map.borrow().get(&e.id) {
16411641
Some(&def) => def.def_id(),
16421642
None => return
16431643
}
16441644
}
16451645
ast::ExprMethodCall(i, _, _) => {
16461646
span = i.span;
16471647
let method_call = typeck::MethodCall::expr(e.id);
1648-
match cx.tcx.method_map.borrow().find(&method_call) {
1648+
match cx.tcx.method_map.borrow().get(&method_call) {
16491649
Some(method) => {
16501650
match method.origin {
16511651
typeck::MethodStatic(def_id) => {

src/librustc/lint/context.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ enum TargetLint {
8484

8585
impl LintStore {
8686
fn get_level_source(&self, lint: LintId) -> LevelSource {
87-
match self.levels.find(&lint) {
87+
match self.levels.get(&lint) {
8888
Some(&s) => s,
8989
None => (Allow, Default),
9090
}
@@ -124,7 +124,7 @@ impl LintStore {
124124
self.lints.push((*lint, from_plugin));
125125

126126
let id = LintId::of(*lint);
127-
if !self.by_name.insert(lint.name_lower(), Id(id)) {
127+
if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {
128128
let msg = format!("duplicate specification of lint {}", lint.name_lower());
129129
match (sess, from_plugin) {
130130
// We load builtin lints first, so a duplicate is a compiler bug.
@@ -147,7 +147,7 @@ impl LintStore {
147147
pub fn register_group(&mut self, sess: Option<&Session>,
148148
from_plugin: bool, name: &'static str,
149149
to: Vec<LintId>) {
150-
let new = self.lint_groups.insert(name, (to, from_plugin));
150+
let new = self.lint_groups.insert(name, (to, from_plugin)).is_none();
151151

152152
if !new {
153153
let msg = format!("duplicate specification of lint group {}", name);
@@ -437,11 +437,11 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
437437
/// Get the level of `lint` at the current position of the lint
438438
/// traversal.
439439
pub fn current_level(&self, lint: &'static Lint) -> Level {
440-
self.lints.levels.find(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
440+
self.lints.levels.get(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
441441
}
442442

443443
fn lookup_and_emit(&self, lint: &'static Lint, span: Option<Span>, msg: &str) {
444-
let (level, src) = match self.lints.levels.find(&LintId::of(lint)) {
444+
let (level, src) = match self.lints.levels.get(&LintId::of(lint)) {
445445
None => return,
446446
Some(&(Warn, src)) => {
447447
let lint_id = LintId::of(builtin::WARNINGS);
@@ -750,7 +750,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
750750
// Output any lints that were previously added to the session.
751751
impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
752752
fn visit_id(&mut self, id: ast::NodeId) {
753-
match self.tcx.sess.lints.borrow_mut().pop(&id) {
753+
match self.tcx.sess.lints.borrow_mut().remove(&id) {
754754
None => {}
755755
Some(lints) => {
756756
for (lint_id, span, msg) in lints.into_iter() {

src/librustc/metadata/cstore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl CStore {
213213

214214
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
215215
-> Option<ast::CrateNum> {
216-
self.extern_mod_crate_map.borrow().find(&emod_id).map(|x| *x)
216+
self.extern_mod_crate_map.borrow().get(&emod_id).map(|x| *x)
217217
}
218218
}
219219

src/librustc/metadata/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
12091209
return ast::DefId { krate: cdata.cnum, node: did.node };
12101210
}
12111211

1212-
match cdata.cnum_map.find(&did.krate) {
1212+
match cdata.cnum_map.get(&did.krate) {
12131213
Some(&n) => {
12141214
ast::DefId {
12151215
krate: n,
@@ -1321,7 +1321,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
13211321
let cnum = spec.split(':').nth(0).unwrap();
13221322
let link = spec.split(':').nth(1).unwrap();
13231323
let cnum = from_str(cnum).unwrap();
1324-
let cnum = match cdata.cnum_map.find(&cnum) {
1324+
let cnum = match cdata.cnum_map.get(&cnum) {
13251325
Some(&n) => n,
13261326
None => panic!("didn't find a crate in the cnum_map")
13271327
};

src/librustc/metadata/encoder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fn encode_symbol(ecx: &EncodeContext,
253253
rbml_w: &mut Encoder,
254254
id: NodeId) {
255255
rbml_w.start_tag(tag_items_data_item_symbol);
256-
match ecx.item_symbols.borrow().find(&id) {
256+
match ecx.item_symbols.borrow().get(&id) {
257257
Some(x) => {
258258
debug!("encode_symbol(id={}, str={})", id, *x);
259259
rbml_w.writer.write(x.as_bytes());
@@ -397,7 +397,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
397397
exp: &middle::resolve::Export2)
398398
-> bool {
399399
let impl_items = ecx.tcx.impl_items.borrow();
400-
match ecx.tcx.inherent_impls.borrow().find(&exp.def_id) {
400+
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
401401
Some(implementations) => {
402402
for base_impl_did in implementations.iter() {
403403
for &method_did in (*impl_items)[*base_impl_did].iter() {
@@ -426,7 +426,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
426426
rbml_w: &mut Encoder,
427427
exp: &middle::resolve::Export2)
428428
-> bool {
429-
match ecx.tcx.trait_items_cache.borrow().find(&exp.def_id) {
429+
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
430430
Some(trait_items) => {
431431
for trait_item in trait_items.iter() {
432432
match *trait_item {
@@ -531,7 +531,7 @@ fn encode_reexports(ecx: &EncodeContext,
531531
id: NodeId,
532532
path: PathElems) {
533533
debug!("(encoding info for module) encoding reexports for {}", id);
534-
match ecx.reexports2.find(&id) {
534+
match ecx.reexports2.get(&id) {
535535
Some(ref exports) => {
536536
debug!("(encoding info for module) found reexports for {}", id);
537537
for exp in exports.iter() {
@@ -978,7 +978,7 @@ fn should_inline(attrs: &[Attribute]) -> bool {
978978
fn encode_inherent_implementations(ecx: &EncodeContext,
979979
rbml_w: &mut Encoder,
980980
def_id: DefId) {
981-
match ecx.tcx.inherent_impls.borrow().find(&def_id) {
981+
match ecx.tcx.inherent_impls.borrow().get(&def_id) {
982982
None => {}
983983
Some(implementations) => {
984984
for &impl_def_id in implementations.iter() {
@@ -994,7 +994,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
994994
fn encode_extension_implementations(ecx: &EncodeContext,
995995
rbml_w: &mut Encoder,
996996
trait_def_id: DefId) {
997-
match ecx.tcx.trait_impls.borrow().find(&trait_def_id) {
997+
match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
998998
None => {}
999999
Some(implementations) => {
10001000
for &impl_def_id in implementations.borrow().iter() {
@@ -1987,7 +1987,7 @@ fn encode_crate_triple(rbml_w: &mut Encoder, triple: &str) {
19871987

19881988
fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
19891989
rbml_w.start_tag(tag_dylib_dependency_formats);
1990-
match ecx.tcx.dependency_formats.borrow().find(&config::CrateTypeDylib) {
1990+
match ecx.tcx.dependency_formats.borrow().get(&config::CrateTypeDylib) {
19911991
Some(arr) => {
19921992
let s = arr.iter().enumerate().filter_map(|(i, slot)| {
19931993
slot.map(|kind| (format!("{}:{}", i + 1, match kind {

src/librustc/metadata/tydecode.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -675,16 +675,16 @@ fn parse_builtin_bounds(st: &mut PState, _conv: conv_did) -> ty::BuiltinBounds {
675675
loop {
676676
match next(st) {
677677
'S' => {
678-
builtin_bounds.add(ty::BoundSend);
678+
builtin_bounds.insert(ty::BoundSend);
679679
}
680680
'Z' => {
681-
builtin_bounds.add(ty::BoundSized);
681+
builtin_bounds.insert(ty::BoundSized);
682682
}
683683
'P' => {
684-
builtin_bounds.add(ty::BoundCopy);
684+
builtin_bounds.insert(ty::BoundCopy);
685685
}
686686
'T' => {
687-
builtin_bounds.add(ty::BoundSync);
687+
builtin_bounds.insert(ty::BoundSync);
688688
}
689689
'.' => {
690690
return builtin_bounds;

src/librustc/metadata/tyencode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct ty_abbrev {
5050
pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>;
5151

5252
pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: ty::t) {
53-
match cx.abbrevs.borrow_mut().find(&t) {
53+
match cx.abbrevs.borrow_mut().get(&t) {
5454
Some(a) => { w.write(a.s.as_bytes()); return; }
5555
None => {}
5656
}

src/librustc/middle/astencode.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,14 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
11511151

11521152
debug!("Encoding side tables for id {}", id);
11531153

1154-
for def in tcx.def_map.borrow().find(&id).iter() {
1154+
for def in tcx.def_map.borrow().get(&id).iter() {
11551155
rbml_w.tag(c::tag_table_def, |rbml_w| {
11561156
rbml_w.id(id);
11571157
rbml_w.tag(c::tag_table_val, |rbml_w| (*def).encode(rbml_w).unwrap());
11581158
})
11591159
}
11601160

1161-
for &ty in tcx.node_types.borrow().find(&(id as uint)).iter() {
1161+
for &ty in tcx.node_types.borrow().get(&(id as uint)).iter() {
11621162
rbml_w.tag(c::tag_table_node_type, |rbml_w| {
11631163
rbml_w.id(id);
11641164
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1167,7 +1167,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
11671167
})
11681168
}
11691169

1170-
for &item_substs in tcx.item_substs.borrow().find(&id).iter() {
1170+
for &item_substs in tcx.item_substs.borrow().get(&id).iter() {
11711171
rbml_w.tag(c::tag_table_item_subst, |rbml_w| {
11721172
rbml_w.id(id);
11731173
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1176,7 +1176,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
11761176
})
11771177
}
11781178

1179-
for &fv in tcx.freevars.borrow().find(&id).iter() {
1179+
for &fv in tcx.freevars.borrow().get(&id).iter() {
11801180
rbml_w.tag(c::tag_table_freevars, |rbml_w| {
11811181
rbml_w.id(id);
11821182
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1209,7 +1209,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12091209
}
12101210
}
12111211

1212-
for &cm in tcx.capture_modes.borrow().find(&id).iter() {
1212+
for &cm in tcx.capture_modes.borrow().get(&id).iter() {
12131213
rbml_w.tag(c::tag_table_capture_modes, |rbml_w| {
12141214
rbml_w.id(id);
12151215
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1219,7 +1219,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12191219
}
12201220

12211221
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
1222-
for &pty in tcx.tcache.borrow().find(&lid).iter() {
1222+
for &pty in tcx.tcache.borrow().get(&lid).iter() {
12231223
rbml_w.tag(c::tag_table_tcache, |rbml_w| {
12241224
rbml_w.id(id);
12251225
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1228,7 +1228,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12281228
})
12291229
}
12301230

1231-
for &type_param_def in tcx.ty_param_defs.borrow().find(&id).iter() {
1231+
for &type_param_def in tcx.ty_param_defs.borrow().get(&id).iter() {
12321232
rbml_w.tag(c::tag_table_param_defs, |rbml_w| {
12331233
rbml_w.id(id);
12341234
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1238,7 +1238,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12381238
}
12391239

12401240
let method_call = MethodCall::expr(id);
1241-
for &method in tcx.method_map.borrow().find(&method_call).iter() {
1241+
for &method in tcx.method_map.borrow().get(&method_call).iter() {
12421242
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
12431243
rbml_w.id(id);
12441244
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1247,7 +1247,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12471247
})
12481248
}
12491249

1250-
for &trait_ref in tcx.object_cast_map.borrow().find(&id).iter() {
1250+
for &trait_ref in tcx.object_cast_map.borrow().get(&id).iter() {
12511251
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
12521252
rbml_w.id(id);
12531253
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1256,11 +1256,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12561256
})
12571257
}
12581258

1259-
for &adjustment in tcx.adjustments.borrow().find(&id).iter() {
1259+
for &adjustment in tcx.adjustments.borrow().get(&id).iter() {
12601260
match *adjustment {
12611261
_ if ty::adjust_is_object(adjustment) => {
12621262
let method_call = MethodCall::autoobject(id);
1263-
for &method in tcx.method_map.borrow().find(&method_call).iter() {
1263+
for &method in tcx.method_map.borrow().get(&method_call).iter() {
12641264
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
12651265
rbml_w.id(id);
12661266
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1273,7 +1273,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12731273
assert!(!ty::adjust_is_object(adjustment));
12741274
for autoderef in range(0, adj.autoderefs) {
12751275
let method_call = MethodCall::autoderef(id, autoderef);
1276-
for &method in tcx.method_map.borrow().find(&method_call).iter() {
1276+
for &method in tcx.method_map.borrow().get(&method_call).iter() {
12771277
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
12781278
rbml_w.id(id);
12791279
rbml_w.tag(c::tag_table_val, |rbml_w| {
@@ -1299,7 +1299,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12991299

13001300
for unboxed_closure in tcx.unboxed_closures
13011301
.borrow()
1302-
.find(&ast_util::local_def(id))
1302+
.get(&ast_util::local_def(id))
13031303
.iter() {
13041304
rbml_w.tag(c::tag_table_unboxed_closures, |rbml_w| {
13051305
rbml_w.id(id);

src/librustc/middle/borrowck/move_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl MoveData {
242242
* base paths that do not yet have an index.
243243
*/
244244

245-
match self.path_map.borrow().find(&lp) {
245+
match self.path_map.borrow().get(&lp) {
246246
Some(&index) => {
247247
return index;
248248
}
@@ -577,7 +577,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
577577
//! Returns the kind of a move of `loan_path` by `id`, if one exists.
578578
579579
let mut ret = None;
580-
for loan_path_index in self.move_data.path_map.borrow().find(&*loan_path).iter() {
580+
for loan_path_index in self.move_data.path_map.borrow().get(&*loan_path).iter() {
581581
self.dfcx_moves.each_gen_bit(id, |move_index| {
582582
let the_move = self.move_data.moves.borrow();
583583
let the_move = (*the_move)[move_index];

0 commit comments

Comments
 (0)