// Language items are items that represent concepts intrinsic to the language
// itself. Examples are:
//
-// * Traits that specify "kinds"; e.g. "Share", "Send".
+// * Traits that specify "kinds"; e.g. "Sync", "Send".
//
// * Traits that represent operators; e.g. "Add", "Sub", "Index".
//
}
}
+ pub fn from_builtin_kind(&self, bound: ty::BuiltinBound)
+ -> Result<ast::DefId, String>
+ {
+ match bound {
+ ty::BoundSend => self.require(SendTraitLangItem),
+ ty::BoundSized => self.require(SizedTraitLangItem),
+ ty::BoundCopy => self.require(CopyTraitLangItem),
+ ty::BoundSync => self.require(SyncTraitLangItem),
+ }
+ }
+
pub fn to_builtin_kind(&self, id: ast::DefId) -> Option<ty::BuiltinBound> {
if Some(id) == self.send_trait() {
Some(ty::BoundSend)
Some(ty::BoundSized)
} else if Some(id) == self.copy_trait() {
Some(ty::BoundCopy)
- } else if Some(id) == self.share_trait() {
- Some(ty::BoundShare)
+ } else if Some(id) == self.sync_trait() {
+ Some(ty::BoundSync)
} else {
None
}
item_refs: HashMap<&'static str, uint>,
}
-impl<'a> Visitor<()> for LanguageItemCollector<'a> {
- fn visit_item(&mut self, item: &ast::Item, _: ()) {
+impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
+ fn visit_item(&mut self, item: &ast::Item) {
match extract(item.attrs.as_slice()) {
Some(value) => {
let item_index = self.item_refs.find_equiv(&value).map(|x| *x);
None => {}
}
- visit::walk_item(self, item, ());
+ visit::walk_item(self, item);
}
}
}
pub fn collect_local_language_items(&mut self, krate: &ast::Crate) {
- visit::walk_crate(self, krate, ());
+ visit::walk_crate(self, krate);
}
pub fn collect_external_language_items(&mut self) {
SendTraitLangItem, "send", send_trait;
SizedTraitLangItem, "sized", sized_trait;
CopyTraitLangItem, "copy", copy_trait;
- ShareTraitLangItem, "share", share_trait;
+ SyncTraitLangItem, "sync", sync_trait;
DropTraitLangItem, "drop", drop_trait;
ShrTraitLangItem, "shr", shr_trait;
IndexTraitLangItem, "index", index_trait;
IndexMutTraitLangItem, "index_mut", index_mut_trait;
+ SliceTraitLangItem, "slice", slice_trait;
+ SliceMutTraitLangItem, "slice_mut", slice_mut_trait;
UnsafeTypeLangItem, "unsafe", unsafe_type;
BeginUnwindLangItem, "begin_unwind", begin_unwind;
ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn;
- ClosureExchangeMallocFnLangItem, "closure_exchange_malloc", closure_exchange_malloc_fn;
ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn;
MallocFnLangItem, "malloc", malloc_fn;
FreeFnLangItem, "free", free_fn;
NoSendItem, "no_send_bound", no_send_bound;
NoCopyItem, "no_copy_bound", no_copy_bound;
- NoShareItem, "no_share_bound", no_share_bound;
+ NoSyncItem, "no_sync_bound", no_sync_bound;
ManagedItem, "managed_bound", managed_bound;
IteratorItem, "iterator", iterator;