about summary refs log tree commit diff
diff options
context:
space:
mode:
authorggomez <guillaume1.gomez@gmail.com>2016-03-15 15:54:27 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-03-14 22:29:57 +0100
commitb2fd882972ff78a65356f489990c832dcefc9b58 (patch)
treed052274f717e3f8ff725c095fb4fdea68713c03b
parenta2e4ab2ab276bbfbcd165b106da4159f68aff6e3 (diff)
downloadrust-b2fd882972ff78a65356f489990c832dcefc9b58.tar.gz
rust-b2fd882972ff78a65356f489990c832dcefc9b58.zip
Add E0522 long error explanation
-rw-r--r--src/librustc/diagnostics.rs18
-rw-r--r--src/librustc/middle/lang_items.rs5
2 files changed, 19 insertions, 4 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 004495bb916..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 {}
+}
+```
+"##,
+
 }
 
 
@@ -2007,5 +2024,4 @@ register_diagnostics! {
     E0490, // a value of type `..` is borrowed for too long
     E0491, // in type `..`, reference has a longer lifetime than the data it...
     E0495, // cannot infer an appropriate lifetime due to conflicting requirements
-    E0522, // creating new item lang is forbidden
 }
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index b16ba9a2190..b08c2d6054c 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -159,10 +159,9 @@ 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 item_def_id = self.ast_map.local_def_id(item.id);
-                let span = self.ast_map.span_if_local(item_def_id).unwrap();
+                let span = self.ast_map.span(item.id);
                 span_err!(self.session, span, E0522,
-                          "creating new item lang is forbidden: `{}`.",
+                          "definition of an unknown language item: `{}`.",
                           &value[..]);
             }
         }