Skip to content

Commit e78913b

Browse files
committed
Auto merge of rust-lang#123592 - matthiaskrgr:rollup-3k1pq8s, r=matthiaskrgr
Rollup of 2 pull requests Successful merges: - rust-lang#123584 (Emit an error when `rustc_doc_primitive` has an unknown value) - rust-lang#123589 (sys_common::thread_local_key: make a note that this is not used on Windows) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4e431fa + e5bdd7e commit e78913b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

library/std/src/sys_common/thread_local_key.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! OS-based thread local storage
1+
//! OS-based thread local storage for non-Windows systems
22
//!
33
//! This module provides an implementation of OS-based thread local storage,
44
//! using the native OS-provided facilities (think `TlsAlloc` or
@@ -11,6 +11,9 @@
1111
//! the OS-TLS key. The other is a type which does implement `Drop` and hence
1212
//! has a safe interface.
1313
//!
14+
//! Windows doesn't use this module at all; `sys::pal::windows::thread_local_key`
15+
//! gets imported in its stead.
16+
//!
1417
//! # Usage
1518
//!
1619
//! This module should likely not be used directly unless other primitives are

src/librustdoc/clean/types.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use rustc_hir::{BodyId, Mutability};
2323
use rustc_hir_analysis::check::intrinsic::intrinsic_operation_unsafety;
2424
use rustc_index::IndexVec;
2525
use rustc_metadata::rendered_const;
26+
use rustc_middle::span_bug;
2627
use rustc_middle::ty::fast_reject::SimplifiedType;
2728
use rustc_middle::ty::{self, TyCtxt, Visibility};
2829
use rustc_resolve::rustdoc::{
@@ -266,8 +267,15 @@ impl ExternalCrate {
266267
let as_primitive = |res: Res<!>| {
267268
let Res::Def(DefKind::Mod, def_id) = res else { return None };
268269
tcx.get_attrs(def_id, sym::rustc_doc_primitive).find_map(|attr| {
269-
// FIXME: should warn on unknown primitives?
270-
Some((def_id, PrimitiveType::from_symbol(attr.value_str()?)?))
270+
let attr_value = attr.value_str().expect("syntax should already be validated");
271+
let Some(prim) = PrimitiveType::from_symbol(attr_value) else {
272+
span_bug!(
273+
attr.span,
274+
"primitive `{attr_value}` is not a member of `PrimitiveType`"
275+
);
276+
};
277+
278+
Some((def_id, prim))
271279
})
272280
};
273281

0 commit comments

Comments
 (0)