Skip to content

Cycle error happens when using inherent_associated_types and generic_const_exprs features #136678

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

Open
EvanLuo42 opened this issue Feb 7, 2025 · 0 comments · May be fixed by #140247
Open

Cycle error happens when using inherent_associated_types and generic_const_exprs features #136678

EvanLuo42 opened this issue Feb 7, 2025 · 0 comments · May be fixed by #140247
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` F-inherent_associated_types `#![feature(inherent_associated_types)]` I-cycle Issue: A query cycle occurred while none was expected I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@EvanLuo42
Copy link

Code

#![feature(inherent_associated_types)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

struct B<const A: usize>;

struct Test<const A: usize>;

impl<const A: usize> Test<A> {
    type B = B<{ A }>;
    
    fn test(a: Self::B) -> Self::B {
        a
    }
}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (942db6782 2025-02-06)
binary: rustc
commit-hash: 942db6782f4a28c55b0b75b38fd4394d0483390f
commit-date: 2025-02-06
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.7

Error output

error: internal compiler error[E0391]: cycle detected when computing function signature of `<impl at src/lib.rs:9:1: 9:29>::test`
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires computing normalized predicates of `<impl at src/lib.rs:9:1: 9:29>::test`...
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing predicates of `<impl at src/lib.rs:9:1: 9:29>::test`...
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing explicit predicates of `<impl at src/lib.rs:9:1: 9:29>::test`...
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: ...which again requires computing function signature of `<impl at src/lib.rs:9:1: 9:29>::test`, completing the cycle
   = note: cycle used when computing the variances for items in this crate
   = 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:563:16 - disabled backtrace
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Backtrace

note: delayed at compiler/rustc_query_system/src/query/job.rs:563: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::DefaultCache<rustc_middle::ty::consts::valtree::Value, 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::DefaultCache<rustc_middle::ty::consts::valtree::Value, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
         6: 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>
         7: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
         8: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
         9: rustc_hir_analysis::collect::predicates_of::gather_explicit_predicates_of
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::explicit_predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        11: 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>
        12: rustc_query_impl::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace
        13: rustc_hir_analysis::collect::predicates_of::predicates_of
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        15: 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>
        16: rustc_query_impl::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace
        17: rustc_ty_utils::ty::param_env
        18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::param_env::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::param_env::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: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_assoc_path
        23: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
        24: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
        25: rustc_hir_analysis::collect::lower_fn_sig_recovering_infer_ret_ty
        26: rustc_hir_analysis::collect::fn_sig
        27: 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]>>
        28: <rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        29: 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>
        30: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
        31: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
        32: <rustc_hir_analysis::variance::constraints::ConstraintContext>::build_constraints_for_item
        33: rustc_hir_analysis::variance::crate_variances
        34: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::crate_variances::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        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; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        36: rustc_query_impl::query_impl::crate_variances::get_query_non_incr::__rust_end_short_backtrace
        37: rustc_hir_analysis::variance::variances_of
        38: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
        39: <rustc_query_impl::query_impl::variances_of::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        40: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        41: rustc_query_impl::query_impl::variances_of::get_query_non_incr::__rust_end_short_backtrace
        42: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>>
        43: rustc_hir_analysis::check::wfcheck::check_variances_for_type_defn
        44: rustc_hir_analysis::check::wfcheck::check_well_formed
        45: 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]>>
        46: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        47: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        48: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        49: 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]>>
        50: 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>
        51: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        52: rustc_hir_analysis::check_crate
        53: rustc_interface::passes::run_required_analyses
        54: rustc_interface::passes::analysis
        55: 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; 0]>>
        56: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        57: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        58: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        59: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        60: 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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        61: <<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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        62: std::sys::pal::unix::thread::Thread::new::thread_start
        63: <unknown>
        64: clone
  --> src/lib.rs:12:5
   |
12 |     fn test(a: Self::B) -> Self::B {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@EvanLuo42 EvanLuo42 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 Feb 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 7, 2025
@jieyouxu jieyouxu added F-generic_const_exprs `#![feature(generic_const_exprs)]` F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-incomplete-features This issue requires the use of incomplete features. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 7, 2025
@fmease fmease added the I-cycle Issue: A query cycle occurred while none was expected label Feb 7, 2025
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Mar 9, 2025
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-generic_const_exprs `#![feature(generic_const_exprs)]` F-inherent_associated_types `#![feature(inherent_associated_types)]` I-cycle Issue: A query cycle occurred while none was expected I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

5 participants