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

&dyn* causes an ICE #102172

Closed
Tracked by #102425
DutchGhost opened this issue Sep 23, 2022 · 3 comments · Fixed by #103386
Closed
Tracked by #102425

&dyn* causes an ICE #102172

DutchGhost opened this issue Sep 23, 2022 · 3 comments · Fixed by #103386
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` glacier ICE tracked in rust-lang/glacier. 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

@DutchGhost
Copy link
Contributor

Code

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

use core::fmt::Debug;

fn main() {
    let i = 42 as &dyn* Debug;
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (e7119a030 2022-09-22)

Error output

[<output>](error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/confirmation.rs:1147:18: impossible case reached)
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/confirmation.rs:1147:18: impossible case reached

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/compiler/rustc_errors/src/lib.rs:1496:9
stack backtrace:
   0:     0x7f6117c4bff0 - std::backtrace_rs::backtrace::libunwind::trace::hf4e04b2e4313927b
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f6117c4bff0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2771cf061d4680d1
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6117c4bff0 - std::sys_common::backtrace::_print_fmt::h2e413508900ead1c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f6117c4bff0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb886319318f6b897
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f6117ca6e1e - core::fmt::write::hd7350cb51945e18c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f6117c3caf5 - std::io::Write::write_fmt::ha7bc763f922fc662
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/io/mod.rs:1679:15
   6:     0x7f6117c4ed73 - std::sys_common::backtrace::_print::h7ad0003e1b032609
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f6117c4ed73 - std::sys_common::backtrace::print::h6f247b59322d4826
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f6117c4ed73 - std::panicking::default_hook::{{closure}}::h71a394bfa368bc38
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:267:22
   9:     0x7f6117c4ea5f - std::panicking::default_hook::h353829743ca9a29f
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:286:9
  10:     0x7f611a464ef1 - <rustc_driver[7857f239df018eab]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[cde1ce9e21f08391]::ops::function::FnOnce<(&core[cde1ce9e21f08391]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f6117c4f5ab - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5c7ac9f6a4be07e2
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1954:9
  12:     0x7f6117c4f5ab - std::panicking::rust_panic_with_hook::h6ad4960c15699d95
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:673:13
  13:     0x7f611b3f3ec1 - std[35bb8192b5670ad2]::panicking::begin_panic::<rustc_errors[354c2d440e1385ac]::ExplicitBug>::{closure#0}
  14:     0x7f611b3f19b6 - std[35bb8192b5670ad2]::sys_common::backtrace::__rust_end_short_backtrace::<std[35bb8192b5670ad2]::panicking::begin_panic<rustc_errors[354c2d440e1385ac]::ExplicitBug>::{closure#0}, !>
  15:     0x7f611b44a376 - std[35bb8192b5670ad2]::panicking::begin_panic::<rustc_errors[354c2d440e1385ac]::ExplicitBug>
  16:     0x7f611b3ee5a6 - std[35bb8192b5670ad2]::panic::panic_any::<rustc_errors[354c2d440e1385ac]::ExplicitBug>
  17:     0x7f611b3eb13f - <rustc_errors[354c2d440e1385ac]::HandlerInner>::bug::<&alloc[70f1755a93720895]::string::String>
  18:     0x7f611b3eab70 - <rustc_errors[354c2d440e1385ac]::Handler>::bug::<&alloc[70f1755a93720895]::string::String>
  19:     0x7f611b4aa73d - rustc_middle[33a3dc3ec8228005]::ty::context::tls::with_context_opt::<rustc_middle[33a3dc3ec8228005]::ty::context::tls::with_opt<rustc_middle[33a3dc3ec8228005]::util::bug::opt_span_bug_fmt<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f611b4ac2b6 - rustc_middle[33a3dc3ec8228005]::util::bug::opt_span_bug_fmt::<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span>
  21:     0x7f6118ecf583 - rustc_middle[33a3dc3ec8228005]::util::bug::bug_fmt
  22:     0x7f6118ecc3e5 - <rustc_trait_selection[c58af949e91f9309]::traits::select::SelectionContext>::confirm_candidate
  23:     0x7f6118eb3a55 - <rustc_trait_selection[c58af949e91f9309]::traits::select::SelectionContext>::select
  24:     0x7f6118ea96b8 - <rustc_infer[ab48729dad9c09b9]::infer::InferCtxt>::commit_if_ok::<rustc_infer[ab48729dad9c09b9]::infer::InferOk<(alloc[70f1755a93720895]::vec::Vec<rustc_middle[33a3dc3ec8228005]::ty::adjustment::Adjustment>, rustc_middle[33a3dc3ec8228005]::ty::Ty)>, rustc_middle[33a3dc3ec8228005]::ty::error::TypeError, <rustc_typeck[3342d60c7785d15]::check::fn_ctxt::FnCtxt>::try_coerce::{closure#1}>
  25:     0x7f6118f11e10 - <rustc_typeck[3342d60c7785d15]::check::fn_ctxt::FnCtxt>::try_coerce
  26:     0x7f611a850712 - <rustc_typeck[3342d60c7785d15]::check::cast::CastCheck>::report_cast_error
  27:     0x7f6119f0a50b - <rustc_typeck[3342d60c7785d15]::check::cast::CastCheck>::check
  28:     0x7f6119a6b725 - <rustc_infer[ab48729dad9c09b9]::infer::InferCtxtBuilder>::enter::<&rustc_middle[33a3dc3ec8228005]::ty::context::TypeckResults, <rustc_typeck[3342d60c7785d15]::check::inherited::InheritedBuilder>::enter<rustc_typeck[3342d60c7785d15]::check::typeck_with_fallback<rustc_typeck[3342d60c7785d15]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[33a3dc3ec8228005]::ty::context::TypeckResults>::{closure#0}>
  29:     0x7f6119a68629 - rustc_typeck[3342d60c7785d15]::check::typeck
  30:     0x7f6119816f65 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId, &rustc_middle[33a3dc3ec8228005]::ty::context::TypeckResults>>
  31:     0x7f611a3a6c0e - <rustc_query_impl[542bbd4b66bfb449]::Queries as rustc_middle[33a3dc3ec8228005]::ty::query::QueryEngine>::typeck
  32:     0x7f611a1ef747 - rustc_data_structures[bf19c7e493ef6519]::sync::par_for_each_in::<&[rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId], <rustc_middle[33a3dc3ec8228005]::hir::map::Map>::par_body_owners<rustc_typeck[3342d60c7785d15]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  33:     0x7f611a1ef503 - rustc_typeck[3342d60c7785d15]::check::typeck_item_bodies
  34:     0x7f611a0f2e5a - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<(), ()>>
  35:     0x7f611a0f2b87 - rustc_query_system[d3b2657d85679091]::query::plumbing::get_query::<rustc_query_impl[542bbd4b66bfb449]::queries::typeck_item_bodies, rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt>
  36:     0x7f6119842ebf - <rustc_session[fa757ff4c2b8954a]::session::Session>::time::<(), rustc_typeck[3342d60c7785d15]::check_crate::{closure#7}>
  37:     0x7f6119842a7f - rustc_typeck[3342d60c7785d15]::check_crate
  38:     0x7f6119842047 - rustc_interface[f2560d97934cc6f6]::passes::analysis
  39:     0x7f611a233e34 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<(), core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>>
  40:     0x7f611a233b67 - rustc_query_system[d3b2657d85679091]::query::plumbing::get_query::<rustc_query_impl[542bbd4b66bfb449]::queries::analysis, rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt>
  41:     0x7f61191fb0c3 - <rustc_interface[f2560d97934cc6f6]::passes::QueryContext>::enter::<rustc_driver[7857f239df018eab]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  42:     0x7f61191f5a0c - rustc_interface[f2560d97934cc6f6]::interface::create_compiler_and_run::<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>
  43:     0x7f61191f4342 - <scoped_tls[8ee1aa185b4607e2]::ScopedKey<rustc_span[4a0a9e8ceb64f0f4]::SessionGlobals>>::set::<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  44:     0x7f61191f402f - std[35bb8192b5670ad2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  45:     0x7f611a2c9980 - <<std[35bb8192b5670ad2]::thread::Builder>::spawn_unchecked_<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#1} as core[cde1ce9e21f08391]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7f6117c59393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe492c93bea3125c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  47:     0x7f6117c59393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c6cb812ee67c431
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  48:     0x7f6117c59393 - std::sys::unix::thread::Thread::new::thread_start::hcd53b5f11cecf106
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys/unix/thread.rs:108:17
  49:     0x7f6117b2c609 - start_thread
  50:     0x7f6117a4f133 - clone
  51:                0x0 - <unknown>

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.66.0-nightly (e7119a030 2022-09-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -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 `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

@DutchGhost DutchGhost 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 Sep 23, 2022
@crlf0710 crlf0710 added F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way. labels Sep 23, 2022
@eholk
Copy link
Contributor

eholk commented Sep 28, 2022

This looks like it should be a type error. The versions that should work are let i = 42 as dyn* Debug; and let i = &(42 as dyn* Debug);, and possibly let i = &42 as &dyn* Debug;. But, we definitely need a more helpful message than an ICE.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 1, 2022
@dwrensha
Copy link
Contributor

including the (unsurprising) output of cargo-bisect-rustc for completness...


searched nightlies: from nightly-2021-02-10 to nightly-2022-10-05
regressed nightly: nightly-2022-09-15
searched commit range: 17cbdfd...750bd1a
regressed commit: 6153d3c

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --end=2022-10-05 --regress ice 

@Rageking8
Copy link
Contributor

Another example to produce the same ICE

trait Trait {}

fn main() {
    let i = Box::new(1) as Box<dyn* Trait>;
}

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)]` glacier ICE tracked in rust-lang/glacier. 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.

6 participants