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

[nightly] [feature generic_const_exprs] type parameter BigTruthTable/#1 (BigTruthTable/#1/1) out of range when instantiating, args=[NUM_VAR/#0] #129813

Closed
thomasarmel opened this issue Aug 31, 2024 · 3 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

@thomasarmel
Copy link

Code

#![feature(generic_const_exprs)]

use num_traits::Unsigned;
use ruint::{uint, Uint, UintTryTo};


pub struct BooleanFunction<const NUM_VAR: usize, BigTruthTable = Uint<{ 1 << NUM_VAR }, {1 << (NUM_VAR - 6)}>> {
    variables_count: usize,
    truth_table_big: Option<BigTruthTable>,
    truth_table_small: u32,
}

impl<const NUM_VAR: usize> BooleanFunction<NUM_VAR> {

    pub fn from_truth_table_small(truth_table_small: u32, variables_count: usize) -> Self {
        let answer = uint!(42_U1024);
        BooleanFunction {
            variables_count,
            truth_table_big: None,
            truth_table_small,
        }
    }
}

Cargo.toml

[package]
name = "boolean_function"
version = "0.1.0"
edition = "2021"

[dependencies]
num-traits = "0.2.19"
ruint = "1.12.3"

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (0d634185d 2024-08-29)
binary: rustc
commit-hash: 0d634185dfddefe09047881175f35c65d68dcff1
commit-date: 2024-08-29
host: x86_64-pc-windows-msvc
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src\lib.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: unused import: `num_traits::Unsigned`
 --> src\lib.rs:3:5
  |
3 | use num_traits::Unsigned;
  |     ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `UintTryTo`
 --> src\lib.rs:4:25
  |
4 | use ruint::{uint, Uint, UintTryTo};
  |                         ^^^^^^^^^

thread 'rustc' panicked at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\compiler\rustc_type_ir\src\binder.rs:697:9:
type parameter `BigTruthTable/#1` (BigTruthTable/#1/1) out of range when instantiating, args=[NUM_VAR/#0]
Backtrace

stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\library/std\src\panicking.rs:662
   1: core::panicking::panic_fmt
             at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\library/core\src\panicking.rs:74
   2: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::mutate
   3: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
   4: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
   5: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::consume
   6: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
   7: <<dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}::GenericArgsCtxt as rustc_hir_analysis::hir_ty_lowering::GenericArgsLowerer>::inferred_kind
   8: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_path
   9: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
  10: rustc_hir_analysis::collect::type_of::type_of
  11: rustc_query_impl::plumbing::query_key_hash_verify_all
  12: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  13: rustc_query_impl::plumbing::query_key_hash_verify_all
  14: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_path
  15: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
  16: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  17: rustc_hir_analysis::collect::trait_def
  18: rustc_hir_analysis::collect::fn_sig
  19: rustc_query_impl::plumbing::query_key_hash_verify_all
  20: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  21: rustc_query_impl::plumbing::query_key_hash_verify_all
  22: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
  23: <rustc_hir_analysis::constrained_generic_params::ParameterCollector as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  24: <rustc_hir_analysis::constrained_generic_params::ParameterCollector as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  25: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  26: rustc_ty_utils::ty::adt_sized_constraint
  27: <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  28: <rustc_hir_analysis::constrained_generic_params::ParameterCollector as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  29: rustc_query_impl::plumbing::query_key_hash_verify_all
  30: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  31: rustc_query_impl::plumbing::query_key_hash_verify_all
  32: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
  33: rustc_hir_analysis::check::wfcheck::check_well_formed
  34: rustc_hir_analysis::check::wfcheck::check_well_formed
  35: rustc_query_impl::plumbing::query_key_hash_verify_all
  36: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  37: rustc_query_impl::plumbing::query_key_hash_verify_all
  38: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
  39: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  40: rustc_ty_utils::ty::adt_sized_constraint
  41: rustc_query_impl::query_system
  42: rustc_hir_analysis::check_crate
  43: rustc_interface::passes::resolver_for_lowering_raw
  44: rustc_interface::passes::analysis
  45: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  46: rustc_ty_utils::ty::adt_sized_constraint
  47: rustc_query_impl::query_system
  48: _rust_alloc_error_handler
  49: _rust_alloc_error_handler
  50: _rust_alloc_error_handler
  51: alloc::boxed::impl$48::call_once
             at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\library/alloc\src\boxed.rs:2231
  52: alloc::boxed::impl$48::call_once
             at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\library/alloc\src\boxed.rs:2231
  53: std::sys::pal::windows::thread::impl$0::new::thread_start
             at /rustc/0d634185dfddefe09047881175f35c65d68dcff1\library/std\src\sys\pal\windows\thread.rs:55
  54: BaseThreadInitThunk
  55: RtlUserThreadStart
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 `C:\Users\thoma\Documents\programmation\rust\boolean_function\rustc-ice-2024-08-31T10_11_04-17844.txt` to your bug report

note: compiler flags: --crate-type lib -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 [type_of] computing type of `<impl at src\lib.rs:13:1: 13:52>`
#1 [fn_sig] computing function signature of `<impl at src\lib.rs:13:1: 13:52>::from_truth_table_small`
#2 [crate_variances] computing the variances for items in this crate
#3 [variances_of] computing the variances of `BooleanFunction`
#4 [check_well_formed] checking that `BooleanFunction` is well-formed
#5 [check_mod_type_wf] checking that types are well-formed in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack

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

Minimized:

#![feature(generic_const_exprs)]

pub struct BooleanFunction<T = [u8; 1 + 1]>(T);

impl BooleanFunction {}

@cyrgani
Copy link
Contributor

cyrgani commented Aug 31, 2024

This is a duplicate of #117460.

@thomasarmel
Copy link
Author

This is a duplicate of #117460.

Ok I'll close it so

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 31, 2024
@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
@fmease fmease added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Aug 31, 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

6 participants