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: None in region infer #134653

Closed
matthiaskrgr opened this issue Dec 22, 2024 · 4 comments
Closed

ICE: None in region infer #134653

matthiaskrgr opened this issue Dec 22, 2024 · 4 comments
Labels
A-edition-2024 Area: The 2024 edition 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 Dec 22, 2024

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
trait Owned: 'static {}
fn ice() -> impl Future<Output = &'static dyn Owned> {
    async {
        let not_static = 0;
        force_send(async_load(&not_static));
        loop {}
    }
}

fn force_send<T: Send>(_: T) {}

fn async_load<'a, T: LoadQuery<'a>>(this: T) -> impl Future {
    async {
        this.get_future().await;
    }
}

trait LoadQuery<'a>: Sized {
    type LoadFuture: Future;

    fn get_future(self) -> Self::LoadFuture {
        loop {}
    }
}

impl<'a> LoadQuery<'a> for &'a u8 {
    type LoadFuture = ();
}

original:

use std::future::Future;

trait Owned: 'static {}
fn ice() -> impl Future<Output = &'static dyn Owned> {
    async {
        let not_static = 0;
        force_send(async_load(&not_static));
        loop {}
    }
}

fn force_send<T: Send>(_: T) {
    bar(0usize);
}

fn async_load<'a, T: LoadQuery<'a>>(this: T) -> impl Future {
    async {
        this.get_future().await;
    }
}

trait LoadQuery<'a>: Sized {
    type LoadFuture: Future;

    fn get_future(self) -> Self::LoadFuture {
        loop {}
    }
}

impl<'a> LoadQuery<'a> for &'a u8 {
    type LoadFuture = SimpleFuture;
}

struct SimpleFuture;
impl Future for SimpleFuture {
    type Output = ();
    fn poll(
        self: std::pin::Pin<&mut Self>,
        _: &mut std::task::Context<'_>,
    ) -> std::task::Poll<Self::Output> {
        loop {}
    }
}

Version information

rustc 1.85.0-nightly (a2bcfae5c 2024-12-22)
binary: rustc
commit-hash: a2bcfae5c5d05dd7806a79194cda39108ed6cd7d
commit-date: 2024-12-22
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Possibly related line of code:

