Skip to content

Commit f0386a1

Browse files
committed
Add "bool" lang item
1 parent 4894123 commit f0386a1

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

src/libcore/bool/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! impl bool {}
2+
3+
#![stable(feature = "core_bool", since = "1.39.0")]
4+
5+
#[cfg(not(boostrap_stdarch_ignore_this))]
6+
#[lang = "bool"]
7+
impl bool {}

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ pub mod borrow;
198198
pub mod any;
199199
pub mod array;
200200
pub mod ascii;
201+
pub mod bool;
201202
pub mod sync;
202203
pub mod cell;
203204
pub mod char;

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems {
246246

247247
language_item_table! {
248248
// Variant name, Name, Method name, Target;
249+
BoolImplItem, "bool", bool_impl, Target::Impl;
249250
CharImplItem, "char", char_impl, Target::Impl;
250251
StrImplItem, "str", str_impl, Target::Impl;
251252
SliceImplItem, "slice", slice_impl, Target::Impl;

src/librustc_typeck/check/method/probe.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
578578
ty::Param(p) => {
579579
self.assemble_inherent_candidates_from_param(p);
580580
}
581+
ty::Bool => {
582+
let lang_def_id = lang_items.bool_impl();
583+
self.assemble_inherent_impl_for_primitive(lang_def_id);
584+
}
581585
ty::Char => {
582586
let lang_def_id = lang_items.char_impl();
583587
self.assemble_inherent_impl_for_primitive(lang_def_id);

src/librustc_typeck/coherence/inherent_impls.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
6767
ty::Dynamic(ref data, ..) if data.principal_def_id().is_some() => {
6868
self.check_def_id(item, data.principal_def_id().unwrap());
6969
}
70+
ty::Bool => {
71+
self.check_primitive_impl(def_id,
72+
lang_items.bool_impl(),
73+
None,
74+
"bool",
75+
"bool",
76+
item.span);
77+
}
7078
ty::Char => {
7179
self.check_primitive_impl(def_id,
7280
lang_items.char_impl(),

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3977,7 +3977,7 @@ fn build_deref_target_impls(cx: &DocContext<'_>,
39773977
F32 => tcx.lang_items().f32_impl(),
39783978
F64 => tcx.lang_items().f64_impl(),
39793979
Char => tcx.lang_items().char_impl(),
3980-
Bool => None,
3980+
Bool => tcx.lang_items().bool_impl(),
39813981
Str => tcx.lang_items().str_impl(),
39823982
Slice => tcx.lang_items().slice_impl(),
39833983
Array => tcx.lang_items().slice_impl(),

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ fn primitive_impl(cx: &DocContext<'_>, path_str: &str) -> Option<DefId> {
679679
"f32" => tcx.lang_items().f32_impl(),
680680
"f64" => tcx.lang_items().f64_impl(),
681681
"str" => tcx.lang_items().str_impl(),
682+
"bool" => tcx.lang_items().bool_impl(),
682683
"char" => tcx.lang_items().char_impl(),
683684
_ => None,
684685
}

src/librustdoc/passes/collect_trait_impls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
5353
lang_items.f64_impl(),
5454
lang_items.f32_runtime_impl(),
5555
lang_items.f64_runtime_impl(),
56+
lang_items.bool_impl(),
5657
lang_items.char_impl(),
5758
lang_items.str_impl(),
5859
lang_items.slice_impl(),

0 commit comments

Comments
 (0)