Add "bool" lang item

This commit is contained in:
varkor 2019-09-07 13:16:18 +01:00
parent 4894123d21
commit f0386a10e0
8 changed files with 24 additions and 1 deletions

7
src/libcore/bool/mod.rs Normal file
View file

@ -0,0 +1,7 @@
//! impl bool {}
#![stable(feature = "core_bool", since = "1.39.0")]
#[cfg(not(boostrap_stdarch_ignore_this))]
#[lang = "bool"]
impl bool {}

View file

@ -198,6 +198,7 @@ pub mod borrow;
pub mod any;
pub mod array;
pub mod ascii;
pub mod bool;
pub mod sync;
pub mod cell;
pub mod char;

View file

@ -246,6 +246,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems {
language_item_table! {
// Variant name, Name, Method name, Target;
BoolImplItem, "bool", bool_impl, Target::Impl;
CharImplItem, "char", char_impl, Target::Impl;
StrImplItem, "str", str_impl, Target::Impl;
SliceImplItem, "slice", slice_impl, Target::Impl;

View file

@ -578,6 +578,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
ty::Param(p) => {
self.assemble_inherent_candidates_from_param(p);
}
ty::Bool => {
let lang_def_id = lang_items.bool_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);
}
ty::Char => {
let lang_def_id = lang_items.char_impl();
self.assemble_inherent_impl_for_primitive(lang_def_id);

View file

@ -67,6 +67,14 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
ty::Dynamic(ref data, ..) if data.principal_def_id().is_some() => {
self.check_def_id(item, data.principal_def_id().unwrap());
}
ty::Bool => {
self.check_primitive_impl(def_id,
lang_items.bool_impl(),
None,
"bool",
"bool",
item.span);
}
ty::Char => {
self.check_primitive_impl(def_id,
lang_items.char_impl(),

View file

@ -3977,7 +3977,7 @@ fn build_deref_target_impls(cx: &DocContext<'_>,
F32 => tcx.lang_items().f32_impl(),
F64 => tcx.lang_items().f64_impl(),
Char => tcx.lang_items().char_impl(),
Bool => None,
Bool => tcx.lang_items().bool_impl(),
Str => tcx.lang_items().str_impl(),
Slice => tcx.lang_items().slice_impl(),
Array => tcx.lang_items().slice_impl(),

View file

@ -679,6 +679,7 @@ fn primitive_impl(cx: &DocContext<'_>, path_str: &str) -> Option<DefId> {
"f32" => tcx.lang_items().f32_impl(),
"f64" => tcx.lang_items().f64_impl(),
"str" => tcx.lang_items().str_impl(),
"bool" => tcx.lang_items().bool_impl(),
"char" => tcx.lang_items().char_impl(),
_ => None,
}

View file

@ -53,6 +53,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
lang_items.f64_impl(),
lang_items.f32_runtime_impl(),
lang_items.f64_runtime_impl(),
lang_items.bool_impl(),
lang_items.char_impl(),
lang_items.str_impl(),
lang_items.slice_impl(),