Skip to content

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

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Foo<const N: u8> {
    fn do_x(&self) -> [u8; N];
}

struct Bar;

impl Foo<const 3> for Bar {
    fn do_x(&self) -> [u8; 3] {
        [0u8; 3]
    }
}

original:

trait Foo<const N: u8> {
    fn do_x(&self) -> [u8; N];
}

struct Bar;

const T: usize = 42;

impl Foo<const 3> for Bar {
//~^ERROR expected lifetime, type, or constant, found keyword `const`
    fn do_x(&self) -> [u8; 3] {
        [0u8; 3]
    }
}

fn main() {}

Version information

rustc 1.83.0-nightly (c4f717650 2024-10-01)
binary: rustc
commit-hash: c4f7176501a7d3c19c230b8c9111b2d39142f83a
commit-date: 2024-10-01
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected lifetime, type, or constant, found keyword `const`
 --> /tmp/icemaker_global_tempdir.xhOgY77xz6zM/rustc_testrunner_tmpdir_reporting.0OBRpObgqu4G/mvce.rs:9:10
  |
9 | impl Foo<const 3> for Bar {
  |          ^^^^^
  |
help: the `const` keyword is only needed in the definition of the type
  |
9 - impl Foo<const 3> for Bar {
9 + impl Foo<3> for Bar {
  |

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.xhOgY77xz6zM/rustc_testrunner_tmpdir_reporting.0OBRpObgqu4G/mvce.rs:14:2
   |
14 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.xhOgY77xz6zM/rustc_testrunner_tmpdir_reporting.0OBRpObgqu4G/mvce.rs`

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

thread 'rustc' panicked at compiler/rustc_middle/src/ty/consts/int.rs:263:13:
Box<dyn Any>
stack backtrace:
   0:     0x74626d8daeda - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::had0a4a07d444c243
   1:     0x74626e0033e6 - core::fmt::write::hfa03780471fd40a1
   2:     0x74626f1bd491 - std::io::Write::write_fmt::he88bb98b829c33b1
   3:     0x74626d8dad32 - std::sys::backtrace::BacktraceLock::print::h1e8153a6bf47e7a5
   4:     0x74626d8dd251 - std::panicking::default_hook::{{closure}}::h2d7a6dde612f1b16
   5:     0x74626d8dd084 - std::panicking::default_hook::ha6ce9de3458bcdda
   6:     0x74626c9a486f - std[c1d7bd3f58de7430]::panicking::update_hook::<alloc[29d5ad3c4a91d383]::boxed::Box<rustc_driver_impl[b3d9015aed309aa5]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x74626d8dd968 - std::panicking::rust_panic_with_hook::haf1d2e00d64b82f1
   8:     0x74626c9de321 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}
   9:     0x74626c9d13c6 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_end_short_backtrace::<std[c1d7bd3f58de7430]::panicking::begin_panic<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}, !>
  10:     0x74626c9ccad9 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>
  11:     0x74626c9e7bb1 - <rustc_errors[a2cc27f529684419]::diagnostic::BugAbort as rustc_errors[a2cc27f529684419]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x74626d00ba54 - rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt::<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}
  13:     0x74626cff17ca - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt::<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x74626cff165b - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_context_opt::<rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x74626a5cce60 - rustc_middle[99056c3c142edfd1]::util::bug::bug_fmt
  16:     0x74626f3fdba3 - <rustc_middle[99056c3c142edfd1]::ty::consts::Const as rustc_type_ir[52210652b01e0c85]::inherent::Const<rustc_middle[99056c3c142edfd1]::ty::context::TyCtxt>>::try_to_target_usize.cold
  17:     0x74626e0e6b05 - <rustc_infer[6567e56aed91dd61]::infer::InferCtxt>::super_combine_tys::<rustc_infer[6567e56aed91dd61]::infer::relate::type_relating::TypeRelating>
  18:     0x74626e0e10dd - <rustc_infer[6567e56aed91dd61]::infer::relate::type_relating::TypeRelating as rustc_type_ir[52210652b01e0c85]::relate::TypeRelation<rustc_middle[99056c3c142edfd1]::ty::context::TyCtxt>>::tys
  19:     0x74626a46bbd9 - rustc_hir_analysis[5f12a0460b8fec89]::check::check::check_impl_items_against_trait
  20:     0x74626baea1a2 - rustc_hir_analysis[5f12a0460b8fec89]::check::wfcheck::check_well_formed
  21:     0x74626e3d9727 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  22:     0x74626e3d99b4 - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::VecCache<rustc_hir[a33e640fa4d8b320]::hir_id::OwnerId, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  23:     0x74626e3d9706 - rustc_query_impl[a128c9efc091a24e]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  24:     0x74626e3da4d7 - rustc_hir_analysis[5f12a0460b8fec89]::check::wfcheck::check_mod_type_wf
  25:     0x74626e3da315 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  26:     0x74626ee8c8bb - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::DefaultCache<rustc_span[fbdd09955dfcae25]::def_id::LocalModDefId, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  27:     0x74626ee8c66d - rustc_query_impl[a128c9efc091a24e]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  28:     0x74626e3a5a3b - rustc_hir_analysis[5f12a0460b8fec89]::check_crate
  29:     0x74626e3a26d7 - rustc_interface[89dec4b9d675c708]::passes::run_required_analyses
  30:     0x74626ed0f51e - rustc_interface[89dec4b9d675c708]::passes::analysis
  31:     0x74626ed0f4f1 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  32:     0x74626ee9252e - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::SingleCache<rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  33:     0x74626ee9220f - rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x74626ed1f55e - rustc_interface[89dec4b9d675c708]::interface::run_compiler::<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}
  35:     0x74626edea350 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>
  36:     0x74626edea9ba - <<std[c1d7bd3f58de7430]::thread::Builder>::spawn_unchecked_<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#1} as core[d0cd706d8d014919]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x74626edeadab - std::sys::pal::unix::thread::Thread::new::thread_start::h6a16a471557e53ce
  38:     0x74627042539d - <unknown>
  39:     0x7462704aa49c - <unknown>
  40:                0x0 - <unknown>

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.83.0-nightly (c4f717650 2024-10-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.xhOgY77xz6zM/rustc_testrunner_tmpdir_reporting.0OBRpObgqu4G/mvce.rs:9:1: 9:26>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions