rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.62k stars 12.63k forks source link

ICE: `cycle detected when computing function signature` #131648

Open matthiaskrgr opened 3 hours ago

matthiaskrgr commented 3 hours ago

auto-reduced (treereduce-rust):

#![feature(return_type_notation)]

trait IntFactory {
    fn stream(self) -> impl IntFactory<stream(..): Send>;
}

fn main() {}

original:

#![feature(return_type_notation)]

trait IntFactory {
    fn stream(self) -> impl IntFactory<stream(..): Send>;
}
trait SendIntFactory: IntFactory<stream(..): Send> + Send {}

fn main() {}

Version information

rustc 1.83.0-nightly (ecf2d1fa4 2024-10-13)
binary: rustc
commit-hash: ecf2d1fa4bd8166c696883b10f483122b1fe98a3
commit-date: 2024-10-13
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

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

Program output

``` warning: trait `IntFactory` is never used --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:3:7 | 3 | trait IntFactory { | ^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: 1 warning 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[E0391]: cycle detected when computing function signature of `IntFactory::stream` --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:4:5 | 4 | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires looking up late bound vars inside `IntFactory::stream`... --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:4:5 | 4 | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires resolving lifetimes for `IntFactory::stream`... --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:4:5 | 4 | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing function signature of `IntFactory::stream`, completing the cycle note: cycle used when checking that `IntFactory` is well-formed --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:3:1 | 3 | trait IntFactory { | ^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information note: delayed at compiler/rustc_query_system/src/query/job.rs:596:16 - disabled backtrace --> /tmp/icemaker_global_tempdir.Y5oQaABbYFFD/rustc_testrunner_tmpdir_reporting.Lfitn4m1Yb8Y/mvce.rs:4:5 | 4 | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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.83.0-nightly (ecf2d1fa4 2024-10-13) running on x86_64-unknown-linux-gnu query stack during panic: end of query stack ```

@rustbot label +F-return_type_notation

matthiaskrgr commented 3 hours ago
error: internal compiler error[E0391]: cycle detected when computing function signature of `IntFactory::stream`
 --> f.rs:4:5
  |
4 |     fn stream(self) -> impl IntFactory<stream(..): Send>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires looking up late bound vars inside `IntFactory::stream`...
 --> f.rs:4:5
  |
4 |     fn stream(self) -> impl IntFactory<stream(..): Send>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires resolving lifetimes for `IntFactory::stream`...
 --> f.rs:4:5
  |
4 |     fn stream(self) -> impl IntFactory<stream(..): Send>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: ...which again requires computing function signature of `IntFactory::stream`, completing the cycle
note: cycle used when checking that `IntFactory` is well-formed
 --> f.rs:3:1
  |
3 | trait IntFactory {
  | ^^^^^^^^^^^^^^^^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
note: delayed at compiler/rustc_query_system/src/query/job.rs:596:16
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::diagnostic::Diag>::delay_as_bug
         4: rustc_query_system::query::plumbing::mk_cycle::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
         5: rustc_query_system::query::plumbing::cycle_error::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
         6: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
         7: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
         8: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_path
         9: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext>::visit_poly_trait_ref_inner
        10: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_opaque_ty
        11: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_ty
        12: <rustc_hir_analysis::collect::resolve_bound_vars::BoundVarContext as rustc_hir::intravisit::Visitor>::visit_trait_item
        13: rustc_hir_analysis::collect::resolve_bound_vars::resolve_bound_vars
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::resolve_bound_vars::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        15: 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; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        16: rustc_query_impl::query_impl::resolve_bound_vars::get_query_non_incr::__rust_end_short_backtrace
        17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::late_bound_vars_map::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        18: 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; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        19: rustc_query_impl::query_impl::late_bound_vars_map::get_query_non_incr::__rust_end_short_backtrace
        20: <rustc_middle::ty::context::TyCtxt>::late_bound_vars
        21: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
        22: rustc_hir_analysis::collect::fn_sig
        23: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        25: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
        26: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
        27: rustc_hir_analysis::check::check::check_item_type
        28: rustc_hir_analysis::check::wfcheck::check_well_formed
        29: 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]>>
        30: 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; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        31: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        32: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        33: 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]>>
        34: 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>
        35: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        36: rustc_hir_analysis::check_crate
        37: rustc_interface::passes::run_required_analyses
        38: rustc_interface::passes::analysis
        39: 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]>>
        40: 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>
        41: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        42: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        43: std::sys::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#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        44: <<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#1}, 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}
        45: std::sys::pal::unix::thread::Thread::new::thread_start
        46: <unknown>
        47: <unknown>
 --> f.rs:4:5
  |
4 |     fn stream(self) -> impl IntFactory<stream(..): Send>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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: please attach the file at `/tmp/im/rustc-ice-2024-10-13T12_34_05-2779095.txt` to your bug report

query stack during panic:
end of query stack