From 9e441c76f76521466f2f83c90d5f2811a1e9a714 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 1 Oct 2017 17:05:35 +0200 Subject: [PATCH] =?UTF-8?q?Add=20a=20lang=20item=20to=20allow=20`impl=20[u?= =?UTF-8?q?8]=20{=E2=80=A6}`=20in=20the=20standard=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librustc/middle/lang_items.rs | 1 + src/librustc_typeck/check/method/probe.rs | 3 +++ src/librustc_typeck/coherence/inherent_impls.rs | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 679c4f17a6c0..a38b37ff745f 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 a24f420af80d..81e5b2fe00a6 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 c56a3b91ca37..569b6a2febb4 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(),