diff options
| author | bors <bors@rust-lang.org> | 2016-03-22 04:06:59 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-22 04:06:59 -0700 |
| commit | 2ae05d37dac364cfcbb3cf3a2490ea8b7116f04c (patch) | |
| tree | bcf7d9f5d5012d49d67e94e8be48fe2a7f02eba0 | |
| parent | 8fc0554e4df413537760850108b10aafcdccd4b0 (diff) | |
| parent | b2fd882972ff78a65356f489990c832dcefc9b58 (diff) | |
| download | rust-2ae05d37dac364cfcbb3cf3a2490ea8b7116f04c.tar.gz rust-2ae05d37dac364cfcbb3cf3a2490ea8b7116f04c.zip | |
Auto merge of #32264 - GuillaumeGomez:lang_item, r=nikomatsakis
Lang item Fixes #32033
| -rw-r--r-- | src/librustc/diagnostics.rs | 17 | ||||
| -rw-r--r-- | src/librustc/middle/lang_items.rs | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 92db527ef98..f474f7d4585 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -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 {} +} +``` +"##, + } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index c432095ff06..b08c2d6054c 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -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[..]); } } } |
