Skip to content

Commit b2fd882

Browse files
Add E0522 long error explanation
1 parent a2e4ab2 commit b2fd882

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/librustc/diagnostics.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,23 @@ each method; it is not possible to annotate the entire impl with an `#[inline]`
19621962
attribute.
19631963
"##,
19641964

1965+
E0522: r##"
1966+
The lang attribute is intended for marking special items that are built-in to
1967+
Rust itself. This includes special traits (like `Copy` and `Sized`) that affect
1968+
how the compiler behaves, as well as special functions that may be automatically
1969+
invoked (such as the handler for out-of-bounds accesses when indexing a slice).
1970+
Erroneous code example:
1971+
1972+
```compile_fail
1973+
#![feature(lang_items)]
1974+
1975+
#[lang = "cookie"]
1976+
fn cookie() -> ! { // error: definition of an unknown language item: `cookie`
1977+
loop {}
1978+
}
1979+
```
1980+
"##,
1981+
19651982
}
19661983

19671984

@@ -2007,5 +2024,4 @@ register_diagnostics! {
20072024
E0490, // a value of type `..` is borrowed for too long
20082025
E0491, // in type `..`, reference has a longer lifetime than the data it...
20092026
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
2010-
E0522, // creating new item lang is forbidden
20112027
}

src/librustc/middle/lang_items.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ impl<'a, 'v, 'tcx> Visitor<'v> for LanguageItemCollector<'a, 'tcx> {
159159
if let Some(item_index) = item_index {
160160
self.collect_item(item_index, self.ast_map.local_def_id(item.id))
161161
} else {
162-
let item_def_id = self.ast_map.local_def_id(item.id);
163-
let span = self.ast_map.span_if_local(item_def_id).unwrap();
162+
let span = self.ast_map.span(item.id);
164163
span_err!(self.session, span, E0522,
165-
"creating new item lang is forbidden: `{}`.",
164+
"definition of an unknown language item: `{}`.",
166165
&value[..]);
167166
}
168167
}

0 commit comments

Comments
 (0)