Rollup merge of #123584 - tgross35:rustc_doc_primitive-usage-error, r=fmease
Emit an error when `rustc_doc_primitive` has an unknown value Currently rustdoc silently does nothing. Change this to raise an error instead.
This commit is contained in:
commit
f64e97100c
1 changed files with 10 additions and 2 deletions
|
@ -23,6 +23,7 @@ use rustc_hir::{BodyId, Mutability};
|
|||
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 @@ impl ExternalCrate {
|
|||
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))
|
||||
})
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue