Skip to content

Privacy assertion failure with staged_api and duplicated module name #104249

Closed
@jruderman

Description

Found with a modified fuzz-rustc.

Code

#![feature(staged_api)]
pub mod a {
}
pub mod a {
    pub mod b {
    }
}
fn main(){}
Alternative input with stability attributes
#![feature(staged_api)]
#![stable(feature = "foo", since = "1.0")]

#[stable(feature = "foo", since = "1.0")]
pub mod a {
}
#[stable(feature = "foo", since = "1.0")]
pub mod a {
    #[stable(feature = "foo", since = "1.0")]
    pub mod b {
    }
}
fn main(){}

Error output with debug assertions

error[E0428]: the name `a` is defined multiple times
error: internal compiler error: compiler/rustc_middle/src/middle/privacy.rs:171:17: private Restricted(DefId(0:4 ~ perr_n[96e5]::a#1)) > direct Restricted(DefId(0:5 ~ perr_n[96e5]::a#1::b))
Full output including backtrace
error[E0428]: the name `a` is defined multiple times
 --> perr-n.rs:4:1
  |
2 | pub mod a {
  | --------- previous definition of the module `a` here
3 | }
4 | pub mod a {
  | ^^^^^^^^^ `a` redefined here
  |
  = note: `a` must be defined only once in the type namespace of this module

error: internal compiler error: compiler/rustc_middle/src/middle/privacy.rs:171:17: private Restricted(DefId(0:4 ~ perr_n[96e5]::a#1)) > direct Restricted(DefId(0:5 ~ perr_n[96e5]::a#1::b))
 --> perr-n.rs:5:5
  |
5 |     pub mod b {
  |     ^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /Users/jruderman/code/rust/compiler/rustc_errors/src/lib.rs:967:33
stack backtrace:
   0:        0x105f67b51 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hca7435eb862ff36c
   1:        0x106004448 - core::fmt::write::hda6b0e10b55724fb
   2:        0x105f655c8 - std::io::Write::write_fmt::ha9d830225ddca362
   3:        0x105f67942 - std::sys_common::backtrace::print::h1790e63dbe903794
   4:        0x105f91355 - std::panicking::default_hook::{{closure}}::h43af9d0e518d235f
   5:        0x105f91137 - std::panicking::default_hook::h66fe7c7e4fb98f6f
   6:        0x117a99198 - rustc_driver[34272412877c8d7e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x105f91a16 - std::panicking::rust_panic_with_hook::h3f2771d8587a6225
   8:        0x11c6f9527 - std[8f57673cc279a434]::panicking::begin_panic::<rustc_errors[baeb4f2523d336bf]::ExplicitBug>::{closure#0}
   9:        0x11c6f9499 - std[8f57673cc279a434]::sys_common::backtrace::__rust_end_short_backtrace::<std[8f57673cc279a434]::panicking::begin_panic<rustc_errors[baeb4f2523d336bf]::ExplicitBug>::{closure#0}, !>
  10:        0x11ccf11a9 - std[8f57673cc279a434]::panicking::begin_panic::<rustc_errors[baeb4f2523d336bf]::ExplicitBug>
  11:        0x11c708769 - std[8f57673cc279a434]::panic::panic_any::<rustc_errors[baeb4f2523d336bf]::ExplicitBug>
  12:        0x11c7086e8 - <rustc_errors[baeb4f2523d336bf]::HandlerInner>::span_bug::<rustc_span[fb729f1b9e5ac969]::span_encoding::Span, &alloc[9c4954bf8315fe26]::string::String>
  13:        0x11c7084f4 - <rustc_errors[baeb4f2523d336bf]::Handler>::span_bug::<rustc_span[fb729f1b9e5ac969]::span_encoding::Span, &alloc[9c4954bf8315fe26]::string::String>
  14:        0x11c79c7d1 - rustc_middle[6f25fe7037d6027b]::ty::context::tls::with_opt::<rustc_middle[6f25fe7037d6027b]::util::bug::opt_span_bug_fmt<rustc_span[fb729f1b9e5ac969]::span_encoding::Span>::{closure#0}, ()>
  15:        0x11c79c841 - rustc_middle[6f25fe7037d6027b]::util::bug::opt_span_bug_fmt::<rustc_span[fb729f1b9e5ac969]::span_encoding::Span>
  16:        0x11cd0285f - rustc_middle[6f25fe7037d6027b]::util::bug::span_bug_fmt::<rustc_span[fb729f1b9e5ac969]::span_encoding::Span>
  17:        0x11c7b780b - <rustc_middle[6f25fe7037d6027b]::middle::privacy::EffectiveVisibilities>::check_invariants
  18:        0x11a5307d5 - rustc_privacy[d2e26e0ea95905a7]::effective_visibilities
  19:        0x11b7be7b0 - rustc_query_system[840d768d15d12085]::query::plumbing::try_execute_query::<rustc_query_impl[c109d582984dd181]::plumbing::QueryCtxt, rustc_query_system[840d768d15d12085]::query::caches::DefaultCache<(), &rustc_middle[6f25fe7037d6027b]::middle::privacy::EffectiveVisibilities>>
  20:        0x11b868c29 - rustc_query_system[840d768d15d12085]::query::plumbing::get_query::<rustc_query_impl[c109d582984dd181]::queries::effective_visibilities, rustc_query_impl[c109d582984dd181]::plumbing::QueryCtxt>
  21:        0x11b593027 - <rustc_query_impl[c109d582984dd181]::Queries as rustc_middle[6f25fe7037d6027b]::ty::query::QueryEngine>::effective_visibilities
  22:        0x11ad6fbe6 - rustc_passes[467a399e7fc15c73]::stability::check_unused_or_stable_features
  23:        0x117be16a7 - <rustc_session[c16dc8859e010203]::session::Session>::time::<(), rustc_interface[e9616f531c09701b]::passes::analysis::{closure#0}::{closure#2}::{closure#0}>
  24:        0x117bfa508 - std[8f57673cc279a434]::panicking::try::<(), core[63810368375d8c35]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[e9616f531c09701b]::passes::analysis::{closure#0}::{closure#2}>>
  25:        0x117be205c - <rustc_session[c16dc8859e010203]::session::Session>::time::<(), rustc_interface[e9616f531c09701b]::passes::analysis::{closure#0}>
  26:        0x117b9a311 - rustc_interface[e9616f531c09701b]::passes::analysis
  27:        0x11b7b61ed - rustc_query_system[840d768d15d12085]::query::plumbing::try_execute_query::<rustc_query_impl[c109d582984dd181]::plumbing::QueryCtxt, rustc_query_system[840d768d15d12085]::query::caches::DefaultCache<(), core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>>
  28:        0x11b8965d9 - rustc_query_system[840d768d15d12085]::query::plumbing::get_query::<rustc_query_impl[c109d582984dd181]::queries::analysis, rustc_query_impl[c109d582984dd181]::plumbing::QueryCtxt>
  29:        0x11b5647d7 - <rustc_query_impl[c109d582984dd181]::Queries as rustc_middle[6f25fe7037d6027b]::ty::query::QueryEngine>::analysis
  30:        0x117b173f8 - <rustc_interface[e9616f531c09701b]::passes::QueryContext>::enter::<rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>
  31:        0x117b01308 - <rustc_interface[e9616f531c09701b]::interface::Compiler>::enter::<rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}::{closure#2}, core[63810368375d8c35]::result::Result<core[63810368375d8c35]::option::Option<rustc_interface[e9616f531c09701b]::queries::Linker>, rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>
  32:        0x117a8729b - rustc_span[fb729f1b9e5ac969]::with_source_map::<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_interface[e9616f531c09701b]::interface::run_compiler<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  33:        0x117b0279a - <scoped_tls[a4e3500caacc884c]::ScopedKey<rustc_span[fb729f1b9e5ac969]::SessionGlobals>>::set::<rustc_interface[e9616f531c09701b]::interface::run_compiler<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}>::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>
  34:        0x117b065e0 - std[8f57673cc279a434]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e9616f531c09701b]::util::run_in_thread_pool_with_globals<rustc_interface[e9616f531c09701b]::interface::run_compiler<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}>::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>
  35:        0x117aea94d - std[8f57673cc279a434]::panicking::try::<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, core[63810368375d8c35]::panic::unwind_safe::AssertUnwindSafe<<std[8f57673cc279a434]::thread::Builder>::spawn_unchecked_<rustc_interface[e9616f531c09701b]::util::run_in_thread_pool_with_globals<rustc_interface[e9616f531c09701b]::interface::run_compiler<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}>::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
  36:        0x117a91b80 - <<std[8f57673cc279a434]::thread::Builder>::spawn_unchecked_<rustc_interface[e9616f531c09701b]::util::run_in_thread_pool_with_globals<rustc_interface[e9616f531c09701b]::interface::run_compiler<core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>, rustc_driver[34272412877c8d7e]::run_compiler::{closure#1}>::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[63810368375d8c35]::result::Result<(), rustc_errors[baeb4f2523d336bf]::ErrorGuaranteed>>::{closure#1} as core[63810368375d8c35]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:        0x105f992eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3d6d78cd5f090dbf
  38:        0x105fa0eef - std::sys::unix::thread::Thread::new::thread_start::h54ce6bb2ca11d46f
  39:     0x7ff80d84d4e1 - __pthread_start

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.67.0-dev running on x86_64-apple-darwin

query stack during panic:
#0 [effective_visibilities] checking effective visibilities
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0428`.

Regression

This is a new assertion, added in 448261a of #103965 (@petrochenkov). I don't know whether this indicates a pre-existing bug.

Version

Built stage1 on x86_64-apple-darwin at revision 01a6f30 with debug-assertions = true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions