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: unexpected borrowck region with type_alias_impl_trait with lifetime #109054

Closed
SparkyPotato opened this issue Mar 12, 2023 · 2 comments · Fixed by #113164
Closed

ICE: unexpected borrowck region with type_alias_impl_trait with lifetime #109054

SparkyPotato opened this issue Mar 12, 2023 · 2 comments · Fixed by #113164
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SparkyPotato
Copy link
Contributor

SparkyPotato commented Mar 12, 2023

Code

#![feature(type_alias_impl_trait)]

struct call_me;

type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a;
type FnType = impl Fn(&u32) -> ReturnType;

impl std::ops::Deref for call_me {
    type Target = FnType;
    
    fn deref(&self) -> &Self::Target {
        fn inner(val: &u32) -> ReturnType {
            async move {
                *val * 2
            }
        }
    
        &inner
    }
}

Explicitly giving lifetimes to FnType with for<'a> FnOnce(&'a u32) -> ReturnType<'a> and doing the same on inner does not fix the ICE either.

Meta

Version rustc 1.70.0-nightly (8a73f50d8 2023-03-11)

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/opaque_types.rs:121:17: unexpected region kind in opaque type: RePlaceholder(Placeholder { universe: U3, name: BrNamed(DefId(0:15 ~ playground[419e]::FnType::{opaque#0}::'_), '_) })

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7f461097651a - std::backtrace_rs::backtrace::libunwind::trace::h8e11308176f74878
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f461097651a - std::backtrace_rs::backtrace::trace_unsynchronized::h08cc8e766dddc25f
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f461097651a - std::sys_common::backtrace::_print_fmt::h99c527e41798f0e9
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f461097651a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h79914c19e70ec78b
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f46109d9c5e - core::fmt::write::h667853c5e38f13ec
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f4610969275 - std::io::Write::write_fmt::hba0992fb471f923a
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/io/mod.rs:1684:15
   6:     0x7f46109762e5 - std::sys_common::backtrace::_print::h215545a75453f830
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f46109762e5 - std::sys_common::backtrace::print::hff9ee2dce3d2dcea
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f461097905f - std::panicking::default_hook::{{closure}}::h8fb87de14fa60e54
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/panicking.rs:271:22
   9:     0x7f4610978d9b - std::panicking::default_hook::h319d8219a84d729a
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/panicking.rs:290:9
  10:     0x7f4613c990d5 - <rustc_driver_impl[de28347a8abf8356]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[d9ef29759c2251a8]::ops::function::FnOnce<(&core[d9ef29759c2251a8]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f461097989d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hf7dd68431c765c20
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/alloc/src/boxed.rs:2002:9
  12:     0x7f461097989d - std::panicking::rust_panic_with_hook::h65b020dd76c4cd89
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/panicking.rs:696:13
  13:     0x7f4614204031 - std[bc2958bd9c820bb9]::panicking::begin_panic::<rustc_errors[24bb4dbb092f22f2]::ExplicitBug>::{closure#0}
  14:     0x7f46141ff766 - std[bc2958bd9c820bb9]::sys_common::backtrace::__rust_end_short_backtrace::<std[bc2958bd9c820bb9]::panicking::begin_panic<rustc_errors[24bb4dbb092f22f2]::ExplicitBug>::{closure#0}, !>
  15:     0x7f4614286ae6 - std[bc2958bd9c820bb9]::panicking::begin_panic::<rustc_errors[24bb4dbb092f22f2]::ExplicitBug>
  16:     0x7f4614252bd6 - std[bc2958bd9c820bb9]::panic::panic_any::<rustc_errors[24bb4dbb092f22f2]::ExplicitBug>
  17:     0x7f461424f456 - <rustc_errors[24bb4dbb092f22f2]::HandlerInner>::bug::<&alloc[66b6468aa09e7a1]::string::String>
  18:     0x7f461424f120 - <rustc_errors[24bb4dbb092f22f2]::Handler>::bug::<&alloc[66b6468aa09e7a1]::string::String>
  19:     0x7f461423b58b - rustc_middle[c2bebf1196c36ca]::util::bug::opt_span_bug_fmt::<rustc_span[67f48ae15a2a1ace]::span_encoding::Span>::{closure#0}
  20:     0x7f4614239fea - rustc_middle[c2bebf1196c36ca]::ty::context::tls::with_opt::<rustc_middle[c2bebf1196c36ca]::util::bug::opt_span_bug_fmt<rustc_span[67f48ae15a2a1ace]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f4614239fb6 - rustc_middle[c2bebf1196c36ca]::ty::context::tls::with_context_opt::<rustc_middle[c2bebf1196c36ca]::ty::context::tls::with_opt<rustc_middle[c2bebf1196c36ca]::util::bug::opt_span_bug_fmt<rustc_span[67f48ae15a2a1ace]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f461423b4d6 - rustc_middle[c2bebf1196c36ca]::util::bug::opt_span_bug_fmt::<rustc_span[67f48ae15a2a1ace]::span_encoding::Span>
  23:     0x7f4612243563 - rustc_middle[c2bebf1196c36ca]::util::bug::bug_fmt
  24:     0x7f4613287af6 - <rustc_middle[c2bebf1196c36ca]::ty::opaque_types::ReverseMapper as rustc_type_ir[99c45160e9dcd5d5]::fold::TypeFolder<rustc_middle[c2bebf1196c36ca]::ty::context::TyCtxt>>::fold_region
  25:     0x7f46131d26ff - <&rustc_middle[c2bebf1196c36ca]::ty::list::List<rustc_middle[c2bebf1196c36ca]::ty::subst::GenericArg> as rustc_type_ir[99c45160e9dcd5d5]::fold::TypeFoldable<rustc_middle[c2bebf1196c36ca]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[c2bebf1196c36ca]::ty::opaque_types::ReverseMapper>
  26:     0x7f46131d2359 - <rustc_middle[c2bebf1196c36ca]::ty::Ty as rustc_type_ir[99c45160e9dcd5d5]::fold::TypeSuperFoldable<rustc_middle[c2bebf1196c36ca]::ty::context::TyCtxt>>::super_fold_with::<rustc_middle[c2bebf1196c36ca]::ty::opaque_types::ReverseMapper>
  27:     0x7f46134a2d2c - <rustc_infer[d6af38f28f637c8d]::infer::InferCtxt as rustc_borrowck[b0ecc8244f8d9953]::region_infer::opaque_types::InferCtxtExt>::infer_opaque_definition_from_instantiation
  28:     0x7f4612689f8a - <rustc_borrowck[b0ecc8244f8d9953]::region_infer::RegionInferenceContext>::infer_opaque_types
  29:     0x7f4612682dba - rustc_borrowck[b0ecc8244f8d9953]::nll::compute_regions
  30:     0x7f4612652473 - rustc_borrowck[b0ecc8244f8d9953]::do_mir_borrowck
  31:     0x7f461264fb11 - <rustc_borrowck[b0ecc8244f8d9953]::provide::{closure#0} as core[d9ef29759c2251a8]::ops::function::FnOnce<(rustc_middle[c2bebf1196c36ca]::ty::context::TyCtxt, rustc_span[67f48ae15a2a1ace]::def_id::LocalDefId)>>::call_once
  32:     0x7f461264dc5d - rustc_query_system[bb54613dbf60299b]::query::plumbing::try_execute_query::<rustc_query_impl[6873813250a98cc1]::queries::mir_borrowck, rustc_query_impl[6873813250a98cc1]::plumbing::QueryCtxt>
  33:     0x7f461264d90a - <rustc_query_impl[6873813250a98cc1]::Queries as rustc_middle[c2bebf1196c36ca]::ty::query::QueryEngine>::mir_borrowck
  34:     0x7f4613e1d2c9 - <rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  35:     0x7f4613e1a7b2 - <rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir[3dffec1ee7877645]::intravisit::Visitor>::visit_nested_impl_item
  36:     0x7f4613df5bb6 - rustc_hir[3dffec1ee7877645]::intravisit::walk_item::<rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
  37:     0x7f4613e1a6dd - <rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir[3dffec1ee7877645]::intravisit::Visitor>::visit_nested_item
  38:     0x7f4613df3d78 - rustc_hir[3dffec1ee7877645]::intravisit::walk_mod::<rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
  39:     0x7f4613e1ca21 - rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::find_opaque_ty_constraints_for_tait
  40:     0x7f461318ada6 - rustc_hir_analysis[d31dbb230cf00630]::collect::type_of::type_of
  41:     0x7f461259ef80 - rustc_query_system[bb54613dbf60299b]::query::plumbing::try_execute_query::<rustc_query_impl[6873813250a98cc1]::queries::type_of, rustc_query_impl[6873813250a98cc1]::plumbing::QueryCtxt>
  42:     0x7f461259d90c - <rustc_query_impl[6873813250a98cc1]::Queries as rustc_middle[c2bebf1196c36ca]::ty::query::QueryEngine>::type_of
  43:     0x7f46127fb145 - rustc_hir_analysis[d31dbb230cf00630]::check::check::check_mod_item_types
  44:     0x7f46132c7ec5 - rustc_query_system[bb54613dbf60299b]::query::plumbing::try_execute_query::<rustc_query_impl[6873813250a98cc1]::queries::check_mod_item_types, rustc_query_impl[6873813250a98cc1]::plumbing::QueryCtxt>
  45:     0x7f46132c7a4a - <rustc_query_impl[6873813250a98cc1]::Queries as rustc_middle[c2bebf1196c36ca]::ty::query::QueryEngine>::check_mod_item_types
  46:     0x7f461202881d - <rustc_middle[c2bebf1196c36ca]::hir::map::Map>::for_each_module::<rustc_hir_analysis[d31dbb230cf00630]::check_crate::{closure#6}::{closure#0}>
  47:     0x7f4612025d98 - rustc_hir_analysis[d31dbb230cf00630]::check_crate
  48:     0x7f461201bcf2 - rustc_interface[50a97a4d78cc75fe]::passes::analysis
  49:     0x7f46134a6f7d - rustc_query_system[bb54613dbf60299b]::query::plumbing::try_execute_query::<rustc_query_impl[6873813250a98cc1]::queries::analysis, rustc_query_impl[6873813250a98cc1]::plumbing::QueryCtxt>
  50:     0x7f46134a6c7f - <rustc_query_impl[6873813250a98cc1]::Queries as rustc_middle[c2bebf1196c36ca]::ty::query::QueryEngine>::analysis
  51:     0x7f46132bc7b6 - <rustc_middle[c2bebf1196c36ca]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[de28347a8abf8356]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>>
  52:     0x7f4612ec9a28 - rustc_span[67f48ae15a2a1ace]::with_source_map::<core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>, rustc_interface[50a97a4d78cc75fe]::interface::run_compiler<core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>, rustc_driver_impl[de28347a8abf8356]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  53:     0x7f4612ec0bac - std[bc2958bd9c820bb9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[50a97a4d78cc75fe]::util::run_in_thread_pool_with_globals<rustc_interface[50a97a4d78cc75fe]::interface::run_compiler<core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>, rustc_driver_impl[de28347a8abf8356]::run_compiler::{closure#1}>::{closure#0}, core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>>
  54:     0x7f4612ec05da - <<std[bc2958bd9c820bb9]::thread::Builder>::spawn_unchecked_<rustc_interface[50a97a4d78cc75fe]::util::run_in_thread_pool_with_globals<rustc_interface[50a97a4d78cc75fe]::interface::run_compiler<core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>, rustc_driver_impl[de28347a8abf8356]::run_compiler::{closure#1}>::{closure#0}, core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ef29759c2251a8]::result::Result<(), rustc_span[67f48ae15a2a1ace]::ErrorGuaranteed>>::{closure#1} as core[d9ef29759c2251a8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  55:     0x7f4610983793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2be05930b084af35
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/alloc/src/boxed.rs:1988:9
  56:     0x7f4610983793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e27f2bce1de28fe
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/alloc/src/boxed.rs:1988:9
  57:     0x7f4610983793 - std::sys::unix::thread::Thread::new::thread_start::hce13d4cabe284bf1
                               at /rustc/8a73f50d875840b8077b8ec080fa41881d7ce40d/library/std/src/sys/unix/thread.rs:108:17
  58:     0x7f4610848609 - start_thread
  59:     0x7f461076b133 - clone
  60:                0x0 - <unknown>
@SparkyPotato SparkyPotato 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 Mar 12, 2023
@Noratrieb Noratrieb added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Mar 12, 2023
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 16, 2023
@langston-barrett
Copy link

@rustbot label +S-bug-has-mcve

@rustbot rustbot added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Mar 17, 2023
@JohnTitor
Copy link
Member

Triage: Fixed on the latest nightly, @rustbot labels: +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 24, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 5, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 6, 2023
…-errors

Add a regression test for rust-lang#109054

Closes rust-lang#109054
r? `@compiler-errors`
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 7, 2023
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#111917 (Simplify duplicate checks for mir validator)
 - rust-lang#112008 (Fix incorrect documented default bufsize in bufreader/writer)
 - rust-lang#112825 (Don't call `type_of` on TAIT in defining scope in new solver)
 - rust-lang#113164 (Add a regression test for rust-lang#109054)
 - rust-lang#113318 (Revert "alloc: Allow comparing Boxs over different allocators", add regression test)
 - rust-lang#113397 (Prefer object candidates in new selection)
 - rust-lang#113419 (Avoid calling item_name for RPITIT)
 - rust-lang#113421 (Do not assert >1 RPITITs on collect_return_position_impl_trait_in_trait_tys)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 1cb31e7 Jul 7, 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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

7 participants
@langston-barrett @JohnTitor @rustbot @Noratrieb @rust-lang-glacier-bot @SparkyPotato and others