Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/rustc_middle/src/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::hash::Hash;
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def::DefKind;
use rustc_hir::{ItemKind, UseKind};
use rustc_macros::HashStable;
use rustc_query_system::ich::StableHashingContext;
use rustc_span::def_id::{CRATE_DEF_ID, LocalDefId};
Expand Down Expand Up @@ -180,8 +181,11 @@ impl EffectiveVisibilities {
// All effective visibilities except `reachable_through_impl_trait` are limited to
// nominal visibility. For some items nominal visibility doesn't make sense so we
// don't check this condition for them.
let is_impl = matches!(tcx.def_kind(def_id), DefKind::Impl { .. });
if !is_impl && tcx.trait_impl_of_assoc(def_id.to_def_id()).is_none() {
let def_kind = tcx.def_kind(def_id);
let is_impl = matches!(def_kind, DefKind::Impl { .. });
let is_glob_use = matches!(def_kind, DefKind::Use)
&& matches!(tcx.hir_expect_item(def_id).kind, ItemKind::Use(_, UseKind::Glob));
if !is_impl && tcx.trait_impl_of_assoc(def_id.to_def_id()).is_none() && !is_glob_use {
let nominal_vis = tcx.visibility(def_id);
if !nominal_vis.is_at_least(ev.reachable, tcx) {
span_bug!(
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/imports/pub-use-and-use-glob.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/151124>
//@ check-pass
Copy link
Member Author

Choose a reason for hiding this comment

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

When building Rustc locally, ICE reproduction was possible for this code without debug-assert

mod bar {
pub struct Symbol0;
}
use bar::*;
pub use bar::*;
fn main() {}
Loading