Skip to content

yet another ICE with HRTB and RPIT #95647

Description

@WaffleLapkin

I tried this code:

trait Tr<T> {
    type Output;
}

impl<T> Tr<T> for () {
    type Output = T;
}

fn g() -> impl for<'a> Tr<&'a u8, Output = impl std::fmt::Debug + 'a> { }

(play)

I expected to see this happen: the code compiles.

Instead, this happened: ICE.

On stable this segfault because of a stackoverflow, but this was fixed by #94081. Now, on nightly (1.61.0-nightly (2022-04-03 6af09d2) this produces internal compiler error:

error: internal compiler error: compiler/rustc_trait_selection/src/opaque_types.rs:157:17: unexpected region kind in opaque type: RePlaceholder(Placeholder { universe: U2, name: BrNamed(DefId(0:11 ~ playground[302b]::g::{opaque#0}::'a), 'a) })

I've found this while working on #93582, this may be related to a similar ICE that I've found while testing it.

Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/opaque_types.rs:157:17: unexpected region kind in opaque type: RePlaceholder(Placeholder { universe: U2, name: BrNamed(DefId(0:11 ~ playground[302b]::g::{opaque#0}::'a), 'a) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1279:9
stack backtrace:
   0:     0x7f595c65a22d - std::backtrace_rs::backtrace::libunwind::trace::h35daaff92d098ed0
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f595c65a22d - std::backtrace_rs::backtrace::trace_unsynchronized::h2a49b328879f3c62
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f595c65a22d - std::sys_common::backtrace::_print_fmt::hbf865a25210831d9
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f595c65a22d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h320151e111e06ced
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f595c6b408c - core::fmt::write::h7413aa28bee1cfbc
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f595c64b781 - std::io::Write::write_fmt::h0e72b6ed17789afa
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/io/mod.rs:1655:15
   6:     0x7f595c65d315 - std::sys_common::backtrace::_print::h983440bc61c2f2c3
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f595c65d315 - std::sys_common::backtrace::print::ha1f03110bb78cc22
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f595c65d315 - std::panicking::default_hook::{{closure}}::heffa35a5a8b52a05
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:295:22
   9:     0x7f595c65cfc9 - std::panicking::default_hook::h7c0cbeac47c399c7
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:314:9
  10:     0x7f595cddaa41 - rustc_driver[76d125f389222871]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f595c65da60 - std::panicking::rust_panic_with_hook::hffbd90fcd9b72f27
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:702:17
  12:     0x7f595deacb71 - std[bd2101aea7a2ace9]::panicking::begin_panic::<rustc_errors[bd5cb8d9692a92d1]::ExplicitBug>::{closure#0}
  13:     0x7f595deac8d6 - std[bd2101aea7a2ace9]::sys_common::backtrace::__rust_end_short_backtrace::<std[bd2101aea7a2ace9]::panicking::begin_panic<rustc_errors[bd5cb8d9692a92d1]::ExplicitBug>::{closure#0}, !>
  14:     0x7f595deb3e2f - std[bd2101aea7a2ace9]::panicking::begin_panic::<rustc_errors[bd5cb8d9692a92d1]::ExplicitBug>
  15:     0x7f595dec0906 - std[bd2101aea7a2ace9]::panic::panic_any::<rustc_errors[bd5cb8d9692a92d1]::ExplicitBug>
  16:     0x7f595dec20e3 - <rustc_errors[bd5cb8d9692a92d1]::HandlerInner>::bug
  17:     0x7f595dec1b40 - <rustc_errors[bd5cb8d9692a92d1]::Handler>::bug
  18:     0x7f595de01176 - rustc_middle[fbba0f33d4f9946e]::ty::context::tls::with_opt::<rustc_middle[fbba0f33d4f9946e]::util::bug::opt_span_bug_fmt<rustc_span[ee8a23fea69ba3d2]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7f595de041e6 - rustc_middle[fbba0f33d4f9946e]::util::bug::opt_span_bug_fmt::<rustc_span[ee8a23fea69ba3d2]::span_encoding::Span>
  20:     0x7f595de04153 - rustc_middle[fbba0f33d4f9946e]::util::bug::bug_fmt
  21:     0x7f595f4b5757 - <rustc_trait_selection[d5079ddefe3ebc30]::opaque_types::ReverseMapper as rustc_middle[fbba0f33d4f9946e]::ty::fold::TypeFolder>::fold_region
  22:     0x7f595f4aa90b - <rustc_middle[fbba0f33d4f9946e]::ty::Ty as rustc_middle[fbba0f33d4f9946e]::ty::fold::TypeFoldable>::super_fold_with::<rustc_trait_selection[d5079ddefe3ebc30]::opaque_types::ReverseMapper>
  23:     0x7f595f475457 - <rustc_infer[ed960bf4336cfb6a]::infer::InferCtxt as rustc_trait_selection[d5079ddefe3ebc30]::opaque_types::InferCtxtExt>::infer_opaque_definition_from_instantiation
  24:     0x7f595f0b4b10 - <rustc_borrowck[c1d826d90d372c4a]::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}
  25:     0x7f595e4c73e1 - rustc_borrowck[c1d826d90d372c4a]::nll::compute_regions
  26:     0x7f595e585bf6 - rustc_borrowck[c1d826d90d372c4a]::do_mir_borrowck
  27:     0x7f595e57a579 - rustc_borrowck[c1d826d90d372c4a]::mir_borrowck
  28:     0x7f595e577210 - <rustc_borrowck[c1d826d90d372c4a]::provide::{closure#0} as core[48b87fce6ec407e9]::ops::function::FnOnce<(rustc_middle[fbba0f33d4f9946e]::ty::context::TyCtxt, rustc_span[ee8a23fea69ba3d2]::def_id::LocalDefId)>>::call_once
  29:     0x7f595e70cb61 - rustc_query_system[951f4c75552d1d3a]::query::plumbing::try_execute_query::<rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt, rustc_query_system[951f4c75552d1d3a]::query::caches::DefaultCache<rustc_span[ee8a23fea69ba3d2]::def_id::LocalDefId, &rustc_middle[fbba0f33d4f9946e]::mir::query::BorrowCheckResult>>
  30:     0x7f595e7f0dfa - <rustc_query_impl[fe5829773555cd6b]::Queries as rustc_middle[fbba0f33d4f9946e]::ty::query::QueryEngine>::mir_borrowck
  31:     0x7f595e2d100e - rustc_typeck[4d7f983240b49f12]::collect::type_of::type_of
  32:     0x7f595e74f30e - rustc_query_system[951f4c75552d1d3a]::query::plumbing::get_query::<rustc_query_impl[fe5829773555cd6b]::queries::type_of, rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt>
  33:     0x7f595e2e1ceb - rustc_typeck[4d7f983240b49f12]::check::check::check_item_type
  34:     0x7f595e2c18eb - <rustc_middle[fbba0f33d4f9946e]::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck[4d7f983240b49f12]::check::CheckItemTypesVisitor>
  35:     0x7f595efcbfec - rustc_typeck[4d7f983240b49f12]::check::check::check_mod_item_types
  36:     0x7f595e70eb7e - rustc_query_system[951f4c75552d1d3a]::query::plumbing::try_execute_query::<rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt, rustc_query_system[951f4c75552d1d3a]::query::caches::DefaultCache<rustc_span[ee8a23fea69ba3d2]::def_id::LocalDefId, ()>>
  37:     0x7f595f1e3763 - rustc_query_system[951f4c75552d1d3a]::query::plumbing::get_query::<rustc_query_impl[fe5829773555cd6b]::queries::check_mod_item_types, rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt>
  38:     0x7f595efac10c - <rustc_middle[fbba0f33d4f9946e]::hir::map::Map>::for_each_module::<rustc_typeck[4d7f983240b49f12]::check_crate::{closure#6}::{closure#0}>
  39:     0x7f595ef7aa18 - <rustc_session[4c620bd5685dfc65]::session::Session>::time::<(), rustc_typeck[4d7f983240b49f12]::check_crate::{closure#6}>
  40:     0x7f595ef6d478 - rustc_typeck[4d7f983240b49f12]::check_crate
  41:     0x7f595ecebd77 - rustc_interface[3efeb2cf171df459]::passes::analysis
  42:     0x7f595f1af25e - rustc_query_system[951f4c75552d1d3a]::query::plumbing::try_execute_query::<rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt, rustc_query_system[951f4c75552d1d3a]::query::caches::DefaultCache<(), core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>>
  43:     0x7f595f1f240e - rustc_query_system[951f4c75552d1d3a]::query::plumbing::get_query::<rustc_query_impl[fe5829773555cd6b]::queries::analysis, rustc_query_impl[fe5829773555cd6b]::plumbing::QueryCtxt>
  44:     0x7f595ecb1af1 - <rustc_interface[3efeb2cf171df459]::passes::QueryContext>::enter::<rustc_driver[76d125f389222871]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>
  45:     0x7f595eccbcb8 - <rustc_interface[3efeb2cf171df459]::interface::Compiler>::enter::<rustc_driver[76d125f389222871]::run_compiler::{closure#1}::{closure#2}, core[48b87fce6ec407e9]::result::Result<core[48b87fce6ec407e9]::option::Option<rustc_interface[3efeb2cf171df459]::queries::Linker>, rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>
  46:     0x7f595ecb12af - rustc_span[ee8a23fea69ba3d2]::with_source_map::<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_interface[3efeb2cf171df459]::interface::create_compiler_and_run<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_driver[76d125f389222871]::run_compiler::{closure#1}>::{closure#1}>
  47:     0x7f595eccc8f4 - rustc_interface[3efeb2cf171df459]::interface::create_compiler_and_run::<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_driver[76d125f389222871]::run_compiler::{closure#1}>
  48:     0x7f595ecafa42 - <scoped_tls[57a9157413d11ba7]::ScopedKey<rustc_span[ee8a23fea69ba3d2]::SessionGlobals>>::set::<rustc_interface[3efeb2cf171df459]::interface::run_compiler<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_driver[76d125f389222871]::run_compiler::{closure#1}>::{closure#0}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>
  49:     0x7f595ecc55ef - std[bd2101aea7a2ace9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3efeb2cf171df459]::util::run_in_thread_pool_with_globals<rustc_interface[3efeb2cf171df459]::interface::run_compiler<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_driver[76d125f389222871]::run_compiler::{closure#1}>::{closure#0}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>::{closure#0}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>
  50:     0x7f595ecb0d69 - <<std[bd2101aea7a2ace9]::thread::Builder>::spawn_unchecked_<rustc_interface[3efeb2cf171df459]::util::run_in_thread_pool_with_globals<rustc_interface[3efeb2cf171df459]::interface::run_compiler<core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>, rustc_driver[76d125f389222871]::run_compiler::{closure#1}>::{closure#0}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>::{closure#0}, core[48b87fce6ec407e9]::result::Result<(), rustc_errors[bd5cb8d9692a92d1]::ErrorGuaranteed>>::{closure#1} as core[48b87fce6ec407e9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f595c667c53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h899a6206a2507bd0
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/alloc/src/boxed.rs:1861:9
  52:     0x7f595c667c53 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd62269684d9bd73e
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/alloc/src/boxed.rs:1861:9
  53:     0x7f595c667c53 - std::sys::unix::thread::Thread::new::thread_start::h7ef91fa8e493bb6e
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f595c597609 - start_thread
  55:     0x7f595c4b0163 - clone
  56:                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.61.0-nightly (6af09d250 2022-04-03) 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 `g`
#1 [type_of] computing type of `g::{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

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.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions