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 (should be handled by coerce) trying to convert dyn Trait into dyn* Trait #134544

Closed
theemathas opened this issue Dec 20, 2024 · 1 comment · Fixed by #134635
Closed

ICE (should be handled by coerce) trying to convert dyn Trait into dyn* Trait #134544

theemathas opened this issue Dec 20, 2024 · 1 comment · Fixed by #134635
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@theemathas
Copy link
Contributor

Code

#![feature(dyn_star)]
#![allow(incomplete_features)]

trait Foo {}

pub fn lol(x: &dyn Foo) {
    *x as dyn* Foo;
}

Meta

Reproducible on the playground with version 1.85.0-nightly (2024-12-19 9e136a30a965bf4e63f0)

Error output

Backtrace

error: internal compiler error: compiler/rustc_hir_typeck/src/cast.rs:725:17: should be handled by `coerce`
 --> src/lib.rs:7:5
  |
7 |     *x as dyn* Foo;
  |     ^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/cast.rs:725:17:
Box<dyn Any>
stack backtrace:
   0:     0x7ace13b8315a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6c37de0361fa7462
   1:     0x7ace14213cbc - core::fmt::write::hf77fe0583268bf67
   2:     0x7ace15142dd1 - std::io::Write::write_fmt::h3b0b8069e2435ed6
   3:     0x7ace13b82fb2 - std::sys::backtrace::BacktraceLock::print::hce84519ec0e7588e
   4:     0x7ace13b854aa - std::panicking::default_hook::{{closure}}::h6e0433c33d1ed12b
   5:     0x7ace13b852f3 - std::panicking::default_hook::h19d4e9e8d7fba9e2
   6:     0x7ace12cf7768 - std[19739dcbdd52d894]::panicking::update_hook::<alloc[d24e20bba6540ab9]::boxed::Box<rustc_driver_impl[3177e72804664110]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7ace13b85c68 - std::panicking::rust_panic_with_hook::hd21771b96ea64164
   8:     0x7ace12d322d1 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}
   9:     0x7ace12d274b6 - std[19739dcbdd52d894]::sys::backtrace::__rust_end_short_backtrace::<std[19739dcbdd52d894]::panicking::begin_panic<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}, !>
  10:     0x7ace12d23ec9 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>
  11:     0x7ace12d3c231 - <rustc_errors[37abd7aad4ad5df0]::diagnostic::BugAbort as rustc_errors[37abd7aad4ad5df0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7ace1328b76c - <rustc_errors[37abd7aad4ad5df0]::DiagCtxtHandle>::span_bug::<rustc_span[2a960e124d280c12]::span_encoding::Span, alloc[d24e20bba6540ab9]::string::String>
  13:     0x7ace13310fe7 - rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt::<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}
  14:     0x7ace132f67ba - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt::<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x7ace132f664b - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_context_opt::<rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x7ace1172b477 - rustc_middle[a45f2c6e02975f4b]::util::bug::span_bug_fmt::<rustc_span[2a960e124d280c12]::span_encoding::Span>
  17:     0x7ace151b0e5c - <rustc_hir_typeck[773c2b5054f1554]::cast::CastCheck>::do_check
  18:     0x7ace14439a98 - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_casts
  19:     0x7ace1443bad5 - rustc_hir_typeck[773c2b5054f1554]::typeck
  20:     0x7ace1443a67b - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 8usize]>>
  21:     0x7ace14494b91 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_data_structures[192c71b2dc5f58e0]::vec_cache::VecCache<rustc_span[2a960e124d280c12]::def_id::LocalDefId, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[1e197417f2882beb]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
  22:     0x7ace14493e4d - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7ace14493aff - <rustc_middle[a45f2c6e02975f4b]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f04f71a4747ef8cb]::check_crate::{closure#4}>::{closure#0}
  24:     0x7ace14491b12 - rustc_hir_analysis[f04f71a4747ef8cb]::check_crate
  25:     0x7ace1465a07c - rustc_interface[dfcc7ff3f03a05db]::passes::run_required_analyses
  26:     0x7ace15146c5e - rustc_interface[dfcc7ff3f03a05db]::passes::analysis
  27:     0x7ace15146c2f - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 0usize]>>
  28:     0x7ace151a9c55 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_query_system[1e197417f2882beb]::query::caches::SingleCache<rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
  29:     0x7ace151a998e - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ace1519ed9e - rustc_interface[dfcc7ff3f03a05db]::passes::create_and_enter_global_ctxt::<core[57d68807791337c0]::option::Option<rustc_interface[dfcc7ff3f03a05db]::queries::Linker>, rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  31:     0x7ace15210c43 - rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler::<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7ace151f7711 - std[19739dcbdd52d894]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7ace151f7ba6 - <<std[19739dcbdd52d894]::thread::Builder>::spawn_unchecked_<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[57d68807791337c0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7ace151f916f - std::sys::pal::unix::thread::Thread::new::thread_start::h71fe57097907b3f8
  35:     0x7ace16839a94 - <unknown>
  36:     0x7ace168c6a34 - clone
  37:                0x0 - <unknown>

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 `/playground/rustc-ice-2024-12-20T04_31_48-28.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [typeck] type-checking `lol`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` (lib)

Seems related to #134543 and #132127.

@rustbot labels +F-dyn_star +requires-nightly

@theemathas theemathas 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 Dec 20, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way. labels Dec 20, 2024
@matthiaskrgr
Copy link
Member

duplicate of #132127 I think

@bors bors closed this as completed in a8edf08 Dec 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 22, 2024
Rollup merge of rust-lang#134635 - compiler-errors:dyn-dyn, r=fmease

Don't ICE on illegal `dyn*` casts

Fixes rust-lang#134544
Fixes rust-lang#132127
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants