Skip to content

Commit

Permalink
rustc: Convert lang_item to use an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
blake2-ppc committed Sep 30, 2013
1 parent 8e69c05 commit abcca1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -1574,7 +1574,7 @@ fn encode_crate_deps(ecx: &EncodeContext,
fn encode_lang_items(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
ebml_w.start_tag(tag_lang_items);

do ecx.tcx.lang_items.each_item |def_id, i| {
for (i, def_id) in ecx.tcx.lang_items.items() {
for id in def_id.iter() {
if id.crate == LOCAL_CRATE {
ebml_w.start_tag(tag_lang_items_item);
Expand All @@ -1590,8 +1590,7 @@ fn encode_lang_items(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
ebml_w.end_tag(); // tag_lang_items_item
}
}
true
};
}

ebml_w.end_tag(); // tag_lang_items
}
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/middle/lang_items.rs
Expand Up @@ -32,6 +32,8 @@ use syntax::visit;
use syntax::visit::Visitor;

use std::hashmap::HashMap;
use std::iter::Enumerate;
use std::vec;

pub enum LangItem {
FreezeTraitLangItem, // 0
Expand Down Expand Up @@ -92,8 +94,8 @@ impl LanguageItems {
}
}

pub fn each_item(&self, f: &fn(Option<DefId>, uint) -> bool) -> bool {
self.items.iter().enumerate().advance(|(i, &item)| f(item, i))
pub fn items<'a>(&'a self) -> Enumerate<vec::VecIterator<'a, Option<DefId>>> {
self.items.iter().enumerate()
}

pub fn item_name(index: uint) -> &'static str {
Expand Down

9 comments on commit abcca1c

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging blake2-ppc/rust/lang-item-iter = abcca1c7 into auto

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blake2-ppc/rust/lang-item-iter = abcca1c7 merged ok, testing candidate = d7b4033d

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging blake2-ppc/rust/lang-item-iter = abcca1c7 into auto

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blake2-ppc/rust/lang-item-iter = abcca1c7 merged ok, testing candidate = ca2d596

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

@bors
Copy link
Contributor

@bors bors commented on abcca1c Sep 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = ca2d596

Please sign in to comment.