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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 4 additions & 4 deletions
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;

0 commit comments

Comments
 (0)