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: did not expect inference variables here #133066

Open
matthiaskrgr opened this issue Nov 15, 2024 · 4 comments
Open

ICE: did not expect inference variables here #133066

matthiaskrgr opened this issue Nov 15, 2024 · 4 comments
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-bisection Status: a bisection 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

auto-reduced (treereduce-rust):

trait Owner {
    const C<const N: u32>: u32;
}

impl Owner for () {
    ;
}

fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}

fn main() {
    take0::<f32, >(());
}

original:

trait Owner {
    const C<const N: u32>: u32;
}

impl Owner for () {
    const C<const N: u32>: u32 = N;
}

fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}

fn main() {
    take0::<f32, {Dimension}>(());
}

Version information

rustc 1.84.0-nightly (251dc8ad8 2024-11-15)
binary: rustc
commit-hash: 251dc8ad84492c792a7600d8c5fef2ec868a36a7
commit-date: 2024-11-15
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Possibly related line of code:

// variables. We reject those here since `resolve`
// would fail otherwise.
//
// When trying to evaluate constants containing inference variables,
// use `Infcx::const_eval_resolve` instead.
if ct.args.has_non_region_infer() {
bug!("did not expect inference variables here");
}
match ty::Instance::try_resolve(self, param_env, ct.def, ct.args) {
Ok(Some(instance)) => {
let cid = GlobalId { instance, promoted: None };
self.const_eval_global_id_for_typeck(param_env, cid, span).inspect(|_| {

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

Program output

error: non-item in item list
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:6:5
  |
5 | impl Owner for () {
  |                   - item list starts here
6 |     ;
  |     ^ non-item starts here
7 | }
  | - item list ends here

error[E0658]: associated const equality is incomplete
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:9:38
  |
9 | fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
  |                                      ^^^^^^^^^^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
  = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-15; consider upgrading it if it is out of date

error[E0658]: generic const items are experimental
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:2:12
  |
2 |     const C<const N: u32>: u32;
  |            ^^^^^^^^^^^^^^
  |
  = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
  = help: add `#![feature(generic_const_items)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-15; consider upgrading it if it is out of date

error[E0046]: not all trait items implemented, missing: `C`
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:5:1
  |
2 |     const C<const N: u32>: u32;
  |     -------------------------- `C` from trait
...
5 | impl Owner for () {
  | ^^^^^^^^^^^^^^^^^ missing `C` in implementation

error: the constant `N` is not of type `u32`
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:9:38
  |
9 | fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
  |                                      ^^^^^^^^^^^^ expected `u32`, found `u64`
  |
note: required by a const generic parameter in `Owner::C`
 --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:2:13
  |
2 |     const C<const N: u32>: u32;
  |             ^^^^^^^^^^^^ required by this const generic parameter in `Owner::C`

error[E0747]: type provided when a constant was expected
  --> /tmp/icemaker_global_tempdir.LZacjKgHN0Cn/rustc_testrunner_tmpdir_reporting.fVFwgFbJn0St/mvce.rs:12:13
   |
12 |     take0::<f32, >(());
   |             ^^^
   |
help: if this generic argument was intended as a const parameter, surround it with braces
   |
12 |     take0::<{ f32 }, >(());
   |             +     +

error: internal compiler error: compiler/rustc_middle/src/mir/interpret/queries.rs:105:13: did not expect inference variables here

thread 'rustc' panicked at compiler/rustc_middle/src/mir/interpret/queries.rs:105:13:
Box<dyn Any>
stack backtrace:
   0:     0x767693e5a3ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3e8890c320687803
   1:     0x76769460414a - core::fmt::write::h8e02e323e721d5d3
   2:     0x767695a2cc51 - std::io::Write::write_fmt::hfa5fc2d5ad51eab4
   3:     0x767693e5a212 - std::sys::backtrace::BacktraceLock::print::hef9ddff43c45c466
   4:     0x767693e5c716 - std::panicking::default_hook::{{closure}}::he4ae1ef11715c038
   5:     0x767693e5c560 - std::panicking::default_hook::h4571154760051e3a
   6:     0x767692ee4281 - std[575dabc3fc23637d]::panicking::update_hook::<alloc[488fcebc54bee2fb]::boxed::Box<rustc_driver_impl[530468506af41d6d]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x767693e5ce28 - std::panicking::rust_panic_with_hook::h99e29fee3fbc2974
   8:     0x767692f1e5d1 - std[575dabc3fc23637d]::panicking::begin_panic::<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>::{closure#0}
   9:     0x767692f115a6 - std[575dabc3fc23637d]::sys::backtrace::__rust_end_short_backtrace::<std[575dabc3fc23637d]::panicking::begin_panic<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>::{closure#0}, !>
  10:     0x767692f0ce1d - std[575dabc3fc23637d]::panicking::begin_panic::<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>
  11:     0x767692f282e1 - <rustc_errors[6fe58dffe56bd7e6]::diagnostic::BugAbort as rustc_errors[6fe58dffe56bd7e6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7676935a86d3 - rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt::<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}
  13:     0x76769358ef1a - rustc_middle[c94631e3827a547d]::ty::context::tls::with_opt::<rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x76769358edab - rustc_middle[c94631e3827a547d]::ty::context::tls::with_context_opt::<rustc_middle[c94631e3827a547d]::ty::context::tls::with_opt<rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x76769195b280 - rustc_middle[c94631e3827a547d]::util::bug::bug_fmt
  16:     0x7676960ab035 - <rustc_middle[c94631e3827a547d]::ty::context::TyCtxt>::const_eval_resolve_for_typeck.cold
  17:     0x76769503e581 - rustc_trait_selection[ae5754708a8b3a46]::traits::try_evaluate_const
  18:     0x767694f92383 - <rustc_trait_selection[ae5754708a8b3a46]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[83e8cfe6e15c3590]::fold::TypeFolder<rustc_middle[c94631e3827a547d]::ty::context::TyCtxt>>::fold_const
  19:     0x7676928336de - <rustc_trait_selection[ae5754708a8b3a46]::traits::normalize::AssocTypeNormalizer>::fold::<rustc_middle[c94631e3827a547d]::ty::Term>
  20:     0x767693d1a9bd - rustc_trait_selection[ae5754708a8b3a46]::traits::normalize::normalize_with_depth_to::<rustc_middle[c94631e3827a547d]::ty::Term>
  21:     0x767693d0f792 - <rustc_trait_selection[ae5754708a8b3a46]::error_reporting::TypeErrCtxt>::report_fulfillment_error
  22:     0x767693cdc889 - <rustc_trait_selection[ae5754708a8b3a46]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  23:     0x767690d25711 - <rustc_hir_typeck[37bfb0076054673b]::fn_ctxt::FnCtxt>::confirm_builtin_call
  24:     0x76769536b6d8 - <rustc_hir_typeck[37bfb0076054673b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x767695365c35 - <rustc_hir_typeck[37bfb0076054673b]::fn_ctxt::FnCtxt>::check_expr_block
  26:     0x76769536bfba - <rustc_hir_typeck[37bfb0076054673b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x76769485789c - rustc_hir_typeck[37bfb0076054673b]::check::check_fn
  28:     0x76769484d2ec - rustc_hir_typeck[37bfb0076054673b]::typeck
  29:     0x76769484cc93 - rustc_query_impl[bf1c9f3baad9eabf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf1c9f3baad9eabf]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 8usize]>>
  30:     0x767694d12001 - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::<rustc_query_impl[bf1c9f3baad9eabf]::DynamicConfig<rustc_query_system[d5846f7a9cb2c23f]::query::caches::VecCache<rustc_span[9778d555244491c7]::def_id::LocalDefId, rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[bf1c9f3baad9eabf]::plumbing::QueryCtxt, false>
  31:     0x767694d1048d - rustc_query_impl[bf1c9f3baad9eabf]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  32:     0x767694d10107 - <rustc_middle[c94631e3827a547d]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[19f2f9b7f430108f]::check_crate::{closure#4}>::{closure#0}
  33:     0x767694d0e0d9 - rustc_hir_analysis[19f2f9b7f430108f]::check_crate
  34:     0x767694b44fca - rustc_interface[c18496298df4cf52]::passes::run_required_analyses
  35:     0x76769542961e - rustc_interface[c18496298df4cf52]::passes::analysis
  36:     0x7676954295ef - rustc_query_impl[bf1c9f3baad9eabf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf1c9f3baad9eabf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7676955dee6e - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::<rustc_query_impl[bf1c9f3baad9eabf]::DynamicConfig<rustc_query_system[d5846f7a9cb2c23f]::query::caches::SingleCache<rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[bf1c9f3baad9eabf]::plumbing::QueryCtxt, false>
  38:     0x7676955deb4e - rustc_query_impl[bf1c9f3baad9eabf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7676954d963a - rustc_interface[c18496298df4cf52]::interface::run_compiler::<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}
  40:     0x767695532e50 - std[575dabc3fc23637d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c18496298df4cf52]::util::run_in_thread_with_globals<rustc_interface[c18496298df4cf52]::util::run_in_thread_pool_with_globals<rustc_interface[c18496298df4cf52]::interface::run_compiler<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>
  41:     0x76769553326b - <<std[575dabc3fc23637d]::thread::Builder>::spawn_unchecked_<rustc_interface[c18496298df4cf52]::util::run_in_thread_with_globals<rustc_interface[c18496298df4cf52]::util::run_in_thread_pool_with_globals<rustc_interface[c18496298df4cf52]::interface::run_compiler<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#1} as core[678332cb0ee15b78]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x767695533d39 - std::sys::pal::unix::thread::Thread::new::thread_start::h1176f996a4a1b888
  43:     0x767696d5f39d - <unknown>
  44:     0x767696de449c - <unknown>
  45:                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: please make sure that you have updated to the latest nightly

note: rustc 1.84.0-nightly (251dc8ad8 2024-11-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 7 previous errors

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

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

bisects to #132927 cc @BoxyUwU

@cyrgani
Copy link
Contributor

cyrgani commented Nov 15, 2024

Isn't this the same as #131406?

@matthiaskrgr
Copy link
Member Author

stacktrace is different, query stack is different, code is different, bisection points to a different PR, so I'm inclined to say its a different case

@jieyouxu jieyouxu added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) S-has-bisection Status: a bisection has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 15, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Nov 15, 2024

Needs an error minimization.

@oli-obk oli-obk added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 15, 2024
@BoxyUwU BoxyUwU self-assigned this Nov 15, 2024
@RalfJung RalfJung added A-const-generics Area: const generics (parameters and arguments) and removed A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Dec 1, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-bisection Status: a bisection has been found for this issue 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

7 participants