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: lifetime_capture_rules_2024: None in region_infer/opaque_types.rs #122782

Closed
matthiaskrgr opened this issue Mar 20, 2024 · 3 comments · Fixed by #116891
Closed

ICE: lifetime_capture_rules_2024: None in region_infer/opaque_types.rs #122782

matthiaskrgr opened this issue Mar 20, 2024 · 3 comments · Fixed by #116891
Labels
C-bug Category: This is a bug. F-lifetime_capture_rules_2024 `#![feature(lifetime_capture_rules_2024)]` 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![feature(lifetime_capture_rules_2024)]


struct FileSystem;

impl FileSystem {
    fn build<'a>(&mut self, commands: impl Iterator + 'a) -> Option<impl Iterator + 'a> {
        let further_commands = self.build(commands);
        self.build(further_commands?)
    }
}

original:

struct FileSystem;

impl FileSystem {
    fn build<'a>(
        &mut self,
        commands: impl Iterator<Item = &'a str> + 'a,
    ) -> Option<impl Iterator<Item = &'a str> + 'a> {
        let further_commands = self.build(commands);
        self.build(further_commands?)
    }
}

fn main() {}

Version information

rustc 1.79.0-nightly (a128516cf 2024-03-20)
binary: rustc
commit-hash: a128516cf9de352ae1f9d430ed730363c7ca3c0c
commit-date: 2024-03-20
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(lifetime_capture_rules_2024)

Program output

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

warning: function cannot return without recursing
 --> /tmp/icemaker_global_tempdir.5DyaYG8WNdcy/rustc_testrunner_tmpdir_reporting.vVpwcwBvw9uo/mvce.rs:4:5
  |
4 |     fn build<'a>(&mut self, commands: impl Iterator + 'a) -> Option<impl Iterator + 'a> {
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
5 |         let further_commands = self.build(commands);
  |                                -------------------- recursive call site
  |
  = help: a `loop` may express intention better if this is on purpose
  = note: `#[warn(unconditional_recursion)]` on by default

