rust-lang / rust

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

ICE: `Encountered anon const with inference variable args but no error reported` #133139

Open yotamofek opened 1 week ago

yotamofek commented 1 week ago

Unfortunately, I can't share the code that caused this ICE, and have not (yet) been able to minimize it into something I can share.

Meta

Reproduce with:

cargo bisect-rustc --start=2024-11-09 --end=2024-11-16 -- build -p fingerprint 

Regression in https://github.com/rust-lang-ci/rust/commit/5380d568a18ae118bdb902b293e2df2cd7ab1dd7 The PR introducing the regression in this rollup is #132927: Consolidate type system const evaluation under `traits::eva…

searched nightlies: from nightly-2024-11-09 to nightly-2024-11-16
regressed nightly: nightly-2024-11-13
searched commit range: https://github.com/rust-lang/rust/compare/81eef2d362a6f03db6f8928f82d94298d31eb81b...f7273e0044ad8f35ad27282e4ab776af50b61a54
regressed commit: https://github.com/rust-lang/rust/commit/5700240affd222f69b8755e2ff5d4ccaae9e6cf9

Error output

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: Encountered anon const with inference variable args but no error reported
Backtrace

``` error: internal compiler error: Encountered anon const with inference variable args but no error reported | = note: delayed at compiler/rustc_trait_selection/src/traits/mod.rs:592:27 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::delayed_bug::<&str> 4: rustc_trait_selection::traits::try_evaluate_const.cold 5: >::fold_const 6: >::try_fold_with:: 7: ::instantiate_value_path 8: ::check_expr_path 9: ::check_expr_with_expectation_and_args 10: ::check_expr_with_expectation_and_args 11: ::check_expr_block 12: ::check_expr_with_expectation_and_args 13: rustc_hir_typeck::check::check_fn 14: rustc_hir_typeck::typeck 15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 16: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 17: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 18: ::par_body_owners::::{closure#0} 19: rustc_hir_analysis::check_crate 20: rustc_interface::passes::run_required_analyses 21: rustc_interface::passes::analysis 22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 23: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 24: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 25: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} 26: std::sys::backtrace::__rust_begin_short_backtrace::, 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>> 27: <::spawn_unchecked_, 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} 28: std::sys::pal::unix::thread::Thread::new::thread_start 29: start_thread at ./nptl/pthread_create.c:447:8 30: clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 error: internal compiler error: Encountered anon const with inference variable args but no error reported | = note: delayed at compiler/rustc_trait_selection/src/traits/mod.rs:592:27 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::delayed_bug::<&str> 4: rustc_trait_selection::traits::try_evaluate_const.cold 5: >::fold_const 6: ::process_obligation 7: >::process_obligations:: 8: ::structurally_resolve_type 9: ::check_expr_with_expectation_and_args 10: ::check_expr_block 11: ::check_expr_with_expectation_and_args 12: rustc_hir_typeck::check::check_fn 13: rustc_hir_typeck::typeck 14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 16: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 17: ::par_body_owners::::{closure#0} 18: rustc_hir_analysis::check_crate 19: rustc_interface::passes::run_required_analyses 20: rustc_interface::passes::analysis 21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 22: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 23: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 24: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} 25: std::sys::backtrace::__rust_begin_short_backtrace::, 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>> 26: <::spawn_unchecked_, 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} 27: std::sys::pal::unix::thread::Thread::new::thread_start 28: start_thread at ./nptl/pthread_create.c:447:8 29: clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 error: internal compiler error: Encountered anon const with inference variable args but no error reported | = note: delayed at compiler/rustc_trait_selection/src/traits/mod.rs:592:27 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::delayed_bug::<&str> 4: rustc_trait_selection::traits::try_evaluate_const.cold 5: >::fold_const 6: >::try_super_fold_with:: 7: ::process_obligation 8: >::process_obligations:: 9: ::structurally_resolve_type 10: ::check_expr_with_expectation_and_args 11: ::check_expr_block 12: ::check_expr_with_expectation_and_args 13: rustc_hir_typeck::check::check_fn 14: rustc_hir_typeck::typeck 15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 16: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 17: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 18: ::par_body_owners::::{closure#0} 19: rustc_hir_analysis::check_crate 20: rustc_interface::passes::run_required_analyses 21: rustc_interface::passes::analysis 22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 23: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 24: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 25: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} 26: std::sys::backtrace::__rust_begin_short_backtrace::, 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>> 27: <::spawn_unchecked_, 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} 28: std::sys::pal::unix::thread::Thread::new::thread_start 29: start_thread at ./nptl/pthread_create.c:447:8 30: clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 error: internal compiler error: Encountered anon const with inference variable args but no error reported | = note: delayed at compiler/rustc_trait_selection/src/traits/mod.rs:592:27 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::delayed_bug::<&str> 4: rustc_trait_selection::traits::try_evaluate_const.cold 5: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable.cold 6: ::process_obligation 7: >::process_obligations:: 8: ::structurally_resolve_type 9: ::check_expr_with_expectation_and_args 10: ::check_expr_block 11: ::check_expr_with_expectation_and_args 12: rustc_hir_typeck::check::check_fn 13: rustc_hir_typeck::typeck 14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 16: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 17: ::par_body_owners::::{closure#0} 18: rustc_hir_analysis::check_crate 19: rustc_interface::passes::run_required_analyses 20: rustc_interface::passes::analysis 21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 22: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> 23: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 24: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} 25: std::sys::backtrace::__rust_begin_short_backtrace::, 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>> 26: <::spawn_unchecked_, 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} 27: std::sys::pal::unix::thread::Thread::new::thread_start 28: start_thread at ./nptl/pthread_create.c:447:8 29: clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78 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 `/home/yotam/taklit-rs-1/rustc-ice-2024-11-17T21_38_08-674929.txt` to your bug report note: compiler flags: -Z unstable-options --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld -Z next-solver=coherence note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack error: could not compile `fingerprint` (lib) ```

BoxyUwU commented 1 week ago

are you using any nightly features

yotamofek commented 1 week ago

Oh yeah, quite a few: adt_const_params, coroutines, generic_const_exprs, rustc_attrs (I have my own NonZero... structs that derive ConstParamTy, so I use rustc_layout_scalar_valid_range_start and rustc_nonnull_optimization_guaranteed for them), const_trait_impl. Probably some more, but there are quite a few workspace crates at play here.

I'll keep trying to minimize it into a code snippet I can share, but it might be a bit difficult. The one thing I can say at this point is that the ICE specifically affects a crate that has both a main.rs and lib.rs, and while it doesn't use any nightly features itself, it depends on crates that use the aforementioned features.

crypdoughdoteth commented 1 week ago

Hi, I managed to reproduce the bug in a codebase of mine by accident

`rustc version: 1.84.0-nightly (03ee48451 2024-11-18)

platform: aarch64-apple-darwin`

https://github.com/crypdoughdoteth/Merkle-Tree/tree/rustc_bug_repro

It only occurred within this last commit where I added two new methods named gmp_2 and mp_get_proof_elements_next_idxs. Running cargo build doesn't output the rustc-ice txt file for me but rust analyzer does when I open up the codebase in nvim. Hopefully this helps!