Skip to content

Commit

Permalink
Auto merge of #32264 - GuillaumeGomez:lang_item, r=nikomatsakis
Browse files Browse the repository at this point in the history
Lang item

Fixes #32033
  • Loading branch information
bors committed Mar 22, 2016
2 parents 8fc0554 + b2fd882 commit 2ae05d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/librustc/diagnostics.rs
Expand Up @@ -1962,6 +1962,23 @@ each method; it is not possible to annotate the entire impl with an `#[inline]`
attribute.
"##,

E0522: r##"
The lang attribute is intended for marking special items that are built-in to
Rust itself. This includes special traits (like `Copy` and `Sized`) that affect
how the compiler behaves, as well as special functions that may be automatically
invoked (such as the handler for out-of-bounds accesses when indexing a slice).
Erroneous code example:
```compile_fail
#![feature(lang_items)]
#[lang = "cookie"]
fn cookie() -> ! { // error: definition of an unknown language item: `cookie`
loop {}
}
```
"##,

}


Expand Down
5 changes: 5 additions & 0 deletions src/librustc/middle/lang_items.rs
Expand Up @@ -158,6 +158,11 @@ impl<'a, 'v, 'tcx> Visitor<'v> for LanguageItemCollector<'a, 'tcx> {

if let Some(item_index) = item_index {
self.collect_item(item_index, self.ast_map.local_def_id(item.id))
} else {
let span = self.ast_map.span(item.id);
span_err!(self.session, span, E0522,
"definition of an unknown language item: `{}`.",
&value[..]);
}
}
}
Expand Down

0 comments on commit 2ae05d3

Please sign in to comment.