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

Associated type bounds ICE #106077

Closed
DutchGhost opened this issue Dec 23, 2022 · 2 comments · Fixed by #108063
Closed

Associated type bounds ICE #106077

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

Comments

@DutchGhost
Copy link
Contributor

Code

#![feature(associated_type_bounds)]

struct Bug<T: ?Sized>(T);

impl Bug<dyn Iterator<Item: Copy>> {}

Meta

rustc --version --verbose:

1.68.0-nightly (8a97b4812 2022-12-22)

Error output

[<output>](error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:2133:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: Impl, disambiguator: 0 }], krate: crate0 })
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:2133:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: Impl, disambiguator: 0 }], krate: crate0 }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
   0:     0x7f6c97deda7a - std::backtrace_rs::backtrace::libunwind::trace::h250f5acc74207c14
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f6c97deda7a - std::backtrace_rs::backtrace::trace_unsynchronized::h8b2cc87ea209f556
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6c97deda7a - std::sys_common::backtrace::_print_fmt::he79fe9ac625765a8
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f6c97deda7a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b8cfd7233c5cf16
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f6c97e507ae - core::fmt::write::hf4356953bb6287e9
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f6c97ddde45 - std::io::Write::write_fmt::h777ff3ca89a9d1e9
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/io/mod.rs:1682:15
   6:     0x7f6c97ded845 - std::sys_common::backtrace::_print::h30bd0c5979c85003
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f6c97ded845 - std::sys_common::backtrace::print::he11670adbc4564f8
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f6c97df058f - std::panicking::default_hook::{{closure}}::h2b850e11ab02b140
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/panicking.rs:267:22
   9:     0x7f6c97df02cb - std::panicking::default_hook::h5e8af7c8d5de5af1
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/panicking.rs:286:9
  10:     0x7f6c9b0d5151 - rustc_driver[b1659719c04a24c8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f6c97df0dcd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3e73a49254418f01
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/alloc/src/boxed.rs:2032:9
  12:     0x7f6c97df0dcd - std::panicking::rust_panic_with_hook::hfdcd0659796f0493
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/panicking.rs:692:13
  13:     0x7f6c9b57c1d1 - std[1a5a851d154403c1]::panicking::begin_panic::<rustc_errors[f3b4af3fda1898a3]::ExplicitBug>::{closure#0}
  14:     0x7f6c9b57b896 - std[1a5a851d154403c1]::sys_common::backtrace::__rust_end_short_backtrace::<std[1a5a851d154403c1]::panicking::begin_panic<rustc_errors[f3b4af3fda1898a3]::ExplicitBug>::{closure#0}, !>
  15:     0x7f6c9b5dac06 - std[1a5a851d154403c1]::panicking::begin_panic::<rustc_errors[f3b4af3fda1898a3]::ExplicitBug>
  16:     0x7f6c9b57a156 - std[1a5a851d154403c1]::panic::panic_any::<rustc_errors[f3b4af3fda1898a3]::ExplicitBug>
  17:     0x7f6c9b578f16 - <rustc_errors[f3b4af3fda1898a3]::HandlerInner>::bug::<&alloc[225e6e9bb7b947dc]::string::String>
  18:     0x7f6c9b578b80 - <rustc_errors[f3b4af3fda1898a3]::Handler>::bug::<&alloc[225e6e9bb7b947dc]::string::String>
  19:     0x7f6c9b5587fe - rustc_middle[fdc133b60cc8890c]::ty::context::tls::with_context_opt::<rustc_middle[fdc133b60cc8890c]::ty::context::tls::with_opt<rustc_middle[fdc133b60cc8890c]::util::bug::opt_span_bug_fmt<rustc_span[506ca92461b63806]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f6c9b55a036 - rustc_middle[fdc133b60cc8890c]::util::bug::opt_span_bug_fmt::<rustc_span[506ca92461b63806]::span_encoding::Span>
  21:     0x7f6c992d03e3 - rustc_middle[fdc133b60cc8890c]::util::bug::bug_fmt
  22:     0x7f6c99a388f8 - <rustc_middle[fdc133b60cc8890c]::ty::context::TyCtxt>::item_name
  23:     0x7f6c9b201485 - rustc_hir_analysis[381fda3b2e789037]::collect::type_of::find_opaque_ty_constraints_for_tait
  24:     0x7f6c9a8d546f - rustc_hir_analysis[381fda3b2e789037]::collect::type_of::type_of
  25:     0x7f6c99a29597 - rustc_query_system[f9c56c1c769457d6]::query::plumbing::get_query::<rustc_query_impl[77e79af898dd5aab]::queries::type_of, rustc_query_impl[77e79af898dd5aab]::plumbing::QueryCtxt>
  26:     0x7f6c99b218ec - rustc_hir_analysis[381fda3b2e789037]::check::check::check_mod_item_types
  27:     0x7f6c99c6a111 - rustc_query_system[f9c56c1c769457d6]::query::plumbing::try_execute_query::<rustc_query_impl[77e79af898dd5aab]::plumbing::QueryCtxt, rustc_query_system[f9c56c1c769457d6]::query::caches::VecCache<rustc_span[506ca92461b63806]::def_id::LocalDefId, ()>>
  28:     0x7f6c9a4e0433 - rustc_query_system[f9c56c1c769457d6]::query::plumbing::get_query::<rustc_query_impl[77e79af898dd5aab]::queries::check_mod_item_types, rustc_query_impl[77e79af898dd5aab]::plumbing::QueryCtxt>
  29:     0x7f6c9a79de45 - <rustc_middle[fdc133b60cc8890c]::hir::map::Map>::for_each_module::<rustc_hir_analysis[381fda3b2e789037]::check_crate::{closure#6}::{closure#0}>
  30:     0x7f6c995c0bd2 - rustc_hir_analysis[381fda3b2e789037]::check_crate
  31:     0x7f6c995c081b - rustc_interface[27db4dcdd626da73]::passes::analysis
  32:     0x7f6c9a8958c7 - rustc_query_system[f9c56c1c769457d6]::query::plumbing::try_execute_query::<rustc_query_impl[77e79af898dd5aab]::plumbing::QueryCtxt, rustc_query_system[f9c56c1c769457d6]::query::caches::DefaultCache<(), core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>>
  33:     0x7f6c9a8955c0 - rustc_query_system[f9c56c1c769457d6]::query::plumbing::get_query::<rustc_query_impl[77e79af898dd5aab]::queries::analysis, rustc_query_impl[77e79af898dd5aab]::plumbing::QueryCtxt>
  34:     0x7f6c9a31b293 - <rustc_interface[27db4dcdd626da73]::passes::QueryContext>::enter::<rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>
  35:     0x7f6c9a317643 - <rustc_interface[27db4dcdd626da73]::interface::Compiler>::enter::<rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}::{closure#2}, core[838cd329d32ba501]::result::Result<core[838cd329d32ba501]::option::Option<rustc_interface[27db4dcdd626da73]::queries::Linker>, rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>
  36:     0x7f6c9a312658 - rustc_span[506ca92461b63806]::with_source_map::<core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>, rustc_interface[27db4dcdd626da73]::interface::run_compiler<core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>, rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  37:     0x7f6c9a312145 - <scoped_tls[57eb591005101a44]::ScopedKey<rustc_span[506ca92461b63806]::SessionGlobals>>::set::<rustc_interface[27db4dcdd626da73]::interface::run_compiler<core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>, rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}>::{closure#0}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>
  38:     0x7f6c9a311732 - std[1a5a851d154403c1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[27db4dcdd626da73]::util::run_in_thread_pool_with_globals<rustc_interface[27db4dcdd626da73]::interface::run_compiler<core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>, rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}>::{closure#0}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>
  39:     0x7f6c9a99e82a - <<std[1a5a851d154403c1]::thread::Builder>::spawn_unchecked_<rustc_interface[27db4dcdd626da73]::util::run_in_thread_pool_with_globals<rustc_interface[27db4dcdd626da73]::interface::run_compiler<core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>, rustc_driver[b1659719c04a24c8]::run_compiler::{closure#1}>::{closure#0}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[838cd329d32ba501]::result::Result<(), rustc_errors[f3b4af3fda1898a3]::ErrorGuaranteed>>::{closure#1} as core[838cd329d32ba501]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f6c97dfadc3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8220a33137e05636
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/alloc/src/boxed.rs:2000:9
  41:     0x7f6c97dfadc3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcde99a22c299cd7f
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/alloc/src/boxed.rs:2000:9
  42:     0x7f6c97dfadc3 - std::sys::unix::thread::Thread::new::thread_start::h608d02a3e5faa1ee
                               at /rustc/8a97b4812a7a46bb5206487c2455b9c5bfcbd1b9/library/std/src/sys/unix/thread.rs:108:17
  43:     0x7f6c97cbf609 - start_thread
  44:     0x7f6c97be2133 - clone
  45:                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.68.0-nightly (8a97b4812 2022-12-22) running on x86_64-unknown-linux-gnu

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 [type_of] computing type of `<impl at src/lib.rs:5:1: 5:35>::{opaque#0}`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`

@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 Dec 23, 2022
@DutchGhost
Copy link
Contributor Author

DutchGhost commented Dec 23, 2022

Also ICE's on stable 1.66 and beta 1.67-beta.2.
A quick investigation on Godbolt concludes this ICE started in 1.61.0: https://godbolt.org/z/fMh3MG43T

@compiler-errors
Copy link
Member

compiler-errors commented Dec 23, 2022

This is a twofold problem:

  1. The associated type bound is getting lowered into Iterator<Item = impl Copy> -- however, that impl Copy should be universal (i.e. a type parameter), not existential (e.g. a RPIT/TAIT). It's being incorrectly lowered into the latter.
    • We don't actually support universal/APIT on impl blocks, but I wouldn't be surprised if it's not that hard to make this work...
  2. There's no validation for the places where associated type bounds are allowed. There are definitely some positions where it's just totally impossible to support these bounds.. there are some late-bound + assoc type bound combos that ought to be disallowed for now...

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-associated_type_bounds `#![feature(associated_type_bounds)]` glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants