Skip to content

Commit 9e441c7

Browse files
SimonSapinLukasKalbertodt
authored andcommitted
Add a lang item to allow impl [u8] {…} in the standard library
1 parent 8a4fa74 commit 9e441c7

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ language_item_table! {
211211
CharImplItem, "char", char_impl;
212212
StrImplItem, "str", str_impl;
213213
SliceImplItem, "slice", slice_impl;
214+
SliceU8ImplItem, "slice_u8", slice_u8_impl;
214215
ConstPtrImplItem, "const_ptr", const_ptr_impl;
215216
MutPtrImplItem, "mut_ptr", mut_ptr_impl;
216217
I8ImplItem, "i8", i8_impl;

src/librustc_typeck/check/method/probe.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
431431
ty::TySlice(_) => {
432432
let lang_def_id = lang_items.slice_impl();
433433
self.assemble_inherent_impl_for_primitive(lang_def_id);
434+
435+
let lang_def_id = lang_items.slice_u8_impl();
436+
self.assemble_inherent_impl_for_primitive(lang_def_id);
434437
}
435438
ty::TyRawPtr(ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => {
436439
let lang_def_id = lang_items.const_ptr_impl();

src/librustc_typeck/coherence/inherent_impls.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
137137
"str",
138138
item.span);
139139
}
140+
ty::TySlice(slice_item) if slice_item == self.tcx.types.u8 => {
141+
self.check_primitive_impl(def_id,
142+
lang_items.slice_u8_impl(),
143+
"slice_u8",
144+
"[u8]",
145+
item.span);
146+
}
140147
ty::TySlice(_) => {
141148
self.check_primitive_impl(def_id,
142149
lang_items.slice_impl(),

0 commit comments

Comments
 (0)