Skip to content

Commit

Permalink
Rollup merge of #123581 - tgross35:f16-f128-rustdoc-updates, r=fmease
Browse files Browse the repository at this point in the history
Add `f16` and `f128` to rustdoc's `PrimitiveType`

Fix a few places where these primitives were missing from librustdoc. This should fix the CI failures from doc links in #122470.
  • Loading branch information
matthiaskrgr authored Apr 7, 2024
2 parents bbc7807 + ebc86e6 commit 549d85d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,8 +1797,10 @@ impl PrimitiveType {
sym::bool => Some(PrimitiveType::Bool),
sym::char => Some(PrimitiveType::Char),
sym::str => Some(PrimitiveType::Str),
sym::f16 => Some(PrimitiveType::F16),
sym::f32 => Some(PrimitiveType::F32),
sym::f64 => Some(PrimitiveType::F64),
sym::f128 => Some(PrimitiveType::F128),
sym::array => Some(PrimitiveType::Array),
sym::slice => Some(PrimitiveType::Slice),
sym::tuple => Some(PrimitiveType::Tuple),
Expand Down Expand Up @@ -1831,8 +1833,10 @@ impl PrimitiveType {
U32 => single(SimplifiedType::Uint(UintTy::U32)),
U64 => single(SimplifiedType::Uint(UintTy::U64)),
U128 => single(SimplifiedType::Uint(UintTy::U128)),
F16 => single(SimplifiedType::Float(FloatTy::F16)),
F32 => single(SimplifiedType::Float(FloatTy::F32)),
F64 => single(SimplifiedType::Float(FloatTy::F64)),
F128 => single(SimplifiedType::Float(FloatTy::F128)),
Str => single(SimplifiedType::Str),
Bool => single(SimplifiedType::Bool),
Char => single(SimplifiedType::Char),
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
I64 => tcx.types.i64,
I128 => tcx.types.i128,
Isize => tcx.types.isize,
F16 => tcx.types.f16,
F32 => tcx.types.f32,
F64 => tcx.types.f64,
F128 => tcx.types.f128,
U8 => tcx.types.u8,
U16 => tcx.types.u16,
U32 => tcx.types.u32,
Expand Down Expand Up @@ -2196,8 +2198,10 @@ fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<Res> {
"u32" => U32,
"u64" => U64,
"u128" => U128,
"f16" => F16,
"f32" => F32,
"f64" => F64,
"f128" => F128,
"char" => Char,
"bool" | "true" | "false" => Bool,
"str" | "&str" => Str,
Expand Down
14 changes: 13 additions & 1 deletion tests/rustdoc/primitive/primitive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![crate_name = "foo"]

#![feature(rustc_attrs)]
#![feature(f16)]
#![feature(f128)]

// @has foo/index.html '//h2[@id="primitives"]' 'Primitive Types'
// @has foo/index.html '//a[@href="primitive.i32.html"]' 'i32'
Expand All @@ -13,9 +15,19 @@
// @!has foo/index.html '//span' '🔒'
#[rustc_doc_primitive = "i32"]
/// this is a test!
mod i32{}
mod i32 {}

// @has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "bool"]
/// hello
mod bool {}

// @has foo/primitive.f16.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "f16"]
/// hello
mod f16 {}

// @has foo/primitive.f128.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "f128"]
/// hello
mod f128 {}

0 comments on commit 549d85d

Please sign in to comment.