Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move doc(primitive) future incompat warning to invalid_doc_attributes #109443

Merged
merged 7 commits into from
Mar 31, 2023
Prev Previous commit
Next Next commit
Improve code
GuillaumeGomez committed Mar 30, 2023
commit bcf8a8b58ccdced38a3b7e9d1f3f219df782cf07
19 changes: 5 additions & 14 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
@@ -262,20 +262,11 @@ impl ExternalCrate {
// duplicately for the same primitive. This is handled later on when
// rendering by delegating everything to a hash map.
let as_primitive = |res: Res<!>| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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| {
        Some((def_id, PrimitiveType::from_symbol(attr.value_str()?)?))
    })
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's much better, thanks!

if let Res::Def(DefKind::Mod, def_id) = res {
let mut prim = None;
for attr in tcx.get_attrs(def_id, sym::rustc_doc_primitive) {
if let Some(v) = attr.value_str() {
prim = PrimitiveType::from_symbol(v);
if prim.is_some() {
break;
}
// FIXME: should warn on unknown primitives?
}
}
return prim.map(|p| (def_id, p));
}
None
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()?)?))
})
};

if root.is_local() {