Skip to content

ICE: NOP unsize vtable changed principal trait ref #130855

Closed
@ehuss

Description

@ehuss

Code

fn main() {
    let subtype: &(dyn for<'a> Fn(&'a i32) -> &'a i32) = &|x| x;
    let supertype: &(dyn Fn(&'static i32) -> &'static i32) = subtype;
}

@compiler-errors I believe this is caused by #130735. Does that look like anything to you?

This doesn't seem to happen with the dist artifacts, only the settings used when testing in CI. The config used in CI is:

build.build          := x86_64-unknown-linux-gnu
rust.new-symbol-mangling := True
change-id            := 99999999
rust.codegen-units-std := 1
build.optimized-compiler-builtins := True
rust.verify-llvm-ir  := True
rust.channel         := nightly
rust.debug-assertions := True
rust.overflow-checks := True
llvm.assertions      := True
profile              := dist

I'm not sure which of those options is the culprit. EDIT: Almost certainly debug-assertions since it comes from debug_assert_eq.

This is causing the reference test suite to fail.

Meta

Using 0399709 which is currently unreleased.

Error output

thread 'rustc' panicked at /Users/eric/Proj/rust/rust/compiler/rustc_codegen_ssa/src/base.rs:139:17:
assertion `left == right` failed: NOP unsize vtable changed principal trait ref: for<'a> Fn(&'a i32) -> &i32 -> Fn(&i32) -> &i32
  left: Some(Binder { value: std::ops::Fn<(&i32,)>, bound_vars: [Region(BrAnon)] })
 right: Some(Binder { value: std::ops::Fn<(&i32,)>, bound_vars: [] })
