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 with generic associated types and HRTBs #107409

Closed
moulins opened this issue Jan 28, 2023 · 0 comments · Fixed by #112422
Closed

ICE with generic associated types and HRTBs #107409

moulins opened this issue Jan 28, 2023 · 0 comments · Fixed by #112422
Labels
C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs 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

@moulins
Copy link
Contributor

moulins commented Jan 28, 2023

Got an ICE while experimenting with GATs:

use std::marker::PhantomData as Boo;

struct Gc<'gc, T: 'gc>(Boo<fn(&'gc T) -> &'gc T>);

trait Rootable<'env> {
    type AsRoot<'r>: Rootable<'r> + 'r where 'env: 'r;
}

impl<'env, T: Rootable<'env>> Rootable<'env> for Gc<'env, T> {
    type AsRoot<'r> = Gc<'r, T::AsRoot<'r>> where 'env: 'r;
}

impl<'env> Rootable<'env> for i32 {
    type AsRoot<'r> = i32 where 'env: 'r;
}

fn reroot<'gc, T: Rootable<'gc>>(_t: T, _f: for<'a> fn(T::AsRoot<'a>)) {
}

fn test<'gc>(t: Gc<'gc, i32>) {
    reroot(t, |_| ());
}

This crashes with the following error:

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:828:36: cannot convert `RePlaceholder(Placeholder { universe: U1, name: BrAnon(0, None) })` to a region vid

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/compiler/rustc_errors/src/lib.rs:1609:9
stack backtrace:
   0:     0x7fc1a3ccf36a - std::backtrace_rs::backtrace::libunwind::trace::heb3166a6cb1fd02b
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fc1a3ccf36a - std::backtrace_rs::backtrace::trace_unsynchronized::h34837841e045a1d4
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc1a3ccf36a - std::sys_common::backtrace::_print_fmt::h4348a4b63f328ee4
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fc1a3ccf36a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1bad440d01eeeb29
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fc1a3d3152e - core::fmt::write::hb5a073c651a6cb64
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/core/src/fmt/mod.rs:1232:17
   5:     0x7fc1a3cbf9b5 - std::io::Write::write_fmt::h97cc768331421fb2
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/io/mod.rs:1682:15
   6:     0x7fc1a3ccf135 - std::sys_common::backtrace::_print::h23bd93d6897965f3
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fc1a3ccf135 - std::sys_common::backtrace::print::h4d41ae33ce7a824f
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fc1a3cd1eff - std::panicking::default_hook::{{closure}}::h8ab48635107c713a
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/panicking.rs:267:22
   9:     0x7fc1a3cd1c3b - std::panicking::default_hook::h6305ca3c910e41d2
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/panicking.rs:286:9
  10:     0x7fc1a703e444 - rustc_driver[d1d90693eba3e117]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fc1a3cd273a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h60fe4dd8262b5528
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/alloc/src/boxed.rs:2002:9
  12:     0x7fc1a3cd273a - std::panicking::rust_panic_with_hook::ha8dfad8ee636a9a3
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/panicking.rs:692:13
  13:     0x7fc1a754dc21 - std[ef0604d174e11cd5]::panicking::begin_panic::<rustc_errors[6cf9ff966b0b62fb]::ExplicitBug>::{closure#0}
  14:     0x7fc1a754cad6 - std[ef0604d174e11cd5]::sys_common::backtrace::__rust_end_short_backtrace::<std[ef0604d174e11cd5]::panicking::begin_panic<rustc_errors[6cf9ff966b0b62fb]::ExplicitBug>::{closure#0}, !>
  15:     0x7fc1a75db2a6 - std[ef0604d174e11cd5]::panicking::begin_panic::<rustc_errors[6cf9ff966b0b62fb]::ExplicitBug>
  16:     0x7fc1a75909c6 - std[ef0604d174e11cd5]::panic::panic_any::<rustc_errors[6cf9ff966b0b62fb]::ExplicitBug>
  17:     0x7fc1a758b376 - <rustc_errors[6cf9ff966b0b62fb]::HandlerInner>::bug::<&alloc[9ea3c9e5c77b7621]::string::String>
  18:     0x7fc1a7589fd0 - <rustc_errors[6cf9ff966b0b62fb]::Handler>::bug::<&alloc[9ea3c9e5c77b7621]::string::String>
  19:     0x7fc1a759f4bb - rustc_middle[526e0ca739798ee2]::util::bug::opt_span_bug_fmt::<rustc_span[6b0f4bf036ac788e]::span_encoding::Span>::{closure#0}
  20:     0x7fc1a759f2ea - rustc_middle[526e0ca739798ee2]::ty::context::tls::with_opt::<rustc_middle[526e0ca739798ee2]::util::bug::opt_span_bug_fmt<rustc_span[6b0f4bf036ac788e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fc1a759f2ba - rustc_middle[526e0ca739798ee2]::ty::context::tls::with_context_opt::<rustc_middle[526e0ca739798ee2]::ty::context::tls::with_opt<rustc_middle[526e0ca739798ee2]::util::bug::opt_span_bug_fmt<rustc_span[6b0f4bf036ac788e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fc1a759f406 - rustc_middle[526e0ca739798ee2]::util::bug::opt_span_bug_fmt::<rustc_span[6b0f4bf036ac788e]::span_encoding::Span>
  23:     0x7fc1a52d57c3 - rustc_middle[526e0ca739798ee2]::util::bug::bug_fmt
  24:     0x7fc1a5f6f38e - <&mut <rustc_borrowck[2e52752a89f891f4]::type_check::free_region_relations::UniversalRegionRelationsBuilder>::create::{closure#0} as core[3a3cbeb512a16fa3]::ops::function::FnOnce<(rustc_middle[526e0ca739798ee2]::ty::Ty,)>>::call_once
  25:     0x7fc1a5f6e402 - <alloc[9ea3c9e5c77b7621]::vec::Vec<&rustc_middle[526e0ca739798ee2]::infer::canonical::QueryRegionConstraints> as alloc[9ea3c9e5c77b7621]::vec::spec_from_iter::SpecFromIter<&rustc_middle[526e0ca739798ee2]::infer::canonical::QueryRegionConstraints, core[3a3cbeb512a16fa3]::iter::adapters::flatten::FlatMap<core[3a3cbeb512a16fa3]::iter::adapters::chain::Chain<core[3a3cbeb512a16fa3]::iter::adapters::cloned::Cloned<core[3a3cbeb512a16fa3]::slice::iter::Iter<rustc_middle[526e0ca739798ee2]::ty::Ty>>, core[3a3cbeb512a16fa3]::option::IntoIter<rustc_middle[526e0ca739798ee2]::ty::Ty>>, core[3a3cbeb512a16fa3]::iter::adapters::chain::Chain<core[3a3cbeb512a16fa3]::iter::adapters::chain::Chain<core[3a3cbeb512a16fa3]::option::IntoIter<&rustc_middle[526e0ca739798ee2]::infer::canonical::QueryRegionConstraints>, core[3a3cbeb512a16fa3]::option::IntoIter<&rustc_middle[526e0ca739798ee2]::infer::canonical::QueryRegionConstraints>>, core[3a3cbeb512a16fa3]::option::IntoIter<&rustc_middle[526e0ca739798ee2]::infer::canonical::QueryRegionConstraints>>, <rustc_borrowck[2e52752a89f891f4]::type_check::free_region_relations::UniversalRegionRelationsBuilder>::create::{closure#0}>>>::from_iter
  26:     0x7fc1a5f69709 - rustc_borrowck[2e52752a89f891f4]::type_check::free_region_relations::create
  27:     0x7fc1a5f5480d - rustc_borrowck[2e52752a89f891f4]::nll::compute_regions
  28:     0x7fc1a5f23e5e - rustc_borrowck[2e52752a89f891f4]::do_mir_borrowck
  29:     0x7fc1a5f06f85 - rustc_borrowck[2e52752a89f891f4]::mir_borrowck
  30:     0x7fc1a582238d - rustc_query_system[decabb1eb79370b7]::query::plumbing::try_execute_query::<rustc_query_impl[ff3c18b748312d2f]::queries::mir_borrowck, rustc_query_impl[ff3c18b748312d2f]::plumbing::QueryCtxt>
  31:     0x7fc1a69f6c8d - <rustc_query_impl[ff3c18b748312d2f]::Queries as rustc_middle[526e0ca739798ee2]::ty::query::QueryEngine>::mir_borrowck
  32:     0x7fc1a6001124 - <rustc_borrowck[2e52752a89f891f4]::type_check::TypeChecker>::prove_closure_bounds
  33:     0x7fc1a5fdd78b - <rustc_borrowck[2e52752a89f891f4]::type_check::TypeChecker>::typeck_mir
  34:     0x7fc1a5f54b8d - rustc_borrowck[2e52752a89f891f4]::nll::compute_regions
  35:     0x7fc1a5f23e5e - rustc_borrowck[2e52752a89f891f4]::do_mir_borrowck
  36:     0x7fc1a5f06f85 - rustc_borrowck[2e52752a89f891f4]::mir_borrowck
  37:     0x7fc1a582238d - rustc_query_system[decabb1eb79370b7]::query::plumbing::try_execute_query::<rustc_query_impl[ff3c18b748312d2f]::queries::mir_borrowck, rustc_query_impl[ff3c18b748312d2f]::plumbing::QueryCtxt>
  38:     0x7fc1a568f5cd - rustc_data_structures[439cdbfa31de989]::sync::par_for_each_in::<&[rustc_span[6b0f4bf036ac788e]::def_id::LocalDefId], <rustc_middle[526e0ca739798ee2]::hir::map::Map>::par_body_owners<rustc_interface[d4b4ad1a0cb81775]::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  39:     0x7fc1a568f1d3 - <rustc_session[8c42e6c16859134b]::session::Session>::time::<(), rustc_interface[d4b4ad1a0cb81775]::passes::analysis::{closure#2}>
  40:     0x7fc1a568d2b7 - rustc_interface[d4b4ad1a0cb81775]::passes::analysis
  41:     0x7fc1a67c588e - rustc_query_system[decabb1eb79370b7]::query::plumbing::try_execute_query::<rustc_query_impl[ff3c18b748312d2f]::queries::analysis, rustc_query_impl[ff3c18b748312d2f]::plumbing::QueryCtxt>
  42:     0x7fc1a69ef64a - <rustc_query_impl[ff3c18b748312d2f]::Queries as rustc_middle[526e0ca739798ee2]::ty::query::QueryEngine>::analysis
  43:     0x7fc1a66f8a60 - <rustc_interface[d4b4ad1a0cb81775]::passes::QueryContext>::enter::<rustc_driver[d1d90693eba3e117]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>
  44:     0x7fc1a624a296 - rustc_span[6b0f4bf036ac788e]::with_source_map::<core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>, rustc_interface[d4b4ad1a0cb81775]::interface::run_compiler<core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>, rustc_driver[d1d90693eba3e117]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  45:     0x7fc1a6242654 - <scoped_tls[6607de7944b4e913]::ScopedKey<rustc_span[6b0f4bf036ac788e]::SessionGlobals>>::set::<rustc_interface[d4b4ad1a0cb81775]::interface::run_compiler<core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>, rustc_driver[d1d90693eba3e117]::run_compiler::{closure#1}>::{closure#0}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>
  46:     0x7fc1a6241d52 - std[ef0604d174e11cd5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d4b4ad1a0cb81775]::util::run_in_thread_pool_with_globals<rustc_interface[d4b4ad1a0cb81775]::interface::run_compiler<core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>, rustc_driver[d1d90693eba3e117]::run_compiler::{closure#1}>::{closure#0}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>
  47:     0x7fc1a6241afa - <<std[ef0604d174e11cd5]::thread::Builder>::spawn_unchecked_<rustc_interface[d4b4ad1a0cb81775]::util::run_in_thread_pool_with_globals<rustc_interface[d4b4ad1a0cb81775]::interface::run_compiler<core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>, rustc_driver[d1d90693eba3e117]::run_compiler::{closure#1}>::{closure#0}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a3cbeb512a16fa3]::result::Result<(), rustc_errors[6cf9ff966b0b62fb]::ErrorGuaranteed>>::{closure#1} as core[3a3cbeb512a16fa3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7fc1a3cdc803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9646bd6a135081c9
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/alloc/src/boxed.rs:1988:9
  49:     0x7fc1a3cdc803 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h180d98f11b902552
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/alloc/src/boxed.rs:1988:9
  50:     0x7fc1a3cdc803 - std::sys::unix::thread::Thread::new::thread_start::h83489d4028ebb6e1
                               at /rustc/ef982929c0b653436a6ea6892a2a839fba7c8b57/library/std/src/sys/unix/thread.rs:108:17
  51:     0x7fc1a3b9f609 - start_thread
  52:     0x7fc1a3ac2133 - clone
  53:                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.69.0-nightly (ef982929c 2023-01-27) 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 [mir_borrowck] borrow-checking `test::{closure#0}`
#1 [mir_borrowck] borrow-checking `test`
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`

Playground link

@moulins moulins added the C-bug Category: This is a bug. label Jan 28, 2023
@matthiaskrgr matthiaskrgr added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 28, 2023
@jackh726 jackh726 added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Jan 28, 2023
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 12, 2023
@Nilstrieb Nilstrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@bors bors closed this as completed in 4d7f952 Nov 17, 2023
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-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs 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.

5 participants