Add a lang item to allow impl [u8] {…} in the standard library

This commit is contained in:
Simon Sapin 2017-10-01 17:05:35 +02:00 committed by Lukas Kalbertodt
parent 8a4fa742a1
commit 9e441c76f7
3 changed files with 11 additions and 0 deletions

View file

@ -211,6 +211,7 @@ language_item_table! {
CharImplItem, "char", char_impl;
StrImplItem, "str", str_impl;
SliceImplItem, "slice", slice_impl;
SliceU8ImplItem, "slice_u8", slice_u8_impl;
ConstPtrImplItem, "const_ptr", const_ptr_impl;
MutPtrImplItem, "mut_ptr", mut_ptr_impl;
I8ImplItem, "i8", i8_impl;

View file

@ -431,6 +431,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
ty::TySlice(_) => {
let lang_def_id = lang_items.slice_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
let lang_def_id = lang_items.slice_u8_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => {
let lang_def_id = lang_items.const_ptr_impl();

View file

@ -137,6 +137,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
"str",
item.span);
}
ty::TySlice(slice_item) if slice_item == self.tcx.types.u8 => {
self.check_primitive_impl(def_id,
lang_items.slice_u8_impl(),
"slice_u8",
"[u8]",
item.span);
}
ty::TySlice(_) => {
self.check_primitive_impl(def_id,
lang_items.slice_impl(),