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: opaque type with non-universal region args #121512

Closed
matthiaskrgr opened this issue Feb 23, 2024 · 5 comments
Closed

ICE: opaque type with non-universal region args #121512

matthiaskrgr opened this issue Feb 23, 2024 · 5 comments
Labels
A-lifetimes Area: Lifetimes / regions 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. 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):

trait Trait<'a, 'b> {}
impl<'a, 'b, T> Trait<'a, 'b> for T {}

fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
    let _: &'a () = foo::<'a, 'b>();

    loop {}
}

original:

trait Trait<'a, 'b> {}
impl<'a, 'b, T> Trait<'a, 'b> for T {}

fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
    let _: &'a () = foo::<'a, 'b>();
    let _: &'b () = foo::<'a, 'b>();
    loop {}
}

Version information

rustc 1.78.0-nightly (52cea084b 2024-02-23)
binary: rustc
commit-hash: 52cea084bd5bbac12ecfa5c0499f5c777025c968
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 --crate-type=lib

Program output

warning: function cannot return without recursing
 --> /tmp/icemaker_global_tempdir.xEeeLtfZEdIS/rustc_testrunner_tmpdir_reporting.OoAOVBT9ivkN/mvce.rs:4:1
  |
4 | fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
5 |     let _: &'a () = foo::<'a, 'b>();
  |                     --------------- recursive call site
  |
  = help: a `loop` may express intention better if this is on purpose
  = note: `#[warn(unconditional_recursion)]` on by default

warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.xEeeLtfZEdIS/rustc_testrunner_tmpdir_reporting.OoAOVBT9ivkN/mvce.rs:1:7
  |
1 | trait Trait<'a, 'b> {}
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function `foo` is never used
 --> /tmp/icemaker_global_tempdir.xEeeLtfZEdIS/rustc_testrunner_tmpdir_reporting.OoAOVBT9ivkN/mvce.rs:4:4
  |
4 | fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
  |    ^^^

warning: 3 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: opaque type with non-universal region args
 --> /tmp/icemaker_global_tempdir.xEeeLtfZEdIS/rustc_testrunner_tmpdir_reporting.OoAOVBT9ivkN/mvce.rs:5:12
  |
5 |     let _: &'a () = foo::<'a, 'b>();
  |            ^^^^^^
  |
note: delayed at compiler/rustc_borrowck/src/region_infer/opaque_types.rs:97:25
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}::{closure#1}.cold.0
         4: <&rustc_middle::ty::list::List<rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_middle::ty::fold::RegionFolder>
         5: rustc_borrowck::nll::compute_regions
         6: rustc_borrowck::do_mir_borrowck
         7: rustc_borrowck::mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        12: rustc_hir_analysis::collect::type_of::type_of_opaque
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
        16: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
        17: rustc_hir_analysis::collect::type_of::type_of
        18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        20: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
        21: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
        22: rustc_hir_analysis::check::check::check_item_type
        23: rustc_hir_analysis::check::wfcheck::check_well_formed
        24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        26: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        27: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        28: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        30: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        31: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
        32: rustc_hir_analysis::check_crate
        33: rustc_interface::passes::analysis
        34: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        36: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        37: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        38: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        39: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        40: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/alloc/src/boxed.rs:2016:9
        41: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/alloc/src/boxed.rs:2016:9
        42: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys/pal/unix/thread.rs:108:17
        43: <unknown>
        44: <unknown>
 --> /tmp/icemaker_global_tempdir.xEeeLtfZEdIS/rustc_testrunner_tmpdir_reporting.OoAOVBT9ivkN/mvce.rs:5:12
  |
5 |     let _: &'a () = foo::<'a, 'b>();
  |            ^^^^^^

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 (52cea084b 2024-02-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@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

It looks like this ICEs since #121491 can't run bisection yet as we don't have the per-pr artifacts yet.

@matthiaskrgr
Copy link
Member Author

The original example crashes since #121479 cc @lcnr

@saethlin saethlin added A-lifetimes Area: Lifetimes / regions and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 24, 2024
@lcnr
Copy link
Contributor

lcnr commented Feb 26, 2024

doesn't this already crash since pretty much forever? https://rust.godbolt.org/z/noc3hrv95

@matthiaskrgr
Copy link
Member Author

This first example yes
the second example: no

@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 28, 2024
@matthiaskrgr
Copy link
Member Author

This was fixed by #116891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions 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. 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