Skip to content

ICE: Trying to feed an already recorded value for query type_of key #110887

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Apr 27, 2023 · 2 comments · Fixed by #110986
Closed

ICE: Trying to feed an already recorded value for query type_of key #110887

matthiaskrgr opened this issue Apr 27, 2023 · 2 comments · Fixed by #110986
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![crate_type="lib"]
trait Bar<const N: BB> {}
trait BB = Bar<{ 2 + 1 }>;

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (1c42cb4ef 2023-04-26)
binary: rustc
commit-hash: 1c42cb4ef0544fbfaa500216e53382d6b079c001
commit-date: 2023-04-26
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error[E0658]: trait aliases are experimental
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:3:1
  |
3 | trait BB = Bar<{ 2 + 1 }>;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
  = help: add `#![feature(trait_alias)]` to the crate attributes to enable

warning: trait objects without an explicit `dyn` are deprecated
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:2:20
  |
2 | trait Bar<const N: BB> {}
  |                    ^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: use `dyn`
  |
2 | trait Bar<const N: dyn BB> {}
  |                    +++

error[E0391]: cycle detected when computing type of `Bar::N`
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:2:11
  |
2 | trait Bar<const N: BB> {}
  |           ^^^^^^^^^^^
  |
note: ...which requires computing the implied predicates of `BB`...
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:3:1
  |
3 | trait BB = Bar<{ 2 + 1 }>;
  | ^^^^^^^^
  = note: ...which again requires computing type of `Bar::N`, completing the cycle
note: cycle used when computing explicit predicates of trait `Bar`
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:2:1
  |
2 | trait Bar<const N: BB> {}
  | ^^^^^^^^^^^^^^^^^^^^^^

error[E0391]: cycle detected when computing type of `Bar::N`
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:2:11
  |
2 | trait Bar<const N: BB> {}
  |           ^^^^^^^^^^^
  |
  = note: ...which immediately requires computing type of `Bar::N` again
note: cycle used when computing explicit predicates of trait `Bar`
 --> EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD.rs:2:1
  |