from_region: RegionVid,
from_region_origin: NllRegionVariableOrigin,
target_test: impl Fn(RegionVid) -> bool,
) -> (BlameConstraint<'tcx>, Vec<ExtraConstraintInfo>) {
// Find all paths
let (path, target_region) =
self.find_constraint_paths_between_regions(from_region, target_test).unwrap();
debug!(
"path={:#?}",
path.iter()
.map(|c| format!(
"{:?} ({:?}: {:?})",
c,

Command:
/home/gh-matthiaskrgr/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

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

error[E0277]: `()` is not a future
  --> /tmp/icemaker_global_tempdir.BHiqrJV6LOIy/rustc_testrunner_tmpdir_reporting.rdn3fbZeLICY/mvce.rs:27:23
   |
27 |     type LoadFuture = ();
   |                       ^^ `()` is not a future
   |
   = help: the trait `Future` is not implemented for `()`
note: required by a bound in `LoadQuery::LoadFuture`
  --> /tmp/icemaker_global_tempdir.BHiqrJV6LOIy/rustc_testrunner_tmpdir_reporting.rdn3fbZeLICY/mvce.rs:19:22
   |
19 |     type LoadFuture: Future;
   |                      ^^^^^^ required by this bound in `LoadQuery::LoadFuture`

thread 'rustc' panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:1954:82:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x72263dcb775a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he57e0fea652ab9fd
   1:     0x72263e413866 - core::fmt::write::hd55e7fc717febc4b
   2:     0x72263f348bd1 - std::io::Write::write_fmt::h78281f831863065d
   3:     0x72263dcb75b2 - std::sys::backtrace::BacktraceLock::print::h7acbe748d8539c38
   4:     0x72263dcb9aaa - std::panicking::default_hook::{{closure}}::hea23bfd5c34c8db7
   5:     0x72263dcb98f3 - std::panicking::default_hook::hff2113baba127713
   6:     0x72263ce2ecc8 - std[e6d36fd50c659ae0]::panicking::update_hook::<alloc[4740fe411def7ec4]::boxed::Box<rustc_driver_impl[89e0991809749e6d]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x72263dcba2a8 - std::panicking::rust_panic_with_hook::hfc1c16069db4c6ff
   8:     0x72263dcb9f66 - std::panicking::begin_panic_handler::{{closure}}::hb21d96c911822c44
   9:     0x72263dcb7c09 - std::sys::backtrace::__rust_end_short_backtrace::h8e09f77e03188563
  10:     0x72263dcb9c5d - rust_begin_unwind
  11:     0x72263a99c340 - core::panicking::panic_fmt::hfa3a678dda58d831
  12:     0x72263b402d7c - core::panicking::panic::hdf786271010df6cf
  13:     0x72263ba1d049 - core::option::unwrap_failed::hbc04c4e08213af89
  14:     0x72263c7aebd6 - <rustc_borrowck[620ce4e9c4d33f0c]::MirBorrowckCtxt>::explain_why_borrow_contains_point
  15:     0x72263c6cf825 - <rustc_borrowck[620ce4e9c4d33f0c]::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough
  16:     0x72263f4de964 - rustc_borrowck[620ce4e9c4d33f0c]::do_mir_borrowck
  17:     0x72263f4b066a - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>
  18:     0x72263e6ef411 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  19:     0x72263e6eef0d - rustc_query_impl[a3a64fb382d359d2]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  20:     0x72263eef1a0a - rustc_middle[5e0371d42ed41497]::query::plumbing::query_get_at::<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>>
  21:     0x72263eef1a6a - <rustc_borrowck[620ce4e9c4d33f0c]::type_check::TypeChecker>::prove_closure_bounds
  22:     0x72263e752cbb - <rustc_borrowck[620ce4e9c4d33f0c]::type_check::TypeChecker>::typeck_mir
  23:     0x72263f49aad0 - rustc_borrowck[620ce4e9c4d33f0c]::type_check::type_check
  24:     0x72263e4c39d7 - rustc_borrowck[620ce4e9c4d33f0c]::nll::compute_regions
  25:     0x72263f4bda78 - rustc_borrowck[620ce4e9c4d33f0c]::do_mir_borrowck
  26:     0x72263f4b066a - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>
  27:     0x72263e6ef411 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  28:     0x72263e6eef0d - rustc_query_impl[a3a64fb382d359d2]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  29:     0x72263ed1c118 - rustc_middle[5e0371d42ed41497]::query::plumbing::query_get_at::<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>>
  30:     0x72263f36c6de - rustc_hir_analysis[17bd3daf66b8921d]::collect::type_of::type_of_opaque
  31:     0x72263f36c551 - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>
  32:     0x72263e50f21f - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefIdCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  33:     0x72263f5e2035 - rustc_query_impl[a3a64fb382d359d2]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  34:     0x72263ed4c5ec - rustc_middle[5e0371d42ed41497]::query::plumbing::query_get_at::<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefIdCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>>
  35:     0x72263e5157e1 - rustc_hir_analysis[17bd3daf66b8921d]::collect::type_of::type_of
  36:     0x72263e514326 - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>
  37:     0x72263e50f21f - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefIdCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  38:     0x72263e50edab - rustc_query_impl[a3a64fb382d359d2]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  39:     0x72263ed4c5ec - rustc_middle[5e0371d42ed41497]::query::plumbing::query_get_at::<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefIdCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 8usize]>>>
  40:     0x72263ed69c75 - rustc_hir_analysis[17bd3daf66b8921d]::check::check::check_item_type
  41:     0x72263bbafafa - rustc_hir_analysis[17bd3daf66b8921d]::check::wfcheck::check_well_formed
  42:     0x72263edce7bb - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 1usize]>>
  43:     0x72263edce269 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  44:     0x72263edcdccb - rustc_query_impl[a3a64fb382d359d2]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  45:     0x72263edce82b - rustc_middle[5e0371d42ed41497]::query::plumbing::query_ensure_error_guaranteed::<rustc_data_structures[3e783a0e36352b79]::vec_cache::VecCache<rustc_span[458074075485def8]::def_id::LocalDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[7ed8f12aa9c699c]::dep_graph::graph::DepNodeIndex>, ()>
  46:     0x72263edced1b - rustc_hir_analysis[17bd3daf66b8921d]::check::wfcheck::check_mod_type_wf
  47:     0x72263edce84b - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 1usize]>>
  48:     0x72263f3816c8 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::DefaultCache<rustc_span[458074075485def8]::def_id::LocalModDefId, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  49:     0x72263f381470 - rustc_query_impl[a3a64fb382d359d2]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  50:     0x72263e6ebeec - rustc_hir_analysis[17bd3daf66b8921d]::check_crate
  51:     0x72263e6bb6aa - rustc_interface[36124661c84dc53c]::passes::run_required_analyses
  52:     0x72263f34ca5e - rustc_interface[36124661c84dc53c]::passes::analysis
  53:     0x72263f34ca2f - rustc_query_impl[a3a64fb382d359d2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a3a64fb382d359d2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 0usize]>>
  54:     0x72263f3a7855 - rustc_query_system[7ed8f12aa9c699c]::query::plumbing::try_execute_query::<rustc_query_impl[a3a64fb382d359d2]::DynamicConfig<rustc_query_system[7ed8f12aa9c699c]::query::caches::SingleCache<rustc_middle[5e0371d42ed41497]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a3a64fb382d359d2]::plumbing::QueryCtxt, false>
  55:     0x72263f3a758e - rustc_query_impl[a3a64fb382d359d2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  56:     0x72263f4437de - rustc_interface[36124661c84dc53c]::passes::create_and_enter_global_ctxt::<core[a17736bada842104]::option::Option<rustc_interface[36124661c84dc53c]::queries::Linker>, rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  57:     0x72263f3c2aa8 - rustc_interface[36124661c84dc53c]::interface::run_compiler::<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}
  58:     0x72263f251311 - std[e6d36fd50c659ae0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[36124661c84dc53c]::util::run_in_thread_with_globals<rustc_interface[36124661c84dc53c]::util::run_in_thread_pool_with_globals<rustc_interface[36124661c84dc53c]::interface::run_compiler<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  59:     0x72263f2517a6 - <<std[e6d36fd50c659ae0]::thread::Builder>::spawn_unchecked_<rustc_interface[36124661c84dc53c]::util::run_in_thread_with_globals<rustc_interface[36124661c84dc53c]::util::run_in_thread_pool_with_globals<rustc_interface[36124661c84dc53c]::interface::run_compiler<(), rustc_driver_impl[89e0991809749e6d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a17736bada842104]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x72263f252d81 - std::sys::pal::unix::thread::Thread::new::thread_start::h0cedf7b69d2cc02b
  61:     0x72263949ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  62:     0x722639529c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  63:                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: please make sure that you have updated to the latest nightly

note: rustc 1.85.0-nightly (a2bcfae5c 2024-12-22) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `ice::{closure#0}`
#1 [mir_borrowck] borrow-checking `ice`
end of query stack
error: aborting due to 2 previous errors

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

@matthiaskrgr matthiaskrgr 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 Dec 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 22, 2024
@matthiaskrgr
Copy link
Member Author

seems to bisect to nightly-2024-07-04

@matthiaskrgr matthiaskrgr added the A-edition-2024 Area: The 2024 edition label Dec 22, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Dec 22, 2024

Isn't this just #133252 (comment)?

@matthiaskrgr
Copy link
Member Author

ah, yes 😆

@matthiaskrgr
Copy link
Member Author

thanks!

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition 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

No branches or pull requests

4 participants