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 GAT + higher-ranked TAIT #97098

Closed
Dirbaio opened this issue May 17, 2022 · 2 comments · Fixed by #113575
Closed

ICE with GAT + higher-ranked TAIT #97098

Dirbaio opened this issue May 17, 2022 · 2 comments · Fixed by #113575
Assignees
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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

@Dirbaio
Copy link
Contributor

Dirbaio commented May 17, 2022

playground

#![feature(type_alias_impl_trait)]
#![feature(generic_associated_types)]

pub trait Trait {
    type Assoc<'a>;
}

pub type Foo = impl for<'a> Trait<Assoc<'a> = FooAssoc<'a>>;
pub type FooAssoc<'a> = impl Sized;

struct Struct;
impl Trait for Struct {
    type Assoc<'a> = &'a u32;
}

const FOO: Foo = Struct;
error: internal compiler error: compiler/rustc_trait_selection/src/opaque_types.rs:326:17: unexpected region kind in opaque type: RePlaceholder(Placeholder { universe: U1, name: BrNamed(DefId(0:8 ~ playground[9145]::Foo::{opaque#0}::'a), 'a) })

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/compiler/rustc_errors/src/lib.rs:1335:9
stack backtrace:
   0:     0x7f5f8516ff8d - std::backtrace_rs::backtrace::libunwind::trace::h67b1c8cf8ce320d0
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5f8516ff8d - std::backtrace_rs::backtrace::trace_unsynchronized::hd715d6ee36d01457
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5f8516ff8d - std::sys_common::backtrace::_print_fmt::h86f2d6902c17b72b
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f5f8516ff8d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2f28719fc9d49991
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f5f851cbc1c - core::fmt::write::h58d80b2387526c14
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f5f85161661 - std::io::Write::write_fmt::h51e24b646b1d9dea
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/io/mod.rs:1654:15
   6:     0x7f5f85172ca5 - std::sys_common::backtrace::_print::h08306e60302c2601
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f5f85172ca5 - std::sys_common::backtrace::print::h8bee5b1ce7ed0828
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f5f85172ca5 - std::panicking::default_hook::{{closure}}::h0135f80d264aa3cb
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/panicking.rs:295:22
   9:     0x7f5f85172919 - std::panicking::default_hook::haf57ee52e612f636
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/panicking.rs:314:9
  10:     0x7f5f85938b21 - rustc_driver[52a5108fb431eaec]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f5f85173476 - std::panicking::rust_panic_with_hook::h4cd397120086e208
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/panicking.rs:702:17
  12:     0x7f5f869c26a1 - std[6756e547c62c76a1]::panicking::begin_panic::<rustc_errors[a3b3cd9ac4cd0404]::ExplicitBug>::{closure#0}
  13:     0x7f5f869bc886 - std[6756e547c62c76a1]::sys_common::backtrace::__rust_end_short_backtrace::<std[6756e547c62c76a1]::panicking::begin_panic<rustc_errors[a3b3cd9ac4cd0404]::ExplicitBug>::{closure#0}, !>
  14:     0x7f5f86951aa6 - std[6756e547c62c76a1]::panicking::begin_panic::<rustc_errors[a3b3cd9ac4cd0404]::ExplicitBug>
  15:     0x7f5f86907306 - std[6756e547c62c76a1]::panic::panic_any::<rustc_errors[a3b3cd9ac4cd0404]::ExplicitBug>
  16:     0x7f5f86903575 - <rustc_errors[a3b3cd9ac4cd0404]::HandlerInner>::bug::<&alloc[37b6f05715a7cc80]::string::String>
  17:     0x7f5f86902f80 - <rustc_errors[a3b3cd9ac4cd0404]::Handler>::bug::<&alloc[37b6f05715a7cc80]::string::String>
  18:     0x7f5f869cb05d - rustc_middle[98c7c48ec55f2d30]::ty::context::tls::with_opt::<rustc_middle[98c7c48ec55f2d30]::util::bug::opt_span_bug_fmt<rustc_span[6ccf8f5ca5317a27]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7f5f869cb3d6 - rustc_middle[98c7c48ec55f2d30]::util::bug::opt_span_bug_fmt::<rustc_span[6ccf8f5ca5317a27]::span_encoding::Span>
  20:     0x7f5f869cb353 - rustc_middle[98c7c48ec55f2d30]::util::bug::bug_fmt
  21:     0x7f5f88183fd2 - <rustc_trait_selection[6e50549df9c71920]::opaque_types::ReverseMapper as rustc_middle[98c7c48ec55f2d30]::ty::fold::TypeFolder>::fold_region
  22:     0x7f5f88188465 - <rustc_middle[98c7c48ec55f2d30]::ty::Ty as rustc_middle[98c7c48ec55f2d30]::ty::fold::TypeFoldable>::super_fold_with::<rustc_trait_selection[6e50549df9c71920]::opaque_types::ReverseMapper>
  23:     0x7f5f881542fe - <rustc_infer[91e6494644033aa9]::infer::InferCtxt as rustc_trait_selection[6e50549df9c71920]::opaque_types::InferCtxtExt>::infer_opaque_definition_from_instantiation
  24:     0x7f5f872199f0 - <rustc_borrowck[7ebf6aea16ae1e27]::region_infer::RegionInferenceContext>::infer_opaque_types
  25:     0x7f5f871830f4 - rustc_borrowck[7ebf6aea16ae1e27]::nll::compute_regions
  26:     0x7f5f871eea2e - rustc_borrowck[7ebf6aea16ae1e27]::do_mir_borrowck
  27:     0x7f5f871e76b9 - rustc_borrowck[7ebf6aea16ae1e27]::mir_borrowck
  28:     0x7f5f871e4420 - <rustc_borrowck[7ebf6aea16ae1e27]::provide::{closure#0} as core[696ac347caa2bd44]::ops::function::FnOnce<(rustc_middle[98c7c48ec55f2d30]::ty::context::TyCtxt, rustc_span[6ccf8f5ca5317a27]::def_id::LocalDefId)>>::call_once
  29:     0x7f5f87414d50 - rustc_query_system[202e2af03b29f868]::query::plumbing::try_execute_query::<rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt, rustc_query_system[202e2af03b29f868]::query::caches::DefaultCache<rustc_span[6ccf8f5ca5317a27]::def_id::LocalDefId, &rustc_middle[98c7c48ec55f2d30]::mir::query::BorrowCheckResult>>
  30:     0x7f5f873dfeea - <rustc_query_impl[571ef98d1fbb149a]::Queries as rustc_middle[98c7c48ec55f2d30]::ty::query::QueryEngine>::mir_borrowck
  31:     0x7f5f85d2ea50 - <rustc_typeck[bf5d8a66ba319940]::collect::type_of::find_opaque_ty_constraints::ConstraintLocator>::check
  32:     0x7f5f85d2e5b8 - <rustc_typeck[bf5d8a66ba319940]::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir[c624ea387cefbc39]::intravisit::Visitor>::visit_item
  33:     0x7f5f85d2aed5 - <rustc_typeck[bf5d8a66ba319940]::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir[c624ea387cefbc39]::intravisit::Visitor>::visit_nested_item
  34:     0x7f5f85c55c57 - rustc_hir[c624ea387cefbc39]::intravisit::walk_mod::<rustc_typeck[bf5d8a66ba319940]::collect::type_of::find_opaque_ty_constraints::ConstraintLocator>
  35:     0x7f5f85d2e300 - rustc_typeck[bf5d8a66ba319940]::collect::type_of::find_opaque_ty_constraints
  36:     0x7f5f86f32bb2 - rustc_typeck[bf5d8a66ba319940]::collect::type_of::type_of
  37:     0x7f5f8745b517 - rustc_query_system[202e2af03b29f868]::query::plumbing::get_query::<rustc_query_impl[571ef98d1fbb149a]::queries::type_of, rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt>
  38:     0x7f5f86f3bc95 - rustc_typeck[bf5d8a66ba319940]::check::check::check_item_type
  39:     0x7f5f86f411fb - rustc_typeck[bf5d8a66ba319940]::check::check::check_mod_item_types
  40:     0x7f5f87416d70 - rustc_query_system[202e2af03b29f868]::query::plumbing::try_execute_query::<rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt, rustc_query_system[202e2af03b29f868]::query::caches::DefaultCache<rustc_span[6ccf8f5ca5317a27]::def_id::LocalDefId, ()>>
  41:     0x7f5f87f6aae3 - rustc_query_system[202e2af03b29f868]::query::plumbing::get_query::<rustc_query_impl[571ef98d1fbb149a]::queries::check_mod_item_types, rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt>
  42:     0x7f5f87c8685d - <rustc_middle[98c7c48ec55f2d30]::hir::map::Map>::for_each_module::<rustc_typeck[bf5d8a66ba319940]::check_crate::{closure#6}::{closure#0}>
  43:     0x7f5f87c64668 - <rustc_session[abce4e7f97e3a707]::session::Session>::time::<(), rustc_typeck[bf5d8a66ba319940]::check_crate::{closure#6}>
  44:     0x7f5f87c4ce68 - rustc_typeck[bf5d8a66ba319940]::check_crate
  45:     0x7f5f879e6e87 - rustc_interface[f634dffaf1f1ed4]::passes::analysis
  46:     0x7f5f87f38574 - rustc_query_system[202e2af03b29f868]::query::plumbing::try_execute_query::<rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt, rustc_query_system[202e2af03b29f868]::query::caches::DefaultCache<(), core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>>
  47:     0x7f5f87f79c7e - rustc_query_system[202e2af03b29f868]::query::plumbing::get_query::<rustc_query_impl[571ef98d1fbb149a]::queries::analysis, rustc_query_impl[571ef98d1fbb149a]::plumbing::QueryCtxt>
  48:     0x7f5f879c78e7 - <rustc_interface[f634dffaf1f1ed4]::passes::QueryContext>::enter::<rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>
  49:     0x7f5f879b2938 - <rustc_interface[f634dffaf1f1ed4]::interface::Compiler>::enter::<rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}::{closure#2}, core[696ac347caa2bd44]::result::Result<core[696ac347caa2bd44]::option::Option<rustc_interface[f634dffaf1f1ed4]::queries::Linker>, rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>
  50:     0x7f5f879db02f - rustc_span[6ccf8f5ca5317a27]::with_source_map::<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_interface[f634dffaf1f1ed4]::interface::create_compiler_and_run<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}>::{closure#1}>
  51:     0x7f5f879b35a4 - rustc_interface[f634dffaf1f1ed4]::interface::create_compiler_and_run::<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}>
  52:     0x7f5f879b0e42 - <scoped_tls[5bcfd69aea41704b]::ScopedKey<rustc_span[6ccf8f5ca5317a27]::SessionGlobals>>::set::<rustc_interface[f634dffaf1f1ed4]::interface::run_compiler<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}>::{closure#0}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>
  53:     0x7f5f879c7f6f - std[6756e547c62c76a1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f634dffaf1f1ed4]::util::run_in_thread_pool_with_globals<rustc_interface[f634dffaf1f1ed4]::interface::run_compiler<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}>::{closure#0}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>::{closure#0}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>
  54:     0x7f5f879c80a9 - <<std[6756e547c62c76a1]::thread::Builder>::spawn_unchecked_<rustc_interface[f634dffaf1f1ed4]::util::run_in_thread_pool_with_globals<rustc_interface[f634dffaf1f1ed4]::interface::run_compiler<core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>, rustc_driver[52a5108fb431eaec]::run_compiler::{closure#1}>::{closure#0}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>::{closure#0}, core[696ac347caa2bd44]::result::Result<(), rustc_errors[a3b3cd9ac4cd0404]::ErrorGuaranteed>>::{closure#1} as core[696ac347caa2bd44]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  55:     0x7f5f8517d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h14e46baa6d22d347
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/alloc/src/boxed.rs:1872:9
  56:     0x7f5f8517d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6ebfb42aa2b9da7a
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/alloc/src/boxed.rs:1872:9
  57:     0x7f5f8517d393 - std::sys::unix::thread::Thread::new::thread_start::hff1811d6a35504cb
                               at /rustc/42e1761c704f074b7b8c7ff8a7433acfd65d2ee9/library/std/src/sys/unix/thread.rs:108:17
  58:     0x7f5f850ad609 - start_thread
  59:     0x7f5f84fc6133 - clone
  60:                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.63.0-nightly (42e1761c7 2022-05-15) 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 `FOO`
#1 [type_of] computing type of `Foo::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack

rustc 1.63.0-nightly (42e1761 2022-05-15)

@aliemjay
Copy link
Member

aliemjay commented May 17, 2022

Related to #96146

@rustbot label F-type_alias_impl_trait C-bug T-compiler

@rustbot claim

@rustbot rustbot added C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 17, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Jun 25, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 25, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Dec 19, 2022

The current error is

thread 'rustc' panicked at 'assertion failed: self.scc_universes[scc] == ty::UniverseIndex::ROOT', compiler/rustc_borrowck/src/region_infer/mod.rs:710:9

So this is probably the same cause as #99945 (higher ranked TAITs are just broken)

@matthiaskrgr matthiaskrgr added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 27, 2023
@bors bors closed this as completed in 03181e0 Aug 4, 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-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` 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.
6 participants