Skip to content

ICE: expected int of size 8, but got size 1 #134230

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

Closed
SajjadPourali opened this issue Dec 12, 2024 · 2 comments
Closed

ICE: expected int of size 8, but got size 1 #134230

SajjadPourali opened this issue Dec 12, 2024 · 2 comments
Labels
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.

Comments

@SajjadPourali
Copy link

Is looks similar to #131103

Code

fn main() {}

pub trait IdAllocator<const LEN: u8> { // changing u8 to usize fixes the issue
    fn allocate_new(&mut self) -> [u8; LEN];
}

struct IdAllocatorImpl<const LEN: u8>;

impl IdAllocator<1> for IdAllocatorImpl<1> {
    fn allocate_new(&mut self) -> [u8; 1] {
        todo!()
    }
}

Meta

rustc --version --verbose:

rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.1

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/consts/int.rs:263:13: expected int of size 8, but got size 1
Backtrace

thread 'rustc' panicked at compiler/rustc_middle/src/ty/consts/int.rs:263:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_middle::ty::consts::valtree::ValTree>::try_to_target_usize
   7: <rustc_middle::ty::consts::Const as rustc_type_ir::inherent::Const<rustc_middle::ty::context::TyCtxt>>::try_to_target_usize
   8: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_infer::infer::relate::type_relating::TypeRelating>
   9: <rustc_infer::infer::relate::type_relating::TypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::tys
  10: <core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::iter::adapters::map::Map<core::iter::adapters::chain::Chain<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}>, core::iter::sources::once::Once<((rustc_middle::ty::Ty, rustc_middle::ty::Ty), bool)>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#1}>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#2}> as core::iter::traits::iterator::Iterator>::next
  11: <core::result::Result<rustc_middle::ty::Ty, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>> as rustc_type_ir::interner::CollectAndApply<rustc_middle::ty::Ty, &rustc_middle::ty::list::RawList<(), rustc_middle::ty::Ty>>>::collect_and_apply::<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::iter::adapters::map::Map<core::iter::adapters::chain::Chain<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}>, core::iter::sources::once::Once<((rustc_middle::ty::Ty, rustc_middle::ty::Ty), bool)>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#1}>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#2}>, <rustc_middle::ty::context::TyCtxt>::mk_type_list_from_iter<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::iter::adapters::map::Map<core::iter::adapters::chain::Chain<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}>, core::iter::sources::once::Once<((rustc_middle::ty::Ty, rustc_middle::ty::Ty), bool)>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#1}>>, <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#2}>, core::result::Result<rustc_middle::ty::Ty, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>>>::{closure#0}>
  12: <rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::relate::Relate<rustc_middle::ty::context::TyCtxt>>::relate::<rustc_infer::infer::relate::type_relating::TypeRelating>
  13: <rustc_infer::infer::at::At>::sup::<rustc_type_ir::ty_kind::FnSig<rustc_middle::ty::context::TyCtxt>>
  14: rustc_hir_analysis::check::check::check_impl_items_against_trait
  15: rustc_hir_analysis::check::check::check_item_type
  16: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 2 frames ...]
  17: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_data_structures::sync::parallel::disabled::try_par_for_each_in<&[rustc_hir::hir::ItemId], rustc_span::ErrorGuaranteed, <rustc_middle::hir::ModuleItems>::par_items<rustc_hir_analysis::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  18: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 2 frames ...]
  19: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::disabled::par_for_each_in<&[rustc_hir::hir_id::OwnerId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_hir_analysis::check_crate::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  20: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#0}>
  21: rustc_hir_analysis::check_crate
  22: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  23: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#5}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  25: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.83.0 (90b35a623 2024-11-26) running on aarch64-apple-darwin

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

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

query stack during panic:
#0 [check_well_formed] checking that `<impl at src/main.rs:9:1: 9:43>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `bug` (bin "bug")

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

krtab commented Dec 13, 2024

I think it is a duplicate of #131101

It is anyhow fixed in nightly.

@compiler-errors
Copy link
Member

yep fixed on nightly

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 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. 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