Auto merge of #126761 - GuillaumeGomez:unsafe_extern_blocks, r=spasto… · rust-lang/rust@3cb521a (original) (raw)

`@@ -254,7 +254,7 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf

`

254

254

``

255

255

`match &*item.kind {

`

256

256

` 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, _) => {

`

258

258

`item_function(buf, cx, item, f)

`

259

259

`}

`

260

260

` 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

`

265

265

` clean::MacroItem(ref m) => item_macro(buf, cx, item, m),

`

266

266

` clean::ProcMacroItem(ref m) => item_proc_macro(buf, cx, item, m),

`

267

267

` 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)),

`

269

270

` clean::ConstantItem(generics, ty, c) => item_constant(buf, cx, item, generics, ty, c),

`

270

271

` clean::ForeignTypeItem => item_foreign_type(buf, cx, item),

`

271

272

` clean::KeywordItem => item_keyword(buf, cx, item),

`

`@@ -491,11 +492,14 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:

`

491

492

`}

`

492

493

``

493

494

`let unsafety_flag = match *myitem.kind {

`

494

``

`-

clean::FunctionItem() | clean::ForeignFunctionItem()

`

``

495

`+

clean::FunctionItem(_) | clean::ForeignFunctionItem(..)

`

495

496

`if myitem.fn_header(tcx).unwrap().safety == hir::Safety::Unsafe =>

`

496

497

`{

`

497

498

`"<sup title="unsafe function">⚠"

`

498

499

`}

`

``

500

`+

clean::ForeignStaticItem(_, hir::Safety::Unsafe) => {

`

``

501

`+

"<sup title="unsafe static">⚠"

`

``

502

`+

}

`

499

503

` _ => "",

`

500

504

`};

`

501

505

``

`@@ -1957,13 +1961,22 @@ fn item_fields(

`

1957

1961

`}

`

1958

1962

`}

`

1959

1963

``

1960

``

`-

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: Optionhir::Safety,

`

``

1970

`+

) {

`

1961

1971

`wrap_item(w, |buffer| {

`

1962

1972

`render_attributes_in_code(buffer, it, cx);

`

1963

1973

`write!(

`

1964

1974

` buffer,

`

1965

``

`-

"{vis}static {mutability}{name}: {typ}",

`

``

1975

`+

"{vis}{safe}static {mutability}{name}: {typ}",

`

1966

1976

` vis = visibility_print_with_space(it, cx),

`

``

1977

`+

safe = safety

`

``

1978

`+

.map(|safe| if safe == hir::Safety::Unsafe { "unsafe " } else { "" })

`

``

1979

`+

.unwrap_or(""),

`

1967

1980

` mutability = s.mutability.print_with_space(),

`

1968

1981

` name = it.name.unwrap(),

`

1969

1982

` typ = s.type_.print(cx)

`