rust-lang / rust

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

ICE: `did not expect inference variables here` #133066

Open matthiaskrgr opened 3 hours ago

matthiaskrgr commented 3 hours ago

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: https://github.com/rust-lang/rust/blob/251dc8ad84492c792a7600d8c5fef2ec868a36a7/compiler/rustc_middle/src/mir/interpret/queries.rs#L99-L111

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(_: impl Owner = { N }>) {} | ^^^^^^^^^^^^ | = note: see issue #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: u32; | ^^^^^^^^^^^^^^ | = note: see issue #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: 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(_: impl Owner = { 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: 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::(()); | ^^^ | 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 stack backtrace: 0: 0x767693e5a3ba - ::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::>::{closure#0} 7: 0x767693e5ce28 - std::panicking::rust_panic_with_hook::h99e29fee3fbc2974 8: 0x767692f1e5d1 - std[575dabc3fc23637d]::panicking::begin_panic::::{closure#0} 9: 0x767692f115a6 - std[575dabc3fc23637d]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x767692f0ce1d - std[575dabc3fc23637d]::panicking::begin_panic:: 11: 0x767692f282e1 - ::emit_producing_guarantee 12: 0x7676935a86d3 - rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt::::{closure#0} 13: 0x76769358ef1a - rustc_middle[c94631e3827a547d]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 14: 0x76769358edab - rustc_middle[c94631e3827a547d]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 15: 0x76769195b280 - rustc_middle[c94631e3827a547d]::util::bug::bug_fmt 16: 0x7676960ab035 - ::const_eval_resolve_for_typeck.cold 17: 0x76769503e581 - rustc_trait_selection[ae5754708a8b3a46]::traits::try_evaluate_const 18: 0x767694f92383 - >::fold_const 19: 0x7676928336de - ::fold:: 20: 0x767693d1a9bd - rustc_trait_selection[ae5754708a8b3a46]::traits::normalize::normalize_with_depth_to:: 21: 0x767693d0f792 - ::report_fulfillment_error 22: 0x767693cdc889 - ::report_fulfillment_errors 23: 0x767690d25711 - ::confirm_builtin_call 24: 0x76769536b6d8 - ::check_expr_with_expectation_and_args 25: 0x767695365c35 - ::check_expr_block 26: 0x76769536bfba - ::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::> 30: 0x767694d12001 - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::>, 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 - ::par_body_owners::::{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::> 37: 0x7676955dee6e - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::>, 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::, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1} 40: 0x767695532e50 - std[575dabc3fc23637d]::sys::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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 - 44: 0x767696de449c - 45: 0x0 - 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 commented 3 hours ago

bisects to #132927 cc @BoxyUwU

cyrgani commented 1 hour ago

Isn't this the same as #131406?

matthiaskrgr commented 1 hour ago

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