Forbid creation of lang item from user code
This commit is contained in:
parent
4db8b5bfdf
commit
a2e4ab2ab2
@ -2007,4 +2007,5 @@ 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
|
||||
}
|
||||
|
@ -158,6 +158,12 @@ 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();
|
||||
span_err!(self.session, span, E0522,
|
||||
"creating new item lang is forbidden: `{}`.",
|
||||
&value[..]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user