thread 'rustc' panicked at compiler/rustc_borrowck/src/region_infer/opaque_types.rs:73:54:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x753296040fa5 - std::backtrace_rs::backtrace::libunwind::trace::hb238178a600e7640
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x753296040fa5 - std::backtrace_rs::backtrace::trace_unsynchronized::h18a64faf849956d4
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x753296040fa5 - std::sys_common::backtrace::_print_fmt::hdae976156d449368
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x753296040fa5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdb9b5e3e983ce460
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x753296091feb - core::fmt::rt::Argument::fmt::h5ad447117290599a
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/core/src/fmt/rt.rs:142:9
   5:     0x753296091feb - core::fmt::write::hcec2d8528418f27e
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/core/src/fmt/mod.rs:1153:17
   6:     0x753296035cbf - std::io::Write::write_fmt::haa636139e96e53ba
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/io/mod.rs:1843:15
   7:     0x753296040d7e - std::sys_common::backtrace::_print::hdbf81feba9c817a4
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x753296040d7e - std::sys_common::backtrace::print::h112b76c74c4834e6
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7532960439f9 - std::panicking::default_hook::{{closure}}::hc5e53ea3fc429948
  10:     0x753296043763 - std::panicking::default_hook::hf72e5bd4be2b44da
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/panicking.rs:292:9
  11:     0x753292bbd84e - std[a5db6e0d1910bc78]::panicking::update_hook::<alloc[18bd171651bd487c]::boxed::Box<rustc_driver_impl[97baef311a2c4da5]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x753296044150 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3f12fab570b3bdb9
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/alloc/src/boxed.rs:2029:9
  13:     0x753296044150 - std::panicking::rust_panic_with_hook::h87df935cb16f0257
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/panicking.rs:783:13
  14:     0x753296043e6d - std::panicking::begin_panic_handler::{{closure}}::h8437e08ccc24881f
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/panicking.rs:649:13
  15:     0x753296041469 - std::sys_common::backtrace::__rust_end_short_backtrace::h3ca2dfcfb7935be2
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x753296043bd7 - rust_begin_unwind
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/panicking.rs:645:5
  17:     0x75329608e486 - core::panicking::panic_fmt::hb044fd902962ba9f
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/core/src/panicking.rs:72:14
  18:     0x75329608e52f - core::panicking::panic::h81980bd19ca17c53
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/core/src/panicking.rs:141:5
  19:     0x75329608e229 - core::option::unwrap_failed::h058372a1f2d8fc7f
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/core/src/option.rs:1985:5
  20:     0x75329173df12 - rustc_borrowck[aed012f9190e468d]::nll::compute_regions
  21:     0x753294dcd306 - rustc_borrowck[aed012f9190e468d]::do_mir_borrowck
  22:     0x753294107ce8 - rustc_borrowck[aed012f9190e468d]::mir_borrowck
  23:     0x7532941077d7 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7532941097ee - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::VecCache<rustc_span[124ba900a2a510f4]::def_id::LocalDefId, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  25:     0x75329410930c - rustc_query_impl[d6f091b6e43d27d5]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x75329487c1cb - rustc_middle[798b1e6edaf341c7]::query::plumbing::query_get_at::<rustc_query_system[b807d52738406a3e]::query::caches::VecCache<rustc_span[124ba900a2a510f4]::def_id::LocalDefId, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>>
  27:     0x7532948740ad - rustc_hir_analysis[423f0ab376009544]::collect::type_of::type_of_opaque
  28:     0x753294873f37 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>
  29:     0x753293ef5b59 - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::DefIdCache<rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  30:     0x753294da71de - rustc_query_impl[d6f091b6e43d27d5]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7532944eb696 - rustc_middle[798b1e6edaf341c7]::query::plumbing::query_get_at::<rustc_query_system[b807d52738406a3e]::query::caches::DefIdCache<rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>>
  32:     0x753291c5ce3a - rustc_hir_analysis[423f0ab376009544]::collect::type_of::type_of
  33:     0x753293ef6f22 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>
  34:     0x753293ef5b59 - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::DefIdCache<rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  35:     0x753293ef565b - rustc_query_impl[d6f091b6e43d27d5]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7532944eb696 - rustc_middle[798b1e6edaf341c7]::query::plumbing::query_get_at::<rustc_query_system[b807d52738406a3e]::query::caches::DefIdCache<rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 8usize]>>>
  37:     0x7532944f1873 - rustc_hir_analysis[423f0ab376009544]::check::check::check_item_type
  38:     0x753294517bd2 - rustc_hir_analysis[423f0ab376009544]::check::wfcheck::check_well_formed
  39:     0x7532945166b5 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>
  40:     0x753294515e40 - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::VecCache<rustc_hir[37495ea4fccba01b]::hir_id::OwnerId, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  41:     0x753294515bbf - rustc_query_impl[d6f091b6e43d27d5]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  42:     0x753294513afa - rustc_hir_analysis[423f0ab376009544]::check::wfcheck::check_mod_type_wf
  43:     0x753294513921 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7532948e7c70 - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::DefaultCache<rustc_span[124ba900a2a510f4]::def_id::LocalModDefId, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  45:     0x7532948e7a1b - rustc_query_impl[d6f091b6e43d27d5]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  46:     0x753294104f0b - rustc_hir_analysis[423f0ab376009544]::check_crate
  47:     0x7532942a226a - rustc_interface[b2729804a80bd186]::passes::analysis
  48:     0x7532942a1dd9 - rustc_query_impl[d6f091b6e43d27d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d6f091b6e43d27d5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>
  49:     0x753294c3c8c3 - rustc_query_system[b807d52738406a3e]::query::plumbing::try_execute_query::<rustc_query_impl[d6f091b6e43d27d5]::DynamicConfig<rustc_query_system[b807d52738406a3e]::query::caches::SingleCache<rustc_middle[798b1e6edaf341c7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d6f091b6e43d27d5]::plumbing::QueryCtxt, false>
  50:     0x753294c3c63f - rustc_query_impl[d6f091b6e43d27d5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  51:     0x753294a8d684 - rustc_interface[b2729804a80bd186]::interface::run_compiler::<core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>, rustc_driver_impl[97baef311a2c4da5]::run_compiler::{closure#0}>::{closure#0}
  52:     0x753294b97a05 - std[a5db6e0d1910bc78]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b2729804a80bd186]::util::run_in_thread_with_globals<rustc_interface[b2729804a80bd186]::util::run_in_thread_pool_with_globals<rustc_interface[b2729804a80bd186]::interface::run_compiler<core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>, rustc_driver_impl[97baef311a2c4da5]::run_compiler::{closure#0}>::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>
  53:     0x753294b97832 - <<std[a5db6e0d1910bc78]::thread::Builder>::spawn_unchecked_<rustc_interface[b2729804a80bd186]::util::run_in_thread_with_globals<rustc_interface[b2729804a80bd186]::util::run_in_thread_pool_with_globals<rustc_interface[b2729804a80bd186]::interface::run_compiler<core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>, rustc_driver_impl[97baef311a2c4da5]::run_compiler::{closure#0}>::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[980ed62ddb44d8e4]::result::Result<(), rustc_span[124ba900a2a510f4]::ErrorGuaranteed>>::{closure#1} as core[980ed62ddb44d8e4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x75329604d919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hce41d8367d913790
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/alloc/src/boxed.rs:2015:9
  55:     0x75329604d919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2459e445e1bb3b38
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/alloc/src/boxed.rs:2015:9
  56:     0x75329604d919 - std::sys::pal::unix::thread::Thread::new::thread_start::h51f8e470692041f5
                               at /rustc/a128516cf9de352ae1f9d430ed730363c7ca3c0c/library/std/src/sys/pal/unix/thread.rs:108:17
  57:     0x75328faa955a - <unknown>
  58:     0x75328fb26a3c - <unknown>
  59:                0x0 - <unknown>

error: 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.79.0-nightly (a128516cf 2024-03-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(lifetime_capture_rules_2024) -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at /tmp/icemaker_global_tempdir.5DyaYG8WNdcy/rustc_testrunner_tmpdir_reporting.vVpwcwBvw9uo/mvce.rs:3:1: 3:16>::build`
#1 [type_of_opaque] computing type of opaque `<impl at /tmp/icemaker_global_tempdir.5DyaYG8WNdcy/rustc_testrunner_tmpdir_reporting.vVpwcwBvw9uo/mvce.rs:3:1: 3:16>::build::{opaque#0}`
#2 [type_of] computing type of `<impl at /tmp/icemaker_global_tempdir.5DyaYG8WNdcy/rustc_testrunner_tmpdir_reporting.vVpwcwBvw9uo/mvce.rs:3:1: 3:16>::build::{opaque#0}`
#3 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.5DyaYG8WNdcy/rustc_testrunner_tmpdir_reporting.vVpwcwBvw9uo/mvce.rs:3:1: 3:16>::build::{opaque#0}` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this 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 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 20, 2024
@matthiaskrgr
Copy link
Member Author

cc @oli-obk seems to happen since #116935

@matthiaskrgr matthiaskrgr added the F-lifetime_capture_rules_2024 `#![feature(lifetime_capture_rules_2024)]` label Mar 20, 2024
@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 20, 2024
@aliemjay
Copy link
Member

minimized:

#![feature(type_alias_impl_trait)]

type Opq<'a, X> = impl Sized;

fn build<'a, X>() -> Option<Opq<'a, X>> {
    match true {
        true => None::<Opq<'_, Opq<'_, X>>>,
        false => None::<Opq<'_, Opq<'_, X>>>,
    }
}

@aliemjay
Copy link
Member

aliemjay commented Mar 25, 2024

futher:

#![feature(type_alias_impl_trait)]

type Opq<'a> = impl Sized;

fn build<'a>() -> Opq<'a> {
    let _: Opq<'_> = ();
}

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-lifetime_capture_rules_2024 `#![feature(lifetime_capture_rules_2024)]` 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants