From 695514e8d881c9e5a58cd1734ee8c22914c7a2df Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 7 Apr 2024 01:37:43 -0400 Subject: [PATCH 1/2] rustdoc: error when `rustc_doc_primitive` has an unknown type Currently rustdoc silently does nothing if it isn't aware of the specified primitive type. Change this to raise an error instead. --- src/librustdoc/clean/types.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6793ea9f485..8a53109d3ae 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -23,6 +23,7 @@ use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety; use rustc_index::IndexVec; use rustc_metadata::rendered_const; +use rustc_middle::span_bug; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, TyCtxt, Visibility}; use rustc_resolve::rustdoc::{ @@ -266,8 +267,15 @@ pub(crate) fn primitives(&self, tcx: TyCtxt<'_>) -> ThinVec<(DefId, PrimitiveTyp let as_primitive = |res: Res| { let Res::Def(DefKind::Mod, def_id) = res else { return None }; tcx.get_attrs(def_id, sym::rustc_doc_primitive).find_map(|attr| { - // FIXME: should warn on unknown primitives? - Some((def_id, PrimitiveType::from_symbol(attr.value_str()?)?)) + let attr_value = attr.value_str().expect("syntax should already be validated"); + let Some(prim) = PrimitiveType::from_symbol(attr_value) else { + span_bug!( + attr.span, + "primitive `{attr_value}` is not a member of `PrimitiveType`" + ); + }; + + Some((def_id, prim)) }) }; From b1d1ad9f8cbe9b6d66effaa9f5856a3b834b2e73 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 7 Apr 2024 12:23:47 +0200 Subject: [PATCH 2/2] sys_common::thread_local_key: make a note that this is not used on Windows --- library/std/src/sys_common/thread_local_key.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys_common/thread_local_key.rs b/library/std/src/sys_common/thread_local_key.rs index 7dcc1141099..a9cd26389cd 100644 --- a/library/std/src/sys_common/thread_local_key.rs +++ b/library/std/src/sys_common/thread_local_key.rs @@ -1,4 +1,4 @@ -//! OS-based thread local storage +//! OS-based thread local storage for non-Windows systems //! //! This module provides an implementation of OS-based thread local storage, //! using the native OS-provided facilities (think `TlsAlloc` or @@ -11,6 +11,9 @@ //! the OS-TLS key. The other is a type which does implement `Drop` and hence //! has a safe interface. //! +//! Windows doesn't use this module at all; `sys::pal::windows::thread_local_key` +//! gets imported in its stead. +//! //! # Usage //! //! This module should likely not be used directly unless other primitives are