Skip to content

Commit 53e0357

Browse files
Link to bool primitive type if "true" or "false" is used
1 parent 3a92b99 commit 53e0357

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

src/librustdoc/clean/types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,11 @@ impl Attributes {
629629
Some((
630630
s.clone(),
631631
format!(
632-
"{}{}std/primitive.{}.html{}",
632+
"{}{}std/{}{}.html{}",
633633
url,
634634
if !url.ends_with('/') { "/" } else { "" },
635+
// This is needed in case we are generating for keywords.
636+
if fragment[..tail].contains(".") { "" } else { "primitive." },
635637
&fragment[..tail],
636638
&fragment[tail..]
637639
),

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -747,30 +747,39 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
747747
};
748748

749749
if candidates.is_empty() {
750-
resolution_failure(cx, &item, path_str, &dox, link_range);
751-
// this could just be a normal link
752-
continue;
753-
}
754-
755-
let len = candidates.clone().present_items().count();
756-
757-
if len == 1 {
758-
candidates.present_items().next().unwrap()
759-
} else if len == 2 && is_derive_trait_collision(&candidates) {
760-
candidates.type_ns.unwrap()
750+
if path_str == "true" || path_str == "false" {
751+
item.attrs.links.push((
752+
ori_link,
753+
None,
754+
Some(format!("keyword.{}", path_str,)),
755+
));
756+
continue;
757+
} else {
758+
resolution_failure(cx, &item, path_str, &dox, link_range);
759+
// this could just be a normal link
760+
continue;
761+
}
761762
} else {
762-
if is_derive_trait_collision(&candidates) {
763-
candidates.macro_ns = None;
763+
let len = candidates.clone().present_items().count();
764+
765+
if len == 1 {
766+
candidates.present_items().next().unwrap()
767+
} else if len == 2 && is_derive_trait_collision(&candidates) {
768+
candidates.type_ns.unwrap()
769+
} else {
770+
if is_derive_trait_collision(&candidates) {
771+
candidates.macro_ns = None;
772+
}
773+
ambiguity_error(
774+
cx,
775+
&item,
776+
path_str,
777+
&dox,
778+
link_range,
779+
candidates.map(|candidate| candidate.map(|(res, _)| res)),
780+
);
781+
continue;
764782
}
765-
ambiguity_error(
766-
cx,
767-
&item,
768-
path_str,
769-
&dox,
770-
link_range,
771-
candidates.map(|candidate| candidate.map(|(res, _)| res)),
772-
);
773-
continue;
774783
}
775784
}
776785
Some(MacroNS) => {

0 commit comments

Comments
 (0)