Skip to content

Nightly: trait_alias compiler panic #110023

Description

@redpandamonium

Code

#![feature(trait_alias)]
trait ReturnsVoidFn<T: Fn() -> ()> = Fn() -> T;

type A<'a, T: Fn() -> ()> = Vec<&'a dyn ReturnsVoidFn<T>>;

Found while playing around in compiler explorer: https://rust.godbolt.org/z/sb31Teqsa. Looks pretty minimal to me already. I'm pretty sure this is the same bug, but I'm linking it just in case: https://rust.godbolt.org/z/89s8hcf85

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (700938c07 2023-04-04) running on x86_64-unknown-linux-gnu

Error output + Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `T`,
 right: `FreshTy(0)`', compiler/rustc_hir_analysis/src/astconv/mod.rs:1668:17
stack backtrace:
   0:     0x7f27be027f8a - std::backtrace_rs::backtrace::libunwind::trace::h08bd4b4334e680d9
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f27be027f8a - std::backtrace_rs::backtrace::trace_unsynchronized::hf594b03fffc7c3a4
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f27be027f8a - std::sys_common::backtrace::_print_fmt::h1134a35071387263
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f27be027f8a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h69f04f53733d3891
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f27be08c05f - core::fmt::write::heb1c797211b5fb3d
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f27be01aac5 - std::io::Write::write_fmt::h0753f8e473762982
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/io/mod.rs:1698:15
   6:     0x7f27be027d55 - std::sys_common::backtrace::_print::h91ef833f3b8da05b
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f27be027d55 - std::sys_common::backtrace::print::h95ac49619fd683a6
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f27be02a9fe - std::panicking::default_hook::{{closure}}::hd0ccf67e3d41bed4
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/panicking.rs:269:22
   9:     0x7f27be02a7a5 - std::panicking::default_hook::he9eeede79fcc44f5
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/panicking.rs:288:9
  10:     0x7f27c134f1c5 - <rustc_driver_impl[ed94cf31389203e0]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[be46bbda2f522b03]::ops::function::FnOnce<(&core[be46bbda2f522b03]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f27be02b1f4 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd73ef4fa9fa0cd04
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/alloc/src/boxed.rs:1990:9
  12:     0x7f27be02b1f4 - std::panicking::rust_panic_with_hook::hfee790920b2b90a3
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/panicking.rs:694:13
  13:     0x7f27be02af69 - std::panicking::begin_panic_handler::{{closure}}::h3bfe84e5bbd52252
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/panicking.rs:581:13
  14:     0x7f27be0283f6 - std::sys_common::backtrace::__rust_end_short_backtrace::hd97ff4e01dc5cc20
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f27be02acc2 - rust_begin_unwind
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/panicking.rs:577:5
  16:     0x7f27be088373 - core::panicking::panic_fmt::h6a7ef2d25e2f2c88
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/core/src/panicking.rs:67:14
  17:     0x7f27be08882f - core::panicking::assert_failed_inner::hcc738cf093fdf2e1
  18:     0x7f27c1433fdc - core[be46bbda2f522b03]::panicking::assert_failed::<rustc_middle[64ae24b83add495e]::ty::Ty, rustc_middle[64ae24b83add495e]::ty::Ty>
  19:     0x7f27c01d420e - <rustc_middle[64ae24b83add495e]::ty::sty::Binder<rustc_middle[64ae24b83add495e]::ty::ProjectionPredicate>>::map_bound::<<dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#14}::{closure#0}, rustc_middle[64ae24b83add495e]::ty::sty::ExistentialProjection>
  20:     0x7f27c01d30b1 - <core[be46bbda2f522b03]::iter::adapters::chain::Chain<core[be46bbda2f522b03]::iter::adapters::chain::Chain<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::slice::iter::Iter<rustc_trait_selection[5ed0f756c2c0cb57]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#13}>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#15}>, core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::slice::iter::Iter<(rustc_middle[64ae24b83add495e]::ty::sty::Binder<rustc_middle[64ae24b83add495e]::ty::ProjectionPredicate>, rustc_span[e6b7ef559b56b356]::span_encoding::Span)>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#14}>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#17}>>, core[be46bbda2f522b03]::iter::adapters::map::Map<alloc[1f106ccfb1b21e78]::vec::into_iter::IntoIter<rustc_trait_selection[5ed0f756c2c0cb57]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#16}>> as core[be46bbda2f522b03]::iter::traits::iterator::Iterator>::next
  21:     0x7f27c01d2a5d - <smallvec[93594887a929d590]::SmallVec<[rustc_middle[64ae24b83add495e]::ty::sty::Binder<rustc_middle[64ae24b83add495e]::ty::sty::ExistentialPredicate>; 8usize]> as core[be46bbda2f522b03]::iter::traits::collect::Extend<<[rustc_middle[64ae24b83add495e]::ty::sty::Binder<rustc_middle[64ae24b83add495e]::ty::sty::ExistentialPredicate>; 8usize] as smallvec[93594887a929d590]::Array>::Item>>::extend::<core[be46bbda2f522b03]::iter::adapters::chain::Chain<core[be46bbda2f522b03]::iter::adapters::chain::Chain<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::slice::iter::Iter<rustc_trait_selection[5ed0f756c2c0cb57]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#13}>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#15}>, core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::iter::adapters::map::Map<core[be46bbda2f522b03]::slice::iter::Iter<(rustc_middle[64ae24b83add495e]::ty::sty::Binder<rustc_middle[64ae24b83add495e]::ty::ProjectionPredicate>, rustc_span[e6b7ef559b56b356]::span_encoding::Span)>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#14}>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#17}>>, core[be46bbda2f522b03]::iter::adapters::map::Map<alloc[1f106ccfb1b21e78]::vec::into_iter::IntoIter<rustc_trait_selection[5ed0f756c2c0cb57]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref::{closure#16}>>>
  22:     0x7f27c01ccdd0 - <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::conv_object_ty_poly_trait_ref
  23:     0x7f27c01a846d - <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
  24:     0x7f27c01a79a3 - <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
  25:     0x7f27c01ac65f - <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::res_to_ty
  26:     0x7f27c01a7770 - <dyn rustc_hir_analysis[13f29dc14ec113f8]::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
  27:     0x7f27c06644a0 - rustc_hir_analysis[13f29dc14ec113f8]::collect::type_of::type_of
  28:     0x7f27bf989165 - rustc_query_system[dd711949c7ae4759]::query::plumbing::try_execute_query::<rustc_query_impl[17fce45f5d0458f2]::queries::type_of, rustc_query_impl[17fce45f5d0458f2]::plumbing::QueryCtxt>
  29:     0x7f27bf987ddd - <rustc_query_impl[17fce45f5d0458f2]::Queries as rustc_middle[64ae24b83add495e]::ty::query::QueryEngine>::type_of
  30:     0x7f27bf8e2208 - <rustc_hir_analysis[13f29dc14ec113f8]::collect::CollectItemTypesVisitor as rustc_hir[997ce0002422a023]::intravisit::Visitor>::visit_item
  31:     0x7f27bf8e0a44 - <rustc_middle[64ae24b83add495e]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[13f29dc14ec113f8]::collect::CollectItemTypesVisitor>
  32:     0x7f27bf8e096c - rustc_hir_analysis[13f29dc14ec113f8]::collect::collect_mod_item_types
  33:     0x7f27c0916071 - rustc_query_system[dd711949c7ae4759]::query::plumbing::try_execute_query::<rustc_query_impl[17fce45f5d0458f2]::queries::collect_mod_item_types, rustc_query_impl[17fce45f5d0458f2]::plumbing::QueryCtxt>
  34:     0x7f27c0915c99 - <rustc_query_impl[17fce45f5d0458f2]::Queries as rustc_middle[64ae24b83add495e]::ty::query::QueryEngine>::collect_mod_item_types
  35:     0x7f27c0757dff - <rustc_session[6c8e5f9a4f3dfafb]::session::Session>::track_errors::<rustc_hir_analysis[13f29dc14ec113f8]::check_crate::{closure#0}, ()>
  36:     0x7f27c07556b1 - rustc_hir_analysis[13f29dc14ec113f8]::check_crate
  37:     0x7f27c074f851 - rustc_interface[f9e4f758c3dbe73a]::passes::analysis
  38:     0x7f27c0ae0dd2 - rustc_query_system[dd711949c7ae4759]::query::plumbing::try_execute_query::<rustc_query_impl[17fce45f5d0458f2]::queries::analysis, rustc_query_impl[17fce45f5d0458f2]::plumbing::QueryCtxt>
  39:     0x7f27c0ae0ad0 - <rustc_query_impl[17fce45f5d0458f2]::Queries as rustc_middle[64ae24b83add495e]::ty::query::QueryEngine>::analysis
  40:     0x7f27c055e9de - <rustc_interface[f9e4f758c3dbe73a]::queries::QueryResult<&rustc_middle[64ae24b83add495e]::ty::context::GlobalCtxt>>::enter::<core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>, rustc_driver_impl[ed94cf31389203e0]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  41:     0x7f27c055d4be - <rustc_interface[f9e4f758c3dbe73a]::interface::Compiler>::enter::<rustc_driver_impl[ed94cf31389203e0]::run_compiler::{closure#1}::{closure#2}, core[be46bbda2f522b03]::result::Result<core[be46bbda2f522b03]::option::Option<rustc_interface[f9e4f758c3dbe73a]::queries::Linker>, rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>>
  42:     0x7f27c055b671 - rustc_span[e6b7ef559b56b356]::set_source_map::<core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>, rustc_interface[f9e4f758c3dbe73a]::interface::run_compiler<core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>, rustc_driver_impl[ed94cf31389203e0]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  43:     0x7f27c055ac1f - std[e75d324dc4549f18]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f9e4f758c3dbe73a]::util::run_in_thread_pool_with_globals<rustc_interface[f9e4f758c3dbe73a]::interface::run_compiler<core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>, rustc_driver_impl[ed94cf31389203e0]::run_compiler::{closure#1}>::{closure#0}, core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>>
  44:     0x7f27c055a601 - <<std[e75d324dc4549f18]::thread::Builder>::spawn_unchecked_<rustc_interface[f9e4f758c3dbe73a]::util::run_in_thread_pool_with_globals<rustc_interface[f9e4f758c3dbe73a]::interface::run_compiler<core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>, rustc_driver_impl[ed94cf31389203e0]::run_compiler::{closure#1}>::{closure#0}, core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[be46bbda2f522b03]::result::Result<(), rustc_span[e6b7ef559b56b356]::ErrorGuaranteed>>::{closure#1} as core[be46bbda2f522b03]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f27be0352d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3e40da2642ee301
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/alloc/src/boxed.rs:1976:9
  46:     0x7f27be0352d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h527cd1887e2c4efe
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/alloc/src/boxed.rs:1976:9
  47:     0x7f27be0352d5 - std::sys::unix::thread::Thread::new::thread_start::hc9f197c710586f02
                               at /rustc/700938c0781c9f135244bb1ec846fe1a5e03ae7d/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7f27bdf06609 - start_thread
  49:     0x7f27bde29133 - clone
  50:                0x0 - <unknown>

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: rustc 1.70.0-nightly (700938c07 2023-04-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib

query stack during panic:
#0 [type_of] expanding type alias `A`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
Compiler returned: 101

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions