summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-10-01 17:05:35 +0200
committerLukas Kalbertodt <lukas.kalbertodt@gmail.com>2017-11-03 21:27:40 +0100
commit9e441c76f76521466f2f83c90d5f2811a1e9a714 (patch)
treec17d17eed1c7197e9d94533b12eedd08a873050c
parent8a4fa742a193f2c6061d7d4ab11d68c76da30286 (diff)
downloadrust-9e441c76f76521466f2f83c90d5f2811a1e9a714.tar.gz
Add a lang item to allow `impl [u8] {…}` in the standard library
-rw-r--r--src/librustc/middle/lang_items.rs1
-rw-r--r--src/librustc_typeck/check/method/probe.rs3
-rw-r--r--src/librustc_typeck/coherence/inherent_impls.rs7
3 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index 679c4f17a6c..a38b37ff745 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -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;
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index a24f420af80..81e5b2fe00a 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -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();
diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs
index c56a3b91ca3..569b6a2febb 100644
--- a/src/librustc_typeck/coherence/inherent_impls.rs
+++ b/src/librustc_typeck/coherence/inherent_impls.rs
@@ -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(),