2 | trait Bar<const N: BB> {}
  | ^^^^^^^^^^^^^^^^^^^^^^
Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Fingerprint(6165256526804378725, 10024937989532815698)`,
 right: `Fingerprint(6898402961433838233, 16874419383706554687)`: Trying to feed an already recorded value for query type_of key=DefId(0:6 ~ EED31F0DF9B9A1537D3A5A1FC8D89EFAC1A02554F65D38EB39520EC6C56421DD[5e14]::BB::{constant#0}):
old value: EarlyBinder([type error])
new value: EarlyBinder((dyn Bar<{ 2 + 1 }> + 'static))', compiler/rustc_middle/src/ty/query.rs:541:1
stack backtrace:
   0:     0x7f52bb3c7e73 - std::backtrace_rs::backtrace::libunwind::trace::h0c8179e89cc9893e
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f52bb3c7e73 - std::backtrace_rs::backtrace::trace_unsynchronized::hfadffaff9fceb6ba
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f52bb3c7e73 - std::sys_common::backtrace::_print_fmt::ha49f609af156c4cb
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f52bb3c7e73 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0ad104dc9ebb0bab
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f52bb428c8f - core::fmt::write::h076b507083203424
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/core/src/fmt/mod.rs:1247:17
   5:     0x7f52bb3baea1 - std::io::Write::write_fmt::ha4c326e8c8c981e1
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/io/mod.rs:1712:15
   6:     0x7f52bb3c7c85 - std::sys_common::backtrace::_print::hbc9e8503f2c8583b
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f52bb3c7c85 - std::sys_common::backtrace::print::he24fec1d9c5516a7
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f52bb3ca847 - std::panicking::default_hook::{{closure}}::hf29caaf6379226a6
   9:     0x7f52bb3ca635 - std::panicking::default_hook::h0765c9476c979227
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/panicking.rs:288:9
  10:     0x7f52ba1bf8c5 - <rustc_driver_impl[b4ece89b41fa04d8]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[a53159a38bb5d97c]::ops::function::FnOnce<(&core[a53159a38bb5d97c]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f52bb3caf85 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7a83df3f1b1b39ec
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/alloc/src/boxed.rs:1976:9
  12:     0x7f52bb3caf85 - std::panicking::rust_panic_with_hook::h060701a46b500fdf
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/panicking.rs:695:13
  13:     0x7f52bb3cacf9 - std::panicking::begin_panic_handler::{{closure}}::hcfb53c4ced379f9a
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/panicking.rs:582:13
  14:     0x7f52bb3c82b6 - std::sys_common::backtrace::__rust_end_short_backtrace::h2100286b873f9af0
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f52bb3caa52 - rust_begin_unwind
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/panicking.rs:578:5
  16:     0x7f52bb424f23 - core::panicking::panic_fmt::hcbb1fb2c2e65f651
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/core/src/panicking.rs:67:14
  17:     0x7f52bb4254c9 - core::panicking::assert_failed_inner::hbcfc8b9959306cd0
  18:     0x7f52ba695cfc - core[a53159a38bb5d97c]::panicking::assert_failed::<rustc_data_structures[ecde4e0aacf74356]::fingerprint::Fingerprint, rustc_data_structures[ecde4e0aacf74356]::fingerprint::Fingerprint>
  19:     0x7f52b94e61aa - <rustc_middle[74d31bc1c7288efd]::ty::context::TyCtxt>::feed_anon_const_type
  20:     0x7f52b94e3499 - rustc_hir_analysis[72726d43727a00d0]::astconv::generics::create_substs_for_generic_args::<<dyn rustc_hir_analysis[72726d43727a00d0]::astconv::AstConv>::create_substs_for_ast_path::{closure#0}::SubstsForAstPathCtxt>
  21:     0x7f52b9518179 - <dyn rustc_hir_analysis[72726d43727a00d0]::astconv::AstConv>::instantiate_poly_trait_ref_inner
  22:     0x7f52b9516edb - <dyn rustc_hir_analysis[72726d43727a00d0]::astconv::AstConv>::instantiate_poly_trait_ref
  23:     0x7f52b9516a70 - <dyn rustc_hir_analysis[72726d43727a00d0]::astconv::AstConv>::add_bounds::<core[a53159a38bb5d97c]::slice::iter::Iter<rustc_hir[91d5175e7694dd08]::hir::GenericBound>>
  24:     0x7f52b95161b6 - rustc_hir_analysis[72726d43727a00d0]::collect::predicates_of::implied_predicates_with_filter
  25:     0x7f52b9aae6aa - rustc_hir_analysis[72726d43727a00d0]::collect::predicates_of::super_predicates_of
  26:     0x7f52b982c8bf - rustc_query_system[38efe1ae13b76606]::query::plumbing::try_execute_query::<rustc_query_impl[d894186be28c7657]::queries::super_predicates_of, rustc_query_impl[d894186be28c7657]::plumbing::QueryCtxt>
  27:     0x7f52b982c028 - <rustc_query_impl[d894186be28c7657]::Queries as rustc_middle[74d31bc1c7288efd]::ty::query::QueryEngine>::super_predicates_of
  28:     0x7f52b8b07698 - <rustc_hir_analysis[72726d43727a00d0]::collect::CollectItemTypesVisitor as rustc_hir[91d5175e7694dd08]::intravisit::Visitor>::visit_item
  29:     0x7f52b8b05c07 - <rustc_middle[74d31bc1c7288efd]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[72726d43727a00d0]::collect::CollectItemTypesVisitor>
  30:     0x7f52b8b05b2c - rustc_hir_analysis[72726d43727a00d0]::collect::collect_mod_item_types
  31:     0x7f52b9822b53 - rustc_query_system[38efe1ae13b76606]::query::plumbing::try_execute_query::<rustc_query_impl[d894186be28c7657]::queries::collect_mod_item_types, rustc_query_impl[d894186be28c7657]::plumbing::QueryCtxt>
  32:     0x7f52b9822789 - <rustc_query_impl[d894186be28c7657]::Queries as rustc_middle[74d31bc1c7288efd]::ty::query::QueryEngine>::collect_mod_item_types
  33:     0x7f52b969afcb - <rustc_middle[74d31bc1c7288efd]::hir::map::Map>::for_each_module::<rustc_hir_analysis[72726d43727a00d0]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  34:     0x7f52b969ab82 - <rustc_session[86cf650fda0448f5]::session::Session>::track_errors::<rustc_hir_analysis[72726d43727a00d0]::check_crate::{closure#0}, ()>
  35:     0x7f52b9697eb4 - rustc_hir_analysis[72726d43727a00d0]::check_crate
  36:     0x7f52b969201d - rustc_interface[69aa8c17999313ff]::passes::analysis
  37:     0x7f52b993e3a2 - rustc_query_system[38efe1ae13b76606]::query::plumbing::try_execute_query::<rustc_query_impl[d894186be28c7657]::queries::analysis, rustc_query_impl[d894186be28c7657]::plumbing::QueryCtxt>
  38:     0x7f52b993e0b0 - <rustc_query_impl[d894186be28c7657]::Queries as rustc_middle[74d31bc1c7288efd]::ty::query::QueryEngine>::analysis
  39:     0x7f52b93ba90a - <rustc_middle[74d31bc1c7288efd]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[b4ece89b41fa04d8]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>
  40:     0x7f52b93b9b48 - <rustc_interface[69aa8c17999313ff]::interface::Compiler>::enter::<rustc_driver_impl[b4ece89b41fa04d8]::run_compiler::{closure#1}::{closure#2}, core[a53159a38bb5d97c]::result::Result<core[a53159a38bb5d97c]::option::Option<rustc_interface[69aa8c17999313ff]::queries::Linker>, rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>
  41:     0x7f52b93b7b6f - rustc_span[5acbb0d3e38bbf81]::set_source_map::<core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>, rustc_interface[69aa8c17999313ff]::interface::run_compiler<core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>, rustc_driver_impl[b4ece89b41fa04d8]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  42:     0x7f52b93b7200 - std[b0e36382822581c2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[69aa8c17999313ff]::util::run_in_thread_pool_with_globals<rustc_interface[69aa8c17999313ff]::interface::run_compiler<core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>, rustc_driver_impl[b4ece89b41fa04d8]::run_compiler::{closure#1}>::{closure#0}, core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>
  43:     0x7f52b93b6b21 - <<std[b0e36382822581c2]::thread::Builder>::spawn_unchecked_<rustc_interface[69aa8c17999313ff]::util::run_in_thread_pool_with_globals<rustc_interface[69aa8c17999313ff]::interface::run_compiler<core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>, rustc_driver_impl[b4ece89b41fa04d8]::run_compiler::{closure#1}>::{closure#0}, core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a53159a38bb5d97c]::result::Result<(), rustc_span[5acbb0d3e38bbf81]::ErrorGuaranteed>>::{closure#1} as core[a53159a38bb5d97c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f52bb3d5365 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2b4cb02d9a218e1d
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/alloc/src/boxed.rs:1962:9
  45:     0x7f52bb3d5365 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbd8144eacfab6e10
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/alloc/src/boxed.rs:1962:9
  46:     0x7f52bb3d5365 - std::sys::unix::thread::Thread::new::thread_start::h95499a4b2fca6f4a
                               at /rustc/1c42cb4ef0544fbfaa500216e53382d6b079c001/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7f52b6e9ebb5 - <unknown>
  48:     0x7f52b6f20d90 - <unknown>
  49:                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: rustc 1.71.0-nightly (1c42cb4ef 2023-04-26) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [super_predicates_of] computing the super predicates of `BB`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@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. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Apr 27, 2023
@BoxyUwU
Copy link
Member

BoxyUwU commented Apr 27, 2023

cc @cjgillot

@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Apr 27, 2023
@cjgillot cjgillot self-assigned this Apr 27, 2023
@matthiaskrgr
Copy link
Member Author

searched toolchains nightly-2023-04-20 through nightly-2023-04-28
Regression in nightly-2023-04-22
searched toolchains 8bdcc62 through fec9adc
Regression in 1f5768b

#96840

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 18, 2023
…apkin

Delay a bug when overwriting fed value.

Fixes rust-lang#110887
@bors bors closed this as completed in f2b213c May 18, 2023
@oli-obk oli-obk moved this to Done in query feeding May 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants