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: Could not resolve Lifetime #121503

Closed
matthiaskrgr opened this issue Feb 23, 2024 · 1 comment
Closed

ICE: Could not resolve Lifetime #121503

matthiaskrgr opened this issue Feb 23, 2024 · 1 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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

impl Struct {
    async fn box_box_ref_Struct(self: Box<Box<Self, impl FnMut(&mut Self)>>) -> &u32 {
        f
    }
}

original:

//@ edition:2018

#![rustc_on_unimplemented(on(x="y"), message="y")]

use std::pin::Pin;

struct Struct { }

impl Struct {
    // Test using `&mut Struct` explicitly:

    async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
        f
        //~^ ERROR lifetime may not live long enough
    }

    async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
        f
        //~^ ERROR lifetime may not live long enough
    }

    async fn pin_ref_Struct(self: Pin<&mut Struct>, bar_inlined_always: &u32) -> &u32 {
        f
        //~^ ERROR lifetime may not live long enough
    }

    async fn box_box_ref_Struct(self: Box<Box<Self, impl FnMut(&mut Self)>>, f: &(1u32 >> 32)) -> &u32 {
        f
        //~^ ERROR lifetime may not live long enough
    }

    async fn box_pin_ref_Struct(self: Box<DemoNoDef<&mut Struct>>, f: &u32) -> &u32 {
        f
        //~^ ERROR lifetime may not live long enough
    }
}

fn main() { }

Version information

rustc 1.78.0-nightly (6dadb6eb2 2024-02-23)
binary: rustc
commit-hash: 6dadb6eb23e7719da4e372d3e13d50282323d022
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> /tmp/icemaker_global_tempdir.YABn6SpLAh6p/rustc_testrunner_tmpdir_reporting.T1oCLmcoChXJ/mvce.rs:2:5
  |
2 |     async fn box_box_ref_Struct(self: Box<Box<Self, impl FnMut(&mut Self)>>) -> &u32 {
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0412]: cannot find type `Struct` in this scope
 --> /tmp/icemaker_global_tempdir.YABn6SpLAh6p/rustc_testrunner_tmpdir_reporting.T1oCLmcoChXJ/mvce.rs:1:6
  |
