Skip to content

Commit

Permalink
Accept #[lang(foo)] attributes, refs rust-lang#11886
Browse files Browse the repository at this point in the history
  • Loading branch information
fhahn committed Feb 22, 2014
1 parent f9681d4 commit b7d3424
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct LanguageItemVisitor<'a> {

impl<'a> Visitor<()> for LanguageItemVisitor<'a> {
fn visit_item(&mut self, item: &ast::Item, _: ()) {
match extract(item.attrs) {
match extract(self.this.session, item.attrs) {
Some(value) => {
let item_index = self.this.item_refs.find_equiv(&value).map(|x| *x);

Expand Down Expand Up @@ -183,14 +183,26 @@ impl LanguageItemCollector {
}
}

pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
pub fn extract(_: Session, attrs: &[ast::Attribute]) -> Option<InternedString> {
for attribute in attrs.iter() {
match attribute.name_str_pair() {
Some((ref key, ref value)) if key.equiv(&("lang")) => {
// Raise error after snapshot landed
//session.err(format!("`lang = {}` was replaced by `lang({})`",
// *value, *value));
return Some((*value).clone());
}
Some(..) | None => {}
}

if attribute.name().equiv(&("lang")) {
match attribute.meta_item_list() {
Some(ref l) if l.len() == 1 => {
return Some(l[0].name().clone());
}
_ => {}
}
}
}

return None;
Expand Down

0 comments on commit b7d3424

Please sign in to comment.