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 region kind in opaque type #122694

Closed
matthiaskrgr opened this issue Mar 18, 2024 · 2 comments · Fixed by #122733
Closed

ICE: unexpected region kind in opaque type #122694

matthiaskrgr opened this issue Mar 18, 2024 · 2 comments · Fixed by #122733
Assignees
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 18, 2024

auto-reduced (treereduce-rust):

#![feature(type_alias_impl_trait)]
use std::future::Future;

type FutNothing<'a> = impl 'a + Future<Output = ()>;

async fn operation(_: &mut ()) -> () {
    call(operation).await
}

async fn call<F>(_f: F)
where
    for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>,
{
}

original:

#![feature(type_alias_impl_trait)]

use std::future::Future;

type FutNothing<'a> = impl 'a + Future<Output = ()>;

async fn operation(x: &mut ()) -> () {
    call(operation).await
}

async fn indirect() {
    call(operation).await
}

async fn call<F>(mut f: F)
where
    for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>,
{
    f(&mut ()).await
}

Version information

rustc 1.79.0-nightly (3cdcdaf31 2024-03-18)
binary: rustc
commit-hash: 3cdcdaf31b45f8045164aae9604573d23091970b
commit-date: 2024-03-18
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:3:23
  |
3 | type FutNothing<'a> = impl 'a + Future<Output = ()>;
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2024-03-18; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs`

error: unconstrained opaque type
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:3:23
  |
3 | type FutNothing<'a> = impl 'a + Future<Output = ()>;
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `FutNothing` must be used in combination with a concrete type within the same module

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:5:20
  |
5 | async fn operation(x: &mut ()) -> () {
  |                    ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_middle/src/ty/opaque_types.rs:122:17: unexpected region kind in opaque type: RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:10 ~ mvce[abe4]::call::'any), 'any) })

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7fb5fd58bfa5 - std::backtrace_rs::backtrace::libunwind::trace::h14c26439c9e659cb
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7fb5fd58bfa5 - std::backtrace_rs::backtrace::trace_unsynchronized::h44d92edd05bbbfda
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb5fd58bfa5 - std::sys_common::backtrace::_print_fmt::h13f1beea5570cb83
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb5fd58bfa5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb8ca44e969e3f71b
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb5fd5dcfeb - core::fmt::rt::Argument::fmt::h5c946a89981df55e
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb5fd5dcfeb - core::fmt::write::hd586e7360777cc96
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/core/src/fmt/mod.rs:1153:17
   6:     0x7fb5fd580cbf - std::io::Write::write_fmt::h710cbd7bbf99ccca
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/io/mod.rs:1843:15
   7:     0x7fb5fd58bd7e - std::sys_common::backtrace::_print::hf1afff5c335e465f
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb5fd58bd7e - std::sys_common::backtrace::print::he54a51a147efc885
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb5fd58e9f9 - std::panicking::default_hook::{{closure}}::hcd08c4e3ffa464ca
  10:     0x7fb5fd58e763 - std::panicking::default_hook::h2663042b363aa298
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/panicking.rs:292:9
  11:     0x7fb6005ba58f - std[f1ab4ce7166604a0]::panicking::update_hook::<alloc[ef09d9835563b69e]::boxed::Box<rustc_driver_impl[76e846938966200a]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb5fd58f150 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcd6186c20f61b1dd
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/alloc/src/boxed.rs:2034:9
  13:     0x7fb5fd58f150 - std::panicking::rust_panic_with_hook::h2a6da5de52d72055
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/panicking.rs:783:13
  14:     0x7fb6005e6a54 - std[f1ab4ce7166604a0]::panicking::begin_panic::<rustc_errors[c906f5c4cf1f88ae]::ExplicitBug>::{closure#0}
  15:     0x7fb6005e3976 - std[f1ab4ce7166604a0]::sys_common::backtrace::__rust_end_short_backtrace::<std[f1ab4ce7166604a0]::panicking::begin_panic<rustc_errors[c906f5c4cf1f88ae]::ExplicitBug>::{closure#0}, !>
  16:     0x7fb6005e3656 - std[f1ab4ce7166604a0]::panicking::begin_panic::<rustc_errors[c906f5c4cf1f88ae]::ExplicitBug>
  17:     0x7fb6005efed1 - <rustc_errors[c906f5c4cf1f88ae]::diagnostic::BugAbort as rustc_errors[c906f5c4cf1f88ae]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fb600a75b91 - rustc_middle[712e48954d6afe8b]::util::bug::opt_span_bug_fmt::<rustc_span[74819862fbf5924e]::span_encoding::Span>::{closure#0}
  19:     0x7fb600a58ffa - rustc_middle[712e48954d6afe8b]::ty::context::tls::with_opt::<rustc_middle[712e48954d6afe8b]::util::bug::opt_span_bug_fmt<rustc_span[74819862fbf5924e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7fb600a58e98 - rustc_middle[712e48954d6afe8b]::ty::context::tls::with_context_opt::<rustc_middle[712e48954d6afe8b]::ty::context::tls::with_opt<rustc_middle[712e48954d6afe8b]::util::bug::opt_span_bug_fmt<rustc_span[74819862fbf5924e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7fb5fe79c5a0 - rustc_middle[712e48954d6afe8b]::util::bug::bug_fmt
  22:     0x7fb6025aba13 - <rustc_middle[712e48954d6afe8b]::ty::opaque_types::ReverseMapper as rustc_type_ir[ce90e5ef7eb5dee5]::fold::TypeFolder<rustc_middle[712e48954d6afe8b]::ty::context::TyCtxt>>::fold_region
  23:     0x7fb6025aa9c3 - <&rustc_middle[712e48954d6afe8b]::ty::list::List<rustc_middle[712e48954d6afe8b]::ty::generic_args::GenericArg> as rustc_type_ir[ce90e5ef7eb5dee5]::fold::TypeFoldable<rustc_middle[712e48954d6afe8b]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[712e48954d6afe8b]::ty::opaque_types::ReverseMapper>
  24:     0x7fb6025ab023 - <rustc_middle[712e48954d6afe8b]::ty::opaque_types::ReverseMapper as rustc_type_ir[ce90e5ef7eb5dee5]::fold::TypeFolder<rustc_middle[712e48954d6afe8b]::ty::context::TyCtxt>>::fold_ty
  25:     0x7fb6025aa13d - <rustc_middle[712e48954d6afe8b]::ty::OpaqueHiddenType>::remap_generic_params_to_declaration_params
  26:     0x7fb6025a8b45 - <rustc_infer[49b3e6d6e2d70b3c]::infer::InferCtxt as rustc_borrowck[5b2dcb3cbda17836]::region_infer::opaque_types::InferCtxtExt>::infer_opaque_definition_from_instantiation
  27:     0x7fb5ff0c2ad2 - rustc_borrowck[5b2dcb3cbda17836]::nll::compute_regions
  28:     0x7fb6027e1b6f - rustc_borrowck[5b2dcb3cbda17836]::do_mir_borrowck
  29:     0x7fb601be19e6 - rustc_borrowck[5b2dcb3cbda17836]::mir_borrowck
  30:     0x7fb601be14d7 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>
  31:     0x7fb601be34ee - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::VecCache<rustc_span[74819862fbf5924e]::def_id::LocalDefId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  32:     0x7fb601be300c - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7fb60237f11c - rustc_middle[712e48954d6afe8b]::query::plumbing::query_get_at::<rustc_query_system[7897cb83f5f0e4a4]::query::caches::VecCache<rustc_span[74819862fbf5924e]::def_id::LocalDefId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>>
  34:     0x7fb60237f18e - <rustc_borrowck[5b2dcb3cbda17836]::type_check::TypeChecker>::prove_closure_bounds
  35:     0x7fb601d2cd1a - <rustc_borrowck[5b2dcb3cbda17836]::type_check::TypeChecker>::typeck_mir
  36:     0x7fb5ff078e6a - rustc_borrowck[5b2dcb3cbda17836]::type_check::type_check
  37:     0x7fb5ff0b2ac7 - rustc_borrowck[5b2dcb3cbda17836]::nll::compute_regions
  38:     0x7fb6027e1b6f - rustc_borrowck[5b2dcb3cbda17836]::do_mir_borrowck
  39:     0x7fb601be19e6 - rustc_borrowck[5b2dcb3cbda17836]::mir_borrowck
  40:     0x7fb601be14d7 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>
  41:     0x7fb601be34ee - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::VecCache<rustc_span[74819862fbf5924e]::def_id::LocalDefId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  42:     0x7fb601be300c - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7fb60229f7b9 - rustc_middle[712e48954d6afe8b]::query::plumbing::query_get_at::<rustc_query_system[7897cb83f5f0e4a4]::query::caches::VecCache<rustc_span[74819862fbf5924e]::def_id::LocalDefId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>>
  44:     0x7fb6022999ad - rustc_hir_analysis[1e7a6b85d58e7e91]::collect::type_of::type_of_opaque
  45:     0x7fb602299837 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>
  46:     0x7fb6018ef699 - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::DefIdCache<rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  47:     0x7fb6027bbd5e - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7fb601e87956 - rustc_middle[712e48954d6afe8b]::query::plumbing::query_get_at::<rustc_query_system[7897cb83f5f0e4a4]::query::caches::DefIdCache<rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>>
  49:     0x7fb5ff60471c - rustc_hir_analysis[1e7a6b85d58e7e91]::collect::type_of::type_of
  50:     0x7fb6018f0a62 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>
  51:     0x7fb6018ef699 - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::DefIdCache<rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  52:     0x7fb6018ef19b - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7fb601e87956 - rustc_middle[712e48954d6afe8b]::query::plumbing::query_get_at::<rustc_query_system[7897cb83f5f0e4a4]::query::caches::DefIdCache<rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 8usize]>>>
  54:     0x7fb601e8db6a - rustc_hir_analysis[1e7a6b85d58e7e91]::check::check::check_item_type
  55:     0x7fb601eb349c - rustc_hir_analysis[1e7a6b85d58e7e91]::check::wfcheck::check_well_formed
  56:     0x7fb601eb1f87 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>
  57:     0x7fb601eb1700 - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::VecCache<rustc_hir[d2c1ab639b195ce5]::hir_id::OwnerId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  58:     0x7fb601eb147f - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  59:     0x7fb601eaf3ba - rustc_hir_analysis[1e7a6b85d58e7e91]::check::wfcheck::check_mod_type_wf
  60:     0x7fb601eaf1e1 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>
  61:     0x7fb602284cb0 - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::DefaultCache<rustc_span[74819862fbf5924e]::def_id::LocalModDefId, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  62:     0x7fb602284a5b - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  63:     0x7fb601bdebfb - rustc_hir_analysis[1e7a6b85d58e7e91]::check_crate
  64:     0x7fb601cc29aa - rustc_interface[6e8cd5a4c59e5ecd]::passes::analysis
  65:     0x7fb601cc2519 - rustc_query_impl[8c6bc27b23dbc83d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8c6bc27b23dbc83d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>
  66:     0x7fb6025715a5 - rustc_query_system[7897cb83f5f0e4a4]::query::plumbing::try_execute_query::<rustc_query_impl[8c6bc27b23dbc83d]::DynamicConfig<rustc_query_system[7897cb83f5f0e4a4]::query::caches::SingleCache<rustc_middle[712e48954d6afe8b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8c6bc27b23dbc83d]::plumbing::QueryCtxt, false>
  67:     0x7fb602571309 - rustc_query_impl[8c6bc27b23dbc83d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  68:     0x7fb602490084 - rustc_interface[6e8cd5a4c59e5ecd]::interface::run_compiler::<core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>, rustc_driver_impl[76e846938966200a]::run_compiler::{closure#0}>::{closure#0}
  69:     0x7fb602560a45 - std[f1ab4ce7166604a0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6e8cd5a4c59e5ecd]::util::run_in_thread_with_globals<rustc_interface[6e8cd5a4c59e5ecd]::util::run_in_thread_pool_with_globals<rustc_interface[6e8cd5a4c59e5ecd]::interface::run_compiler<core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>, rustc_driver_impl[76e846938966200a]::run_compiler::{closure#0}>::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>
  70:     0x7fb602560872 - <<std[f1ab4ce7166604a0]::thread::Builder>::spawn_unchecked_<rustc_interface[6e8cd5a4c59e5ecd]::util::run_in_thread_with_globals<rustc_interface[6e8cd5a4c59e5ecd]::util::run_in_thread_pool_with_globals<rustc_interface[6e8cd5a4c59e5ecd]::interface::run_compiler<core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>, rustc_driver_impl[76e846938966200a]::run_compiler::{closure#0}>::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[254dfe32d5b92b13]::result::Result<(), rustc_span[74819862fbf5924e]::ErrorGuaranteed>>::{closure#1} as core[254dfe32d5b92b13]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  71:     0x7fb5fd598919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h24cb68345bc0eeeb
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/alloc/src/boxed.rs:2020:9
  72:     0x7fb5fd598919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1d32c6c52d61212f
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/alloc/src/boxed.rs:2020:9
  73:     0x7fb5fd598919 - std::sys::pal::unix::thread::Thread::new::thread_start::h789f3c93e78a3e64
                               at /rustc/3cdcdaf31b45f8045164aae9604573d23091970b/library/std/src/sys/pal/unix/thread.rs:108:17
  74:     0x7fb5fd37f55a - <unknown>
  75:     0x7fb5fd3fca3c - <unknown>
  76:                0x0 - <unknown>

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.79.0-nightly (3cdcdaf31 2024-03-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_borrowck] borrow-checking `operation::{closure#0}`
#1 [mir_borrowck] borrow-checking `operation`
#2 [type_of_opaque] computing type of opaque `operation::{opaque#0}`
#3 [type_of] computing type of `operation::{opaque#0}`
#4 [check_well_formed] checking that `operation::{opaque#0}` is well-formed
#5 [check_mod_type_wf] checking that types are well-formed in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
warning: unused variable: `f`
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:9:22
  |
9 | async fn call<F>(mut f: F)
  |                      ^ help: if this is intentional, prefix it with an underscore: `_f`

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:9:18
  |
9 | async fn call<F>(mut f: F)
  |                  ----^
  |                  |
  |                  help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

error[E0792]: expected generic lifetime parameter, found `'any`
  --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:12:1
   |
3  |   type FutNothing<'a> = impl 'a + Future<Output = ()>;
   |                   -- this generic parameter must be used with a generic lifetime parameter
...
12 | / {
13 | | }
   | |_^

error: concrete type differs from previous defining opaque type use
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:5:1
  |
5 | async fn operation(x: &mut ()) -> () {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FutNothing<'_>`, got `{async fn body@/tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:5:38: 7:2}`
  |
note: previous use here
 --> /tmp/icemaker_global_tempdir.r1Tr5xXMwC2J/rustc_testrunner_tmpdir_reporting.TROxRMfkZ9Oy/mvce.rs:6:5
  |
6 |     call(operation).await
  |     ^^^^^^^^^^^^^^^

error: aborting due to 6 previous errors; 3 warnings emitted

Some errors have detailed explanations: E0601, E0658, E0792.
For more information about an error, try `rustc --explain E0601`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 18, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 18, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: `unexpected region kind in opaque type ICE: unexpected region kind in opaque type Mar 18, 2024
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Mar 18, 2024

#121796 cc @oli-obk
could be related to #108399

@oli-obk
Copy link
Contributor

oli-obk commented Mar 18, 2024

yea I have just locally started hitting this in tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs while rebasing #122077

@oli-obk oli-obk self-assigned this Mar 19, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
Strip placeholders from hidden types before remapping generic parameter

When remapping generic parameters in the hidden type to the generic parameters of the definition of the opaque, we assume that placeholders cannot exist. Instead of just patching that site, I decided to handle it earlier, directly in `infer_opaque_types`, where we are already doing all the careful lifetime handling.

fixes rust-lang#122694

the reason that ICE now occurred was that we stopped treating `operation` as being in the defining scope, so the TAIT became part of the hidden type of the `async fn`'s opaque type instead of just bailing out as ambiguos

I think

```rust
use std::future::Future;

mod foo {
    type FutNothing<'a> = impl 'a + Future<Output = ()>;
    //~^ ERROR: unconstrained opaque type
}

async fn operation(_: &mut ()) -> () {
    //~^ ERROR: concrete type differs from previous
    call(operation).await
    //~^ ERROR: concrete type differs from previous
}

async fn call<F>(_f: F)
where
    for<'any> F: FnMut(&'any mut ()) -> foo::FutNothing<'any>,
{
    //~^ ERROR: expected generic lifetime parameter, found `'any`
}
```

would have already had the same ICE before rust-lang#121796
@bors bors closed this as completed in 40c972e Mar 21, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 21, 2024
Rollup merge of rust-lang#122733 - oli-obk:error_prop, r=compiler-errors

Strip placeholders from hidden types before remapping generic parameter

When remapping generic parameters in the hidden type to the generic parameters of the definition of the opaque, we assume that placeholders cannot exist. Instead of just patching that site, I decided to handle it earlier, directly in `infer_opaque_types`, where we are already doing all the careful lifetime handling.

fixes rust-lang#122694

the reason that ICE now occurred was that we stopped treating `operation` as being in the defining scope, so the TAIT became part of the hidden type of the `async fn`'s opaque type instead of just bailing out as ambiguos

I think

```rust
use std::future::Future;

mod foo {
    type FutNothing<'a> = impl 'a + Future<Output = ()>;
    //~^ ERROR: unconstrained opaque type
}

async fn operation(_: &mut ()) -> () {
    //~^ ERROR: concrete type differs from previous
    call(operation).await
    //~^ ERROR: concrete type differs from previous
}

async fn call<F>(_f: F)
where
    for<'any> F: FnMut(&'any mut ()) -> foo::FutNothing<'any>,
{
    //~^ ERROR: expected generic lifetime parameter, found `'any`
}
```

would have already had the same ICE before rust-lang#121796
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 21, 2024
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. 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