stack backtrace:
   0:        0x101b54b8c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec38e2e59d3bd897
   1:        0x101ba28b8 - core::fmt::write::h86b880d51712e117
   2:        0x101b4a40c - std::io::Write::write_fmt::h04dc6eda66713a47
   3:        0x101b54a88 - std::sys::backtrace::BacktraceLock::print::hb7b409141cf4e9a0
   4:        0x101b572b8 - std::panicking::default_hook::{{closure}}::h2bcfe1201d2d75f0
   5:        0x101b57124 - std::panicking::default_hook::h4924a313ce2860ed
   6:        0x10d6060d8 - std[433ee821b815b648]::panicking::update_hook::<alloc[276fed6b273b7f5a]::boxed::Box<rustc_driver_impl[3871cb34889e72e2]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x101b57bb0 - std::panicking::rust_panic_with_hook::h76613d1d99f32bd7
   8:        0x101b57864 - std::panicking::begin_panic_handler::{{closure}}::hfeecd167b4281067
   9:        0x101b5515c - std::sys::backtrace::__rust_end_short_backtrace::hd030a3b0745e4845
  10:        0x101b57498 - _rust_begin_unwind
  11:        0x101bc061c - core::panicking::panic_fmt::h01cdd50c0fde8e82
  12:        0x101bc09d8 - core::panicking::assert_failed_inner::hfcdddeb78dc1b587
  13:        0x1132e1654 - core[86e044d91e4722ed]::panicking::assert_failed::<core[86e044d91e4722ed]::option::Option<rustc_type_ir[93885b82ab8bd98c]::binder::Binder<rustc_middle[6f4fac59e3602a2]::ty::context::TyCtxt, rustc_type_ir[93885b82ab8bd98c]::predicate::ExistentialTraitRef<rustc_middle[6f4fac59e3602a2]::ty::context::TyCtxt>>>, core[86e044d91e4722ed]::option::Option<rustc_type_ir[93885b82ab8bd98c]::binder::Binder<rustc_middle[6f4fac59e3602a2]::ty::context::TyCtxt, rustc_type_ir[93885b82ab8bd98c]::predicate::ExistentialTraitRef<rustc_middle[6f4fac59e3602a2]::ty::context::TyCtxt>>>>
  14:        0x10d955624 - rustc_codegen_ssa[27a895d4cd4eea55]::base::unsized_info::<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>
  15:        0x10d954fe4 - rustc_codegen_ssa[27a895d4cd4eea55]::base::unsize_ptr::<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>
  16:        0x10da7b35c - <rustc_codegen_ssa[27a895d4cd4eea55]::mir::FunctionCx<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>>::codegen_rvalue_operand
  17:        0x10da72e44 - rustc_codegen_ssa[27a895d4cd4eea55]::mir::codegen_mir::<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>
  18:        0x10d956adc - rustc_codegen_ssa[27a895d4cd4eea55]::base::codegen_instance::<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>
  19:        0x10d9f4378 - <rustc_middle[6f4fac59e3602a2]::mir::mono::MonoItem as rustc_codegen_ssa[27a895d4cd4eea55]::mono_item::MonoItemExt>::define::<rustc_codegen_llvm[d9c62a5eaf271a62]::builder::Builder>
  20:        0x10da4938c - rustc_codegen_llvm[d9c62a5eaf271a62]::base::compile_codegen_unit::module_codegen
  21:        0x10da48ac8 - rustc_codegen_llvm[d9c62a5eaf271a62]::base::compile_codegen_unit
  22:        0x10d956190 - rustc_codegen_ssa[27a895d4cd4eea55]::base::codegen_crate::<rustc_codegen_llvm[d9c62a5eaf271a62]::LlvmCodegenBackend>
  23:        0x10d9f0650 - <rustc_codegen_llvm[d9c62a5eaf271a62]::LlvmCodegenBackend as rustc_codegen_ssa[27a895d4cd4eea55]::traits::backend::CodegenBackend>::codegen_crate
  24:        0x10d927f6c - <rustc_session[af1947e1332477ae]::session::Session>::time::<alloc[276fed6b273b7f5a]::boxed::Box<dyn core[86e044d91e4722ed]::any::Any>, rustc_interface[55778473aa590b51]::passes::start_codegen::{closure#0}>
  25:        0x10d7fc858 - rustc_interface[55778473aa590b51]::passes::start_codegen
  26:        0x10d953b38 - <rustc_interface[55778473aa590b51]::queries::Linker>::codegen_and_build_linker
  27:        0x10d57c798 - <rustc_middle[6f4fac59e3602a2]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[3871cb34889e72e2]::run_compiler::{closure#0}::{closure#1}::{closure#6}, core[86e044d91e4722ed]::result::Result<core[86e044d91e4722ed]::option::Option<rustc_interface[55778473aa590b51]::queries::Linker>, rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>
  28:        0x10d5854bc - <rustc_interface[55778473aa590b51]::interface::Compiler>::enter::<rustc_driver_impl[3871cb34889e72e2]::run_compiler::{closure#0}::{closure#1}, core[86e044d91e4722ed]::result::Result<core[86e044d91e4722ed]::option::Option<rustc_interface[55778473aa590b51]::queries::Linker>, rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>
  29:        0x10d5b4b48 - <scoped_tls[443f3a74bab93e7b]::ScopedKey<rustc_span[8acec9caaabfd301]::SessionGlobals>>::set::<rustc_interface[55778473aa590b51]::util::run_in_thread_with_globals<rustc_interface[55778473aa590b51]::util::run_in_thread_pool_with_globals<rustc_interface[55778473aa590b51]::interface::run_compiler<core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>, rustc_driver_impl[3871cb34889e72e2]::run_compiler::{closure#0}>::{closure#1}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>
  30:        0x10d62e0bc - std[433ee821b815b648]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55778473aa590b51]::util::run_in_thread_with_globals<rustc_interface[55778473aa590b51]::util::run_in_thread_pool_with_globals<rustc_interface[55778473aa590b51]::interface::run_compiler<core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>, rustc_driver_impl[3871cb34889e72e2]::run_compiler::{closure#0}>::{closure#1}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>
  31:        0x10d6309c4 - <<std[433ee821b815b648]::thread::Builder>::spawn_unchecked_<rustc_interface[55778473aa590b51]::util::run_in_thread_with_globals<rustc_interface[55778473aa590b51]::util::run_in_thread_pool_with_globals<rustc_interface[55778473aa590b51]::interface::run_compiler<core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>, rustc_driver_impl[3871cb34889e72e2]::run_compiler::{closure#0}>::{closure#1}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[86e044d91e4722ed]::result::Result<(), rustc_span[8acec9caaabfd301]::ErrorGuaranteed>>::{closure#1} as core[86e044d91e4722ed]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:        0x101b61870 - std::sys::pal::unix::thread::Thread::new::thread_start::h9f6bbcdd39762e6a
  33:        0x19ead5f94 - __pthread_joiner_wake

error: 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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/eric/Temp/z32/rustc-ice-2024-09-25T21_59_32-3303.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

Metadata

Metadata

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-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions