Auto merge of #126761 - GuillaumeGomez:unsafe_extern_blocks, r=spasto… · rust-lang/rust@3cb521a
@@ -254,7 +254,7 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
254254255255match &*item.kind {
256256 clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
257- clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) => {
257+ clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f, _) => {
258258item_function(buf, cx, item, f)
259259}
260260 clean::TraitItem(ref t) => item_trait(buf, cx, item, t),
@@ -265,7 +265,8 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
265265 clean::MacroItem(ref m) => item_macro(buf, cx, item, m),
266266 clean::ProcMacroItem(ref m) => item_proc_macro(buf, cx, item, m),
267267 clean::PrimitiveItem(_) => item_primitive(buf, cx, item),
268- clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) => item_static(buf, cx, item, i),
268+ clean::StaticItem(ref i) => item_static(buf, cx, item, i, None),
269+ clean::ForeignStaticItem(ref i, safety) => item_static(buf, cx, item, i, Some(*safety)),
269270 clean::ConstantItem(generics, ty, c) => item_constant(buf, cx, item, generics, ty, c),
270271 clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
271272 clean::KeywordItem => item_keyword(buf, cx, item),
@@ -491,11 +492,14 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
491492}
492493493494let unsafety_flag = match *myitem.kind {
494- clean::FunctionItem(_) | clean::ForeignFunctionItem(_)
495+ clean::FunctionItem(_) | clean::ForeignFunctionItem(..)
495496if myitem.fn_header(tcx).unwrap().safety == hir::Safety::Unsafe =>
496497{
497498"<sup title=\"unsafe function\">⚠</sup>"
498499}
500+ clean::ForeignStaticItem(_, hir::Safety::Unsafe) => {
501+"<sup title=\"unsafe static\">⚠</sup>"
502+}
499503 _ => "",
500504};
501505@@ -1957,13 +1961,22 @@ fn item_fields(
19571961}
19581962}
195919631960-fn item_static(w: &mut impl fmt::Write, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
1964+fn item_static(
1965+w: &mut impl fmt::Write,
1966+cx: &mut Context<'_>,
1967+it: &clean::Item,
1968+s: &clean::Static,
1969+safety: Option<hir::Safety>,
1970+) {
19611971wrap_item(w, |buffer| {
19621972render_attributes_in_code(buffer, it, cx);
19631973write!(
19641974 buffer,
1965-"{vis}static {mutability}{name}: {typ}",
1975+"{vis}{safe}static {mutability}{name}: {typ}",
19661976 vis = visibility_print_with_space(it, cx),
1977+ safe = safety
1978+.map(|safe| if safe == hir::Safety::Unsafe { "unsafe " } else { "" })
1979+.unwrap_or(""),
19671980 mutability = s.mutability.print_with_space(),
19681981 name = it.name.unwrap(),
19691982 typ = s.type_.print(cx)