1 | impl Struct {
  |      ^^^^^^ not found in this scope

error[E0425]: cannot find value `f` in this scope
 --> /tmp/icemaker_global_tempdir.YABn6SpLAh6p/rustc_testrunner_tmpdir_reporting.T1oCLmcoChXJ/mvce.rs:3:9
  |
3 |         f
  |         ^ not found in this scope

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

error: internal compiler error: Could not resolve Lifetime { hir_id: HirId(DefId(0:8 ~ mvce[fea7]::{impl#0}::box_box_ref_Struct::{opaque#0}).1), ident: '_#0, res: Param(DefId(0:7 ~ mvce[fea7]::{impl#0}::box_box_ref_Struct::'_)) } in scope Supertrait {
                                    bound_vars: [],
                                    s: ObjectLifetimeDefault {
                                        lifetime: Some(
                                            StaticLifetime,
                                        ),
                                        s: Binder {
                                            bound_vars: {},
                                            scope_type: Normal,
                                            hir_id: HirId(DefId(0:8 ~ mvce[fea7]::{impl#0}::box_box_ref_Struct::{opaque#0}).7),
                                            s: TraitRefBoundary {
                                                s: Binder {
                                                    bound_vars: {},
                                                    scope_type: Normal,
                                                    hir_id: HirId(DefId(0:8 ~ mvce[fea7]::{impl#0}::box_box_ref_Struct::{opaque#0}).0),
                                                    s: Root {
                                                        opt_parent_item: Some(
                                                            DefId(0:4 ~ mvce[fea7]::{impl#0}::box_box_ref_Struct),
                                                        ),
                                                    },
                                                    where_bound_origin: None,
                                                },
                                            },
                                            where_bound_origin: None,
                                        },
                                    },
                                }
 --> /tmp/icemaker_global_tempdir.YABn6SpLAh6p/rustc_testrunner_tmpdir_reporting.T1oCLmcoChXJ/mvce.rs:2:82
  |
2 |     async fn box_box_ref_Struct(self: Box<Box<Self, impl FnMut(&mut Self)>>) -> &u32 {
  |                                                                                  ^

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs:1334:24:
Box<dyn Any>
stack backtrace:
   0:     0x7fb33f3b6af6 - std::backtrace_rs::backtrace::libunwind::trace::ha65d3ff76184bc87
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb33f3b6af6 - std::backtrace_rs::backtrace::trace_unsynchronized::hf7ea96d3ce514b82
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb33f3b6af6 - std::sys_common::backtrace::_print_fmt::hfd298e4a770e9899
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb33f3b6af6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2323338a86fc81c9
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb33f407a7c - core::fmt::rt::Argument::fmt::h157eaeeeb24bb72e
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb33f407a7c - core::fmt::write::heaac4748a4770443
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb33f3ab4bf - std::io::Write::write_fmt::h9259032badca1042
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/io/mod.rs:1846:15
   7:     0x7fb33f3b68a4 - std::sys_common::backtrace::_print::hc92d5e2a4404e26e
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb33f3b68a4 - std::sys_common::backtrace::print::ha2a94ce768edf33a
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb33f3b95eb - std::panicking::default_hook::{{closure}}::h76871112b9e556f7
  10:     0x7fb33f3b9339 - std::panicking::default_hook::hf74de90c4b5df7a9
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/panicking.rs:292:9
  11:     0x7fb33c073c9c - std[dd5750cd74b4d211]::panicking::update_hook::<alloc[3a2d298fa1f4f8a8]::boxed::Box<rustc_driver_impl[c7e2e991238ea07f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb33f3b9d50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb795ef914b920bc4
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/alloc/src/boxed.rs:2030:9
  13:     0x7fb33f3b9d50 - std::panicking::rust_panic_with_hook::h098a2e3444b7237d
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/panicking.rs:786:13
  14:     0x7fb33c0a07e4 - std[dd5750cd74b4d211]::panicking::begin_panic::<rustc_errors[fcc6779dd83e2b71]::ExplicitBug>::{closure#0}
  15:     0x7fb33c09d706 - std[dd5750cd74b4d211]::sys_common::backtrace::__rust_end_short_backtrace::<std[dd5750cd74b4d211]::panicking::begin_panic<rustc_errors[fcc6779dd83e2b71]::ExplicitBug>::{closure#0}, !>
  16:     0x7fb33c09d3e6 - std[dd5750cd74b4d211]::panicking::begin_panic::<rustc_errors[fcc6779dd83e2b71]::ExplicitBug>
  17:     0x7fb33aa17a71 - <rustc_errors[fcc6779dd83e2b71]::diagnostic::BugAbort as rustc_errors[fcc6779dd83e2b71]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fb33a7b0f54 - <rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext as rustc_hir[9f3737e52b7f217]::intravisit::Visitor>::visit_lifetime
  19:     0x7fb33a7a9c6e - <rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext as rustc_hir[9f3737e52b7f217]::intravisit::Visitor>::visit_ty
  20:     0x7fb33a7aeb30 - <rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext as rustc_hir[9f3737e52b7f217]::intravisit::Visitor>::visit_path
  21:     0x7fb33db924ef - <rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext>::visit_poly_trait_ref_inner
  22:     0x7fb33dd100ae - rustc_hir[9f3737e52b7f217]::intravisit::walk_item::<rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext>
  23:     0x7fb33dd0f1b8 - <rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::BoundVarContext as rustc_hir[9f3737e52b7f217]::intravisit::Visitor>::visit_item
  24:     0x7fb33db8f58a - rustc_hir_analysis[79e63f47d465cd1b]::collect::resolve_bound_vars::resolve_bound_vars
  25:     0x7fb33db8f131 - rustc_query_impl[57e36b29e5bd967b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57e36b29e5bd967b]::query_impl::resolve_bound_vars::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7fb33d67fa23 - rustc_query_system[2e43c3a675bb3873]::query::plumbing::try_execute_query::<rustc_query_impl[57e36b29e5bd967b]::DynamicConfig<rustc_query_system[2e43c3a675bb3873]::query::caches::VecCache<rustc_hir[9f3737e52b7f217]::hir_id::OwnerId, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[57e36b29e5bd967b]::plumbing::QueryCtxt, false>
  27:     0x7fb33d67f54c - rustc_query_impl[57e36b29e5bd967b]::query_impl::resolve_bound_vars::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7fb33d67f2cd - rustc_query_impl[57e36b29e5bd967b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57e36b29e5bd967b]::query_impl::late_bound_vars_map::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7fb33d67fa23 - rustc_query_system[2e43c3a675bb3873]::query::plumbing::try_execute_query::<rustc_query_impl[57e36b29e5bd967b]::DynamicConfig<rustc_query_system[2e43c3a675bb3873]::query::caches::VecCache<rustc_hir[9f3737e52b7f217]::hir_id::OwnerId, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[57e36b29e5bd967b]::plumbing::QueryCtxt, false>
  30:     0x7fb33d75654c - rustc_query_impl[57e36b29e5bd967b]::query_impl::late_bound_vars_map::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fb33d756731 - <rustc_middle[e10bafab6a476256]::ty::context::TyCtxt>::late_bound_vars
  32:     0x7fb33df8060a - <dyn rustc_hir_analysis[79e63f47d465cd1b]::astconv::AstConv>::instantiate_poly_trait_ref
  33:     0x7fb33df7d57c - <dyn rustc_hir_analysis[79e63f47d465cd1b]::astconv::AstConv>::compute_bounds
  34:     0x7fb33df2ada2 - rustc_hir_analysis[79e63f47d465cd1b]::collect::item_bounds::opaque_type_bounds
  35:     0x7fb33df296f1 - rustc_hir_analysis[79e63f47d465cd1b]::collect::item_bounds::explicit_item_bounds
  36:     0x7fb33df28867 - rustc_query_impl[57e36b29e5bd967b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57e36b29e5bd967b]::query_impl::explicit_item_bounds::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 16usize]>>
  37:     0x7fb33df28831 - <rustc_query_impl[57e36b29e5bd967b]::query_impl::explicit_item_bounds::dynamic_query::{closure#2} as core[169382930dc0d056]::ops::function::FnOnce<(rustc_middle[e10bafab6a476256]::ty::context::TyCtxt, rustc_span[ba27dc81bf59733]::def_id::DefId)>>::call_once
  38:     0x7fb33d75e480 - rustc_query_system[2e43c3a675bb3873]::query::plumbing::try_execute_query::<rustc_query_impl[57e36b29e5bd967b]::DynamicConfig<rustc_query_system[2e43c3a675bb3873]::query::caches::DefIdCache<rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[57e36b29e5bd967b]::plumbing::QueryCtxt, false>
  39:     0x7fb33d75cb61 - rustc_query_impl[57e36b29e5bd967b]::query_impl::explicit_item_bounds::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7fb33d7cd6de - <rustc_hir_analysis[79e63f47d465cd1b]::collect::CollectItemTypesVisitor as rustc_hir[9f3737e52b7f217]::intravisit::Visitor>::visit_item
  41:     0x7fb33d7cbbea - rustc_hir_analysis[79e63f47d465cd1b]::collect::collect_mod_item_types
  42:     0x7fb33d7cbb77 - rustc_query_impl[57e36b29e5bd967b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57e36b29e5bd967b]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 0usize]>>
  43:     0x7fb33e01036d - rustc_query_system[2e43c3a675bb3873]::query::plumbing::try_execute_query::<rustc_query_impl[57e36b29e5bd967b]::DynamicConfig<rustc_query_system[2e43c3a675bb3873]::query::caches::DefaultCache<rustc_span[ba27dc81bf59733]::def_id::LocalModDefId, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[57e36b29e5bd967b]::plumbing::QueryCtxt, false>
  44:     0x7fb33e00fe97 - rustc_query_impl[57e36b29e5bd967b]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7fb33ddbf828 - rustc_hir_analysis[79e63f47d465cd1b]::check_crate
  46:     0x7fb33e0071af - rustc_interface[4e9aee6b98c8cda]::passes::analysis
  47:     0x7fb33e006e19 - rustc_query_impl[57e36b29e5bd967b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[57e36b29e5bd967b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 1usize]>>
  48:     0x7fb33e1210a5 - rustc_query_system[2e43c3a675bb3873]::query::plumbing::try_execute_query::<rustc_query_impl[57e36b29e5bd967b]::DynamicConfig<rustc_query_system[2e43c3a675bb3873]::query::caches::SingleCache<rustc_middle[e10bafab6a476256]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[57e36b29e5bd967b]::plumbing::QueryCtxt, false>
  49:     0x7fb33e120e09 - rustc_query_impl[57e36b29e5bd967b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  50:     0x7fb33e1302d6 - rustc_interface[4e9aee6b98c8cda]::interface::run_compiler::<core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>, rustc_driver_impl[c7e2e991238ea07f]::run_compiler::{closure#0}>::{closure#0}
  51:     0x7fb33e3c09cd - std[dd5750cd74b4d211]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4e9aee6b98c8cda]::util::run_in_thread_with_globals<rustc_interface[4e9aee6b98c8cda]::util::run_in_thread_pool_with_globals<rustc_interface[4e9aee6b98c8cda]::interface::run_compiler<core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>, rustc_driver_impl[c7e2e991238ea07f]::run_compiler::{closure#0}>::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>
  52:     0x7fb33e3c07fa - <<std[dd5750cd74b4d211]::thread::Builder>::spawn_unchecked_<rustc_interface[4e9aee6b98c8cda]::util::run_in_thread_with_globals<rustc_interface[4e9aee6b98c8cda]::util::run_in_thread_pool_with_globals<rustc_interface[4e9aee6b98c8cda]::interface::run_compiler<core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>, rustc_driver_impl[c7e2e991238ea07f]::run_compiler::{closure#0}>::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[169382930dc0d056]::result::Result<(), rustc_span[ba27dc81bf59733]::ErrorGuaranteed>>::{closure#1} as core[169382930dc0d056]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7fb33f3c3725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h805908c663ab5fb8
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/alloc/src/boxed.rs:2016:9
  54:     0x7fb33f3c3725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h42041a05506d3149
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/alloc/src/boxed.rs:2016:9
  55:     0x7fb33f3c3725 - std::sys::pal::unix::thread::Thread::new::thread_start::h93419657116bfcaf
                               at /rustc/6dadb6eb23e7719da4e372d3e13d50282323d022/library/std/src/sys/pal/unix/thread.rs:108:17
  56:     0x7fb33906f9eb - <unknown>
  57:     0x7fb3390f37cc - <unknown>
  58:                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.78.0-nightly (6dadb6eb2 2024-02-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolve_bound_vars] resolving lifetimes
#1 [late_bound_vars_map] looking up late bound vars
#2 [explicit_item_bounds] finding item bounds for `<impl at /tmp/icemaker_global_tempdir.YABn6SpLAh6p/rustc_testrunner_tmpdir_reporting.T1oCLmcoChXJ/mvce.rs:1:1: 1:12>::box_box_ref_Struct::{opaque#0}`
#3 [collect_mod_item_types] collecting item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

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

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

#121208 cc @nnethercote

@bors bors closed this as completed in edda2a7 Feb 26, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 29, 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

No branches or pull requests

3 participants