Skip to content

Commit b7d3424

Browse files
committed
Accept #[lang(foo)] attributes, refs rust-lang#11886
1 parent f9681d4 commit b7d3424

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/librustc/middle/lang_items.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct LanguageItemVisitor<'a> {
114114

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

@@ -183,14 +183,26 @@ impl LanguageItemCollector {
183183
}
184184
}
185185

186-
pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
186+
pub fn extract(_: Session, attrs: &[ast::Attribute]) -> Option<InternedString> {
187187
for attribute in attrs.iter() {
188188
match attribute.name_str_pair() {
189189
Some((ref key, ref value)) if key.equiv(&("lang")) => {
190+
// Raise error after snapshot landed
191+
//session.err(format!("`lang = {}` was replaced by `lang({})`",
192+
// *value, *value));
190193
return Some((*value).clone());
191194
}
192195
Some(..) | None => {}
193196
}
197+
198+
if attribute.name().equiv(&("lang")) {
199+
match attribute.meta_item_list() {
200+
Some(ref l) if l.len() == 1 => {
201+
return Some(l[0].name().clone());
202+
}
203+
_ => {}
204+
}
205+
}
194206
}
195207

196208
return None;

0 commit comments

Comments
 (0)