Skip to content

ICE when generic type T is not bound to a Trait, but used as <T as Trait> in union declaration #87388

Closed
@zakarumych

Description

@zakarumych

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=dfd08aa6ef697ef5e4edd159a9bbaa37

Code

trait Foo {
    type Bar;
}
union Type<T> {
    bar: <T as Foo>::Bar,
}

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)

On nightly as well

Error output

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<T as Foo>::Bar`

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.55.0-nightly (32c9b7b09 2021-07-21) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<T as Foo>::Bar`
#1 [check_mod_unstable_api_usage] checking for unstable API usage in top-level module
end of query stack
error: could not compile `playground`
Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b\library\std\src\panic.rs:59:5
stack backtrace:
   0:     0x7ffd884c574e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6cc98e249320f302
   1:     0x7ffd884ee88c - core::fmt::write::h85dfbe120b6ddd44
   2:     0x7ffd884b9748 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h5e54761071278f40
   3:     0x7ffd884c97e2 - std::panicking::take_hook::h88bf14ecfdf59a5b
   4:     0x7ffd884c92c3 - std::panicking::take_hook::h88bf14ecfdf59a5b
   5:     0x7ffd7973de37 - rustc_driver::report_ice::hbc044b9faaa778a2
   6:     0x7ffd884ca035 - std::panicking::rust_panic_with_hook::hbf8551f03adac8c7
   7:     0x7ffd7d93bd00 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h5794a9d6c3f40738
   8:     0x7ffd7d93bc79 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h5794a9d6c3f40738
   9:     0x7ffd7dbe2ef1 - rustc_query_system::query::job::report_cycle::h60c3d77428bb768a
  10:     0x7ffd7d92b210 - <rustc_errors::emitter::FileWithAnnotatedLines as core::fmt::Debug>::fmt::h2399f20a95b85633
  11:     0x7ffd7d931c05 - rustc_errors::HandlerInner::err_count::h272524b264342f84
  12:     0x7ffd7d92f722 - rustc_errors::Handler::bug::h0fd8fb5edc26b7ac
  13:     0x7ffd7d7ccf78 - <rustc_middle::ty::sty::Binder<rustc_middle::ty::ProjectionPredicate> as rustc_middle::ty::ToPredicate>::to_predicate::hadca7a7419d51212
  14:     0x7ffd7d7c0c60 - rustc_middle::ty::query::on_disk_cache::<impl rustc_serialize::serialize::Decodable<rustc_middle::ty::query::on_disk_cache::CacheDecoder> for &[rustc_middle::mir::abstract_const::Node]>::decode::h43357b0f29f6c9b5
  15:     0x7ffd7d7c0ba9 - rustc_middle::ty::query::on_disk_cache::<impl rustc_serialize::serialize::Decodable<rustc_middle::ty::query::on_disk_cache::CacheDecoder> for &[rustc_middle::mir::abstract_const::Node]>::decode::h43357b0f29f6c9b5
  16:     0x7ffd7d7ccea9 - <rustc_middle::ty::sty::Binder<rustc_middle::ty::ProjectionPredicate> as rustc_middle::ty::ToPredicate>::to_predicate::hadca7a7419d51212
  17:     0x7ffd7dbdd3c7 - rustc_middle::util::bug::bug_fmt::h1510b6de2a300666
  18:     0x7ffd7ba61376 - rustc_traits::provide::h629c641245e02a6c
  19:     0x7ffd7bb2c913 - <rustc_middle::traits::chalk::ChalkEnvironmentAndGoal as rustc_traits::chalk::lowering::LowerInto<chalk_ir::InEnvironment<chalk_ir::Goal<rustc_middle::traits::chalk::RustInterner>>>>::lower_into::h3c101f253dec82a5
  20:     0x7ffd7c4a663d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  21:     0x7ffd7c54bb1c - <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::store_diagnostics_for_anon_node::hb1a9250ea723ec7f
  22:     0x7ffd7c2accd5 - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  23:     0x7ffd7c20de75 - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  24:     0x7ffd7c457cde - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  25:     0x7ffd7d74fb60 - <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h103dd803e86bb445
  26:     0x7ffd7c66a4f4 - <rustc_passes::stability::Checker as rustc_hir::intravisit::Visitor>::visit_item::hc2110ee2188ef1be
  27:     0x7ffd7c64c206 - <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_param::hb405ad205c81be46
  28:     0x7ffd7c669527 - <rustc_passes::stability::MissingStabilityAnnotations as rustc_hir::intravisit::Visitor>::visit_macro_def::h0ee140f0eb7bd392
  29:     0x7ffd7c4940f8 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  30:     0x7ffd7c53edba - <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::store_diagnostics_for_anon_node::hb1a9250ea723ec7f
  31:     0x7ffd7c2e836b - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  32:     0x7ffd7c1d1bbc - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  33:     0x7ffd7c450652 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  34:     0x7ffd7989efae - rustc_interface::queries::Linker::link::h2e8de7c6ea96ab52
  35:     0x7ffd7987ee55 - rustc_interface::passes::BoxedResolver::to_resolver_outputs::h41c44f992ccd4377
  36:     0x7ffd7c495311 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  37:     0x7ffd7c53c767 - <rustc_query_impl::plumbing::QueryCtxt as rustc_query_system::query::QueryContext>::store_diagnostics_for_anon_node::hb1a9250ea723ec7f
  38:     0x7ffd7c2a8c9a - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  39:     0x7ffd7c1bd40a - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_foreign_item::hda79da453640ae1e
  40:     0x7ffd7c44ce92 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_print_query_stack::h1a0e7e2e28ec4054
  41:     0x7ffd797781a9 - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h934311db2359d134
  42:     0x7ffd797489b1 - rustc_driver::pretty::print_after_hir_lowering::hc5364ea0ee4ca08c
  43:     0x7ffd79740b3c - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h84f69d4761638945
  44:     0x7ffd79749cd2 - rustc_driver::pretty::print_after_hir_lowering::hc5364ea0ee4ca08c
  45:     0x7ffd797721c4 - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h934311db2359d134
  46:     0x7ffd797744ef - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h934311db2359d134
  47:     0x7ffd7977ec4d - <rustc_middle::ty::SymbolName as core::fmt::Debug>::fmt::h934311db2359d134
  48:     0x7ffd884d817a - std::sys::windows::thread::Thread::new::h8dd2182e95caa21a
  49:     0x7ffe04e87034 - BaseThreadInitThunk
  50:     0x7ffe05042651 - RtlUserThreadStart

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