Add f16 and f128 to rustdoc's PrimitiveType

Fix a few places where these primitives were missing from librustdoc.
This commit is contained in:
Trevor Gross 2024-04-06 22:38:20 -04:00
parent aa1c45908d
commit ebc86e6f58
3 changed files with 21 additions and 1 deletions

View File

@ -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),
@ -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),

View File

@ -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,
@ -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,

View File

@ -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'
@ -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 {}