From dbeb506eaefdda5d9d7927c4d10d6d13a336eaf3 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Tue, 16 Aug 2022 15:37:31 +0200 Subject: [PATCH] rustdoc JSON: Fix ICE with `pub extern crate self as ` --- src/librustdoc/json/mod.rs | 4 ++-- .../reexport/export_extern_crate_as_self.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 6364d00d0624e..7b1b059e14dcb 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -209,11 +209,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { } types::ItemEnum::Method(_) + | types::ItemEnum::Module(_) | types::ItemEnum::AssocConst { .. } | types::ItemEnum::AssocType { .. } | types::ItemEnum::PrimitiveType(_) => true, - types::ItemEnum::Module(_) - | types::ItemEnum::ExternCrate { .. } + types::ItemEnum::ExternCrate { .. } | types::ItemEnum::Import(_) | types::ItemEnum::StructField(_) | types::ItemEnum::Variant(_) diff --git a/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs new file mode 100644 index 0000000000000..fda38056a094a --- /dev/null +++ b/src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs @@ -0,0 +1,11 @@ +//! Regression test for + +#![feature(no_core)] +#![no_core] + +#![crate_name = "export_extern_crate_as_self"] + +// ignore-tidy-linelength + +// @is export_extern_crate_as_self.json "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" +pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has