]> git.lizzy.rs Git - rust.git/commitdiff
Add E0522 long error explanation
authorggomez <guillaume1.gomez@gmail.com>
Tue, 15 Mar 2016 14:54:27 +0000 (15:54 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 14 Mar 2016 21:29:57 +0000 (22:29 +0100)
src/librustc/diagnostics.rs
src/librustc/middle/lang_items.rs

index 004495bb91699127030111267f0041f575a1c562..f474f7d4585f9fcdcd8bced82bf6604af98a6675 100644 (file)
@@ -1962,6 +1962,23 @@ impl Foo {
 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 @@ impl Foo {
     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
 }
index b16ba9a2190245528f12dc794f0199aa1f965ec8..b08c2d6054c89cb1d4f7ed5a856a78b63dab5d19 100644 (file)
@@ -159,10 +159,9 @@ fn visit_item(&mut self, item: &hir::Item) {
             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[..]);
             }
         }