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

thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:363:36: called Option::unwrap() on a None value #133687

Closed
KaliTheCatgirl opened this issue Nov 30, 2024 · 2 comments
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` 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.

Comments

@KaliTheCatgirl
Copy link

Hi,

While making a reverse-engineering framework, I seem to have found an issue with the incomplete generic_const_exprs feature, as there appears to be a conflict with traits.

This ICE does not happen for usages within the same crate; merging lib.rs into main.rs will successfully compile.

Code

lib.rs:

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

pub trait TestTrait {
    const SIZE: usize;
    fn test_fn(bytes: [u8; Self::SIZE]);
}
pub struct TestStruct<const N: usize>;
impl<const N: usize> TestTrait for TestStruct<N> {
    const SIZE: usize = N;
    fn test_fn(_: [u8; Self::SIZE]) {}
}

main.rs:

use ice_test::TestTrait;

fn main() {
    ice_test::TestStruct::<12>::test_fn([0; 12]);
}

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (d10a6823f 2024-11-29)
binary: rustc
commit-hash: d10a6823f4c3176be7a05a2454e5c33b861cb05f
commit-date: 2024-11-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Error output

error: could not compile `ice_test` (bin "ice_test")

Caused by:
  process didn't exit successfully: `/home/kali/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name ice_test --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=175 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=3593e76aa8f5c164 -C extra-filename=-3593e76aa8f5c164 --out-dir /media/kali/Big/girlcode/rs/ice_test/target/debug/deps -C incremental=/media/kali/Big/girlcode/rs/ice_test/target/debug/incremental -L dependency=/media/kali/Big/girlcode/rs/ice_test/target/debug/deps --extern ice_test=/media/kali/Big/girlcode/rs/ice_test/target/debug/deps/libice_test-bafdc74fa4e6a076.rlib` (exit status: 101)
Backtrace

   Compiling ice_test v0.1.0 (/media/kali/Big/girlcode/rs/ice_test)
thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:363:36:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_middle::ty::sty::ParamConst>::find_ty_from_env.cold
   5: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
   6: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
   7: rustc_traits::codegen::codegen_select_candidate
      [... omitted 3 frames ...]
   8: rustc_ty_utils::instance::resolve_instance_raw
      [... omitted 1 frame ...]
   9: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  10: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::push_stack_frame_raw
  11: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
      [... omitted 3 frames ...]
  12: rustc_const_eval::const_eval::valtrees::eval_to_valtree
  13: <rustc_const_eval::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
      [... omitted 3 frames ...]
  14: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>>
  15: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  16: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  17: rustc_trait_selection::traits::try_evaluate_const
  18: rustc_trait_selection::traits::evaluate_const
  19: <rustc_trait_selection::traits::normalize_param_env_or_error::{closure#0}::ConstNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
  20: rustc_trait_selection::traits::normalize_param_env_or_error
  21: rustc_ty_utils::ty::param_env
      [... omitted 1 frame ...]
  22: rustc_ty_utils::abi::fn_abi_of_instance
      [... omitted 1 frame ...]
  23: rustc_monomorphize::mono_checks::check_mono_item
      [... omitted 1 frame ...]
  24: rustc_monomorphize::collector::items_of_instance
      [... omitted 1 frame ...]
  25: rustc_monomorphize::collector::collect_items_rec::{closure#0}
  26: rustc_monomorphize::collector::collect_items_rec
  27: rustc_monomorphize::collector::collect_items_rec
  28: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  29: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  30: <rustc_interface::queries::Linker>::codegen_and_build_linker
  31: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/media/kali/Big/girlcode/rs/ice_test/rustc-ice-2024-11-30T19_19_35-1189533.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [codegen_select_candidate] computing candidate for `<ice_test::TestStruct<N> as ice_test::TestTrait>`
#1 [resolve_instance_raw] resolving instance `<ice_test::TestStruct<N> as ice_test::TestTrait>::SIZE`
#2 [eval_to_allocation_raw] const-evaluating + checking `<ice_test::TestStruct<N> as ice_test::TestTrait>::test_fn::{constant#0}`
#3 [eval_to_valtree] evaluating type-level constant
#4 [param_env] computing normalized predicates of `<ice_test::TestStruct<N> as ice_test::TestTrait>::test_fn`
#5 [fn_abi_of_instance] computing call ABI of `<ice_test::TestStruct<12> as ice_test::TestTrait>::test_fn`
#6 [check_mono_item] monomorphization-time checking
#7 [items_of_instance] collecting items used by `<ice_test::TestStruct<12> as ice_test::TestTrait>::test_fn`
#8 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `ice_test` (bin "ice_test")

Caused by:
  process didn't exit successfully: `/home/kali/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name ice_test --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=175 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=3593e76aa8f5c164 -C extra-filename=-3593e76aa8f5c164 --out-dir /media/kali/Big/girlcode/rs/ice_test/target/debug/deps -C incremental=/media/kali/Big/girlcode/rs/ice_test/target/debug/incremental -L dependency=/media/kali/Big/girlcode/rs/ice_test/target/debug/deps --extern ice_test=/media/kali/Big/girlcode/rs/ice_test/target/debug/deps/libice_test-bafdc74fa4e6a076.rlib` (exit status: 101)

rustc-ice-2024-11-30T19_19_35-1189533.txt

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

cyrgani commented Nov 30, 2024

Looks like the same as #131054 and #128525.

@saethlin saethlin added F-generic_const_exprs `#![feature(generic_const_exprs)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 30, 2024
@workingjubilee
Copy link
Member

seems correct, closing as duplicate.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2024
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)]` 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.
Projects
None yet
Development

No branches or pull requests

5 participants