Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE upcasting or calling a supertrait method, for trait object with unfulfilled bound on generic argument #136492

Closed
steffahn opened this issue Feb 3, 2025 · 2 comments
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-trait_upcasting `#![feature(trait_upcasting)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Feb 3, 2025

Original/first issue variant (using trait_upcasting)

This (first) example for an ICE is broken out from the review of #135318, the PR after which it’s first appearing:

#![feature(trait_upcasting)]

trait Supertrait<T> {
    fn method(&self) {}
}
impl<T> Supertrait<T> for () {}

trait WithAssoc {
    type Assoc;
}
trait Trait<P: WithAssoc>: Supertrait<P::Assoc> + Supertrait<()> {}

fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
    x
}

fn main() {
    println!("{:p}", upcast::<()> as *const ());
}

(playground)

The relevant subtle design/implementation point about trait objects is that upcasting them is (apparently) supported fully generically, for any &dyn Trait<P> type, even when P: WithAssoc isn’t met, even though Trait itself as a trait does require P: WithAssoc. The new vtable-deduplication logic then wants to determine whether or not Supertrait<P::Assoc> and Supertrait<()> are the same&deduplicated; and the possibility that P::Assoc might be impossible to normalize during monomorphization never handled: with P = () above, which doesn’t implement WithAssoc at all, <() as WithAssoc>::Assoc can’t be normalized.


Expected behavior: builds successfully; this was also the behavior on nightly until #135318 was merged

Actual behavior (since #135318 was merged):

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(Projection, AliasTy { args: [()], def_id: DefId(0:9 ~ playground[2f00]::WithAssoc::Assoc), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead
(backtrace…)
thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13:
Box<dyn Any>
stack backtrace:
   0:     0x7aac496307e0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha7a887e7d71c6e16
   1:     0x7aac49e147e6 - core::fmt::write::h8bce7c34d32c16d5
   2:     0x7aac4b0f8491 - std::io::Write::write_fmt::h61588d2e153c1fe1
   3:     0x7aac49630642 - std::sys::backtrace::BacktraceLock::print::h5e897e4367a4390b
   4:     0x7aac49632ac2 - std::panicking::default_hook::{{closure}}::hfb627b30254cb12b
   5:     0x7aac4963294a - std::panicking::default_hook::hc4630489198bafcd
   6:     0x7aac4878cf89 - std[a1eb87e154533a0e]::panicking::update_hook::<alloc[ad594d350f83b1d5]::boxed::Box<rustc_driver_impl[a791c9c5bd8cfc65]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7aac49633603 - std::panicking::rust_panic_with_hook::h5ee98a90e6655b2f
   8:     0x7aac487c7c71 - std[a1eb87e154533a0e]::panicking::begin_panic::<rustc_errors[4c730af126acd4ca]::ExplicitBug>::{closure#0}
   9:     0x7aac487bcbe6 - std[a1eb87e154533a0e]::sys::backtrace::__rust_end_short_backtrace::<std[a1eb87e154533a0e]::panicking::begin_panic<rustc_errors[4c730af126acd4ca]::ExplicitBug>::{closure#0}, !>
  10:     0x7aac487bc99f - std[a1eb87e154533a0e]::panicking::begin_panic::<rustc_errors[4c730af126acd4ca]::ExplicitBug>
  11:     0x7aac487d1c11 - <rustc_errors[4c730af126acd4ca]::diagnostic::BugAbort as rustc_errors[4c730af126acd4ca]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7aac48daf9a3 - rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt::<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}
  13:     0x7aac48d9859a - rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_opt::<rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7aac48d9842b - rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_context_opt::<rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_opt<rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7aac46f522b0 - rustc_middle[99a44bd93e00f3c6]::util::bug::bug_fmt
  16:     0x7aac4a3cdbb4 - <rustc_middle[99a44bd93e00f3c6]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[5dd542ab83ff2458]::fold::TypeFolder<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>::fold_ty
  17:     0x7aac493c5164 - <&rustc_middle[99a44bd93e00f3c6]::ty::list::RawList<(), rustc_middle[99a44bd93e00f3c6]::ty::generic_args::GenericArg> as rustc_type_ir[5dd542ab83ff2458]::fold::TypeFoldable<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[99a44bd93e00f3c6]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>
  18:     0x7aac4b9569af - <rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>::normalize_erasing_late_bound_regions::<rustc_type_ir[5dd542ab83ff2458]::predicate::TraitPredicate<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>.cold
  19:     0x7aac494d09dd - rustc_trait_selection[326587cd639b8c1b]::traits::vtable::supertrait_vtable_slot
  20:     0x7aac4917d766 - rustc_query_impl[7662b9ec157989e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7662b9ec157989e2]::query_impl::supertrait_vtable_slot::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7aac49161dc9 - <rustc_query_impl[7662b9ec157989e2]::query_impl::supertrait_vtable_slot::dynamic_query::{closure#2} as core[4442fbc2d924c325]::ops::function::FnOnce<(rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt, (rustc_middle[99a44bd93e00f3c6]::ty::Ty, rustc_middle[99a44bd93e00f3c6]::ty::Ty))>>::call_once
  22:     0x7aac490d0ce0 - rustc_query_system[68979f2bdbd6f64a]::query::plumbing::try_execute_query::<rustc_query_impl[7662b9ec157989e2]::DynamicConfig<rustc_query_system[68979f2bdbd6f64a]::query::caches::DefaultCache<(rustc_middle[99a44bd93e00f3c6]::ty::Ty, rustc_middle[99a44bd93e00f3c6]::ty::Ty), rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7662b9ec157989e2]::plumbing::QueryCtxt, false>
  23:     0x7aac4919c291 - rustc_query_impl[7662b9ec157989e2]::query_impl::supertrait_vtable_slot::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7aac4a328991 - rustc_codegen_ssa[eabe536e63931777]::base::unsized_info::<rustc_codegen_llvm[a131874fd9aa18eb]::builder::GenericBuilder<rustc_codegen_llvm[a131874fd9aa18eb]::context::CodegenCx>>
  25:     0x7aac4a327d18 - rustc_codegen_ssa[eabe536e63931777]::base::unsize_ptr::<rustc_codegen_llvm[a131874fd9aa18eb]::builder::GenericBuilder<rustc_codegen_llvm[a131874fd9aa18eb]::context::CodegenCx>>
  26:     0x7aac4a3029c6 - <rustc_codegen_ssa[eabe536e63931777]::mir::FunctionCx<rustc_codegen_llvm[a131874fd9aa18eb]::builder::GenericBuilder<rustc_codegen_llvm[a131874fd9aa18eb]::context::CodegenCx>>>::codegen_rvalue_operand
  27:     0x7aac4a95d8c1 - rustc_codegen_ssa[eabe536e63931777]::mir::codegen_mir::<rustc_codegen_llvm[a131874fd9aa18eb]::builder::GenericBuilder<rustc_codegen_llvm[a131874fd9aa18eb]::context::CodegenCx>>
  28:     0x7aac4a9080bf - rustc_codegen_llvm[a131874fd9aa18eb]::base::compile_codegen_unit::module_codegen
  29:     0x7aac4adf3588 - <rustc_codegen_llvm[a131874fd9aa18eb]::LlvmCodegenBackend as rustc_codegen_ssa[eabe536e63931777]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  30:     0x7aac4adef817 - rustc_codegen_ssa[eabe536e63931777]::base::codegen_crate::<rustc_codegen_llvm[a131874fd9aa18eb]::LlvmCodegenBackend>
  31:     0x7aac4adeebaf - <rustc_codegen_llvm[a131874fd9aa18eb]::LlvmCodegenBackend as rustc_codegen_ssa[eabe536e63931777]::traits::backend::CodegenBackend>::codegen_crate
  32:     0x7aac4adf65f4 - <rustc_interface[71b698d67f628f7f]::queries::Linker>::codegen_and_build_linker
  33:     0x7aac4ad9c69f - rustc_interface[71b698d67f628f7f]::passes::create_and_enter_global_ctxt::<core[4442fbc2d924c325]::option::Option<rustc_interface[71b698d67f628f7f]::queries::Linker>, rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  34:     0x7aac4ad7bcb3 - rustc_interface[71b698d67f628f7f]::interface::run_compiler::<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7aac4ace8bb5 - std[a1eb87e154533a0e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[71b698d67f628f7f]::util::run_in_thread_with_globals<rustc_interface[71b698d67f628f7f]::util::run_in_thread_pool_with_globals<rustc_interface[71b698d67f628f7f]::interface::run_compiler<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  36:     0x7aac4ace8899 - <<std[a1eb87e154533a0e]::thread::Builder>::spawn_unchecked_<rustc_interface[71b698d67f628f7f]::util::run_in_thread_with_globals<rustc_interface[71b698d67f628f7f]::util::run_in_thread_pool_with_globals<rustc_interface[71b698d67f628f7f]::interface::run_compiler<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4442fbc2d924c325]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7aac4ace802b - std::sys::pal::unix::thread::Thread::new::thread_start::h83cea321e92f80f9
  38:     0x7aac4c5a0a94 - <unknown>
  39:     0x7aac4c62da34 - clone
  40:                0x0 - <unknown>

@compiler-errors had already opened a PR with a possible fix, and it includes (a variant of) this test case.

@rustbot label A-trait-objects F-trait_upcasting
(deliberately no “requires-nightly” label, see next section)


Second issue variant (regression without unstable features)

Looking at the PR, it seems @compiler-errors has also identified that this ICEs from a method call, not just upcasting (as what the original repro did):

trait Supertrait<T> {
    fn method(&self) {}
}
impl<T> Supertrait<T> for () {}

trait WithAssoc {
    type Assoc;
}
trait Trait<P: WithAssoc>: Supertrait<P::Assoc> + Supertrait<()> {}

fn call<P>(x: &dyn Trait<P>) {
    x.method();
}

fn main() {
    println!("{:p}", call::<()> as *const ());
}

(playground)

(behavior: same as above, w.r.t expected behavior, regression point, and [similar] ICE message)

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(Projection, AliasTy { args: [()], def_id: DefId(0:9 ~ playground[2f00]::WithAssoc::Assoc), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead
(backtrace…)
thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13:
Box<dyn Any>
stack backtrace:
   0:     0x751dd00307e0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha7a887e7d71c6e16
   1:     0x751dd08147e6 - core::fmt::write::h8bce7c34d32c16d5
   2:     0x751dd1af8491 - std::io::Write::write_fmt::h61588d2e153c1fe1
   3:     0x751dd0030642 - std::sys::backtrace::BacktraceLock::print::h5e897e4367a4390b
   4:     0x751dd0032ac2 - std::panicking::default_hook::{{closure}}::hfb627b30254cb12b
   5:     0x751dd003294a - std::panicking::default_hook::hc4630489198bafcd
   6:     0x751dcf18cf89 - std[a1eb87e154533a0e]::panicking::update_hook::<alloc[ad594d350f83b1d5]::boxed::Box<rustc_driver_impl[a791c9c5bd8cfc65]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x751dd0033603 - std::panicking::rust_panic_with_hook::h5ee98a90e6655b2f
   8:     0x751dcf1c7c71 - std[a1eb87e154533a0e]::panicking::begin_panic::<rustc_errors[4c730af126acd4ca]::ExplicitBug>::{closure#0}
   9:     0x751dcf1bcbe6 - std[a1eb87e154533a0e]::sys::backtrace::__rust_end_short_backtrace::<std[a1eb87e154533a0e]::panicking::begin_panic<rustc_errors[4c730af126acd4ca]::ExplicitBug>::{closure#0}, !>
  10:     0x751dcf1bc99f - std[a1eb87e154533a0e]::panicking::begin_panic::<rustc_errors[4c730af126acd4ca]::ExplicitBug>
  11:     0x751dcf1d1c11 - <rustc_errors[4c730af126acd4ca]::diagnostic::BugAbort as rustc_errors[4c730af126acd4ca]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x751dcf7af9a3 - rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt::<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}
  13:     0x751dcf79859a - rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_opt::<rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x751dcf79842b - rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_context_opt::<rustc_middle[99a44bd93e00f3c6]::ty::context::tls::with_opt<rustc_middle[99a44bd93e00f3c6]::util::bug::opt_span_bug_fmt<rustc_span[a22240cbbe35b408]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x751dcd9522b0 - rustc_middle[99a44bd93e00f3c6]::util::bug::bug_fmt
  16:     0x751dd0dcdbb4 - <rustc_middle[99a44bd93e00f3c6]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[5dd542ab83ff2458]::fold::TypeFolder<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>::fold_ty
  17:     0x751dcfdc5164 - <&rustc_middle[99a44bd93e00f3c6]::ty::list::RawList<(), rustc_middle[99a44bd93e00f3c6]::ty::generic_args::GenericArg> as rustc_type_ir[5dd542ab83ff2458]::fold::TypeFoldable<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[99a44bd93e00f3c6]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder>
  18:     0x751dd23569af - <rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>::normalize_erasing_late_bound_regions::<rustc_type_ir[5dd542ab83ff2458]::predicate::TraitPredicate<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>>.cold
  19:     0x751dd15e56c4 - rustc_trait_selection[326587cd639b8c1b]::traits::vtable::first_method_vtable_slot
  20:     0x751dd15e52f6 - rustc_query_impl[7662b9ec157989e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7662b9ec157989e2]::query_impl::first_method_vtable_slot::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 8usize]>>
  21:     0x751dd15e52db - <rustc_query_impl[7662b9ec157989e2]::query_impl::first_method_vtable_slot::dynamic_query::{closure#2} as core[4442fbc2d924c325]::ops::function::FnOnce<(rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt, rustc_type_ir[5dd542ab83ff2458]::predicate::TraitRef<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>)>>::call_once
  22:     0x751dd15ebacf - rustc_query_system[68979f2bdbd6f64a]::query::plumbing::try_execute_query::<rustc_query_impl[7662b9ec157989e2]::DynamicConfig<rustc_query_system[68979f2bdbd6f64a]::query::caches::DefaultCache<rustc_type_ir[5dd542ab83ff2458]::predicate::TraitRef<rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt>, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7662b9ec157989e2]::plumbing::QueryCtxt, false>
  23:     0x751dd15eb7ec - rustc_query_impl[7662b9ec157989e2]::query_impl::first_method_vtable_slot::get_query_non_incr::__rust_end_short_backtrace
  24:     0x751dce0504ad - rustc_ty_utils[6f69adb5a450b42]::instance::resolve_instance_raw
  25:     0x751dd0cdc8f2 - rustc_query_impl[7662b9ec157989e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7662b9ec157989e2]::query_impl::resolve_instance_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 32usize]>>
  26:     0x751dd0cdccae - rustc_query_system[68979f2bdbd6f64a]::query::plumbing::try_execute_query::<rustc_query_impl[7662b9ec157989e2]::DynamicConfig<rustc_query_system[68979f2bdbd6f64a]::query::caches::DefaultCache<rustc_middle[99a44bd93e00f3c6]::ty::PseudoCanonicalInput<(rustc_span[a22240cbbe35b408]::def_id::DefId, &rustc_middle[99a44bd93e00f3c6]::ty::list::RawList<(), rustc_middle[99a44bd93e00f3c6]::ty::generic_args::GenericArg>)>, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[7662b9ec157989e2]::plumbing::QueryCtxt, false>
  27:     0x751dd0cdc86e - rustc_query_impl[7662b9ec157989e2]::query_impl::resolve_instance_raw::get_query_non_incr::__rust_end_short_backtrace
  28:     0x751dd0cda903 - <rustc_middle[99a44bd93e00f3c6]::ty::instance::Instance>::expect_resolve
  29:     0x751dcd4aea0d - rustc_monomorphize[86e20e627c2db3b3]::collector::items_of_instance
  30:     0x751dd131e090 - rustc_query_impl[7662b9ec157989e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7662b9ec157989e2]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 32usize]>>
  31:     0x751dd131d8f4 - rustc_query_system[68979f2bdbd6f64a]::query::plumbing::try_execute_query::<rustc_query_impl[7662b9ec157989e2]::DynamicConfig<rustc_query_system[68979f2bdbd6f64a]::query::caches::DefaultCache<(rustc_middle[99a44bd93e00f3c6]::ty::instance::Instance, rustc_middle[99a44bd93e00f3c6]::mir::mono::CollectionMode), rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[7662b9ec157989e2]::plumbing::QueryCtxt, false>
  32:     0x751dd131d52c - rustc_query_impl[7662b9ec157989e2]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
  33:     0x751dd1319f44 - rustc_monomorphize[86e20e627c2db3b3]::collector::collect_items_rec::{closure#0}
  34:     0x751dcd495516 - rustc_monomorphize[86e20e627c2db3b3]::collector::collect_items_rec
  35:     0x751dcd495e7a - rustc_monomorphize[86e20e627c2db3b3]::collector::collect_items_rec
  36:     0x751dcda449bc - rustc_monomorphize[86e20e627c2db3b3]::partitioning::collect_and_partition_mono_items
  37:     0x751dd17d3a16 - rustc_query_impl[7662b9ec157989e2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7662b9ec157989e2]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 40usize]>>
  38:     0x751dd17d39ef - <rustc_query_impl[7662b9ec157989e2]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[4442fbc2d924c325]::ops::function::FnOnce<(rustc_middle[99a44bd93e00f3c6]::ty::context::TyCtxt, ())>>::call_once
  39:     0x751dd17d355a - rustc_query_system[68979f2bdbd6f64a]::query::plumbing::try_execute_query::<rustc_query_impl[7662b9ec157989e2]::DynamicConfig<rustc_query_system[68979f2bdbd6f64a]::query::caches::SingleCache<rustc_middle[99a44bd93e00f3c6]::query::erase::Erased<[u8; 40usize]>>, false, false, false>, rustc_query_impl[7662b9ec157989e2]::plumbing::QueryCtxt, false>
  40:     0x751dd17d32fc - rustc_query_impl[7662b9ec157989e2]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  41:     0x751dd17ef10a - rustc_codegen_ssa[eabe536e63931777]::base::codegen_crate::<rustc_codegen_llvm[a131874fd9aa18eb]::LlvmCodegenBackend>
  42:     0x751dd17eebaf - <rustc_codegen_llvm[a131874fd9aa18eb]::LlvmCodegenBackend as rustc_codegen_ssa[eabe536e63931777]::traits::backend::CodegenBackend>::codegen_crate
  43:     0x751dd17f65f4 - <rustc_interface[71b698d67f628f7f]::queries::Linker>::codegen_and_build_linker
  44:     0x751dd179c69f - rustc_interface[71b698d67f628f7f]::passes::create_and_enter_global_ctxt::<core[4442fbc2d924c325]::option::Option<rustc_interface[71b698d67f628f7f]::queries::Linker>, rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  45:     0x751dd177bcb3 - rustc_interface[71b698d67f628f7f]::interface::run_compiler::<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}
  46:     0x751dd16e8bb5 - std[a1eb87e154533a0e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[71b698d67f628f7f]::util::run_in_thread_with_globals<rustc_interface[71b698d67f628f7f]::util::run_in_thread_pool_with_globals<rustc_interface[71b698d67f628f7f]::interface::run_compiler<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  47:     0x751dd16e8899 - <<std[a1eb87e154533a0e]::thread::Builder>::spawn_unchecked_<rustc_interface[71b698d67f628f7f]::util::run_in_thread_with_globals<rustc_interface[71b698d67f628f7f]::util::run_in_thread_pool_with_globals<rustc_interface[71b698d67f628f7f]::interface::run_compiler<(), rustc_driver_impl[a791c9c5bd8cfc65]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4442fbc2d924c325]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x751dd16e802b - std::sys::pal::unix::thread::Thread::new::thread_start::h83cea321e92f80f9
  49:     0x751dd2ecfa94 - <unknown>
  50:     0x751dd2f5ca34 - clone
  51:                0x0 - <unknown>

This means we do have an ICE regression on nightly without unstable features, which I don’t see tracked anywhere else yet (let's track this so it can't be forgotten, especially with the next beta cut coming up soon-ish).

The relevant subtle design/implementation point about trait objects is that a &dyn Trait<P> trait object will still be considered to implement all its supertraits, including Supertrait<()> in particular (so you can call its supertrait methods), even when P: WithAssoc doesn’t hold. For illustration, this variant of fn call also compiles:

fn call<P>(x: &dyn Trait<P>) {
    trt_check(x);
}

fn trt_check(x: &(impl Supertrait<()> + ?Sized)) {
    x.method();
}

(and it can be used in the same way to now ICE)

@rustbot label regression-from-stable-to-nightly

@steffahn steffahn added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 3, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-trait-objects Area: trait objects, vtable layout F-trait_upcasting `#![feature(trait_upcasting)]` regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 3, 2025
@compiler-errors compiler-errors added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 3, 2025
@compiler-errors
Copy link
Member

I don't expect this to exist in practice and they both should be fixed by the PR I put up

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 2025
@steffahn
Copy link
Member Author

steffahn commented Feb 6, 2025

Closing with #136311 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-trait_upcasting `#![feature(trait_upcasting)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants