Skip to content

ICE with const blocks in rustc_legacy_const_generics #132120

Description

@RCoder01

Code

fn main() {
    const I = 0; // type ommitted
    std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {I});
}

Judging by this comment, I think this might be the same issue as #123077, but I'm posting this just in case its different.

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1

rustc +nightly --version --verbose:

rustc 1.84.0-nightly (4f2f477fd 2024-10-23)
binary: rustc
commit-hash: 4f2f477fded0a47b21ed3f6aeddeafa5db8bf518
commit-date: 2024-10-23
host: x86_64-pc-windows-msvc
release: 1.84.0-nightly
LLVM version: 19.1.1

Error output

error: missing type for `const` item
 --> src/main.rs:3:12
  |
3 |     const I = 0; // type ommitted
  |            ^ help: provide a type for the constant: `: i32`

warning: unreachable expression
 --> src/main.rs:4:48
  |
4 |     std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {I});
  |                                       -------  ^^^^^^^ unreachable expression
  |                                       |
  |                                       any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default
  = note: this warning originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: compiler\rustc_middle\src\ty\typeck_results.rs:334:13: node_type: no type for node HirId(DefId(0:3 ~ main[4b21]::main).9) (const `{I}`)

thread 'rustc' panicked at compiler\rustc_middle\src\ty\typeck_results.rs:334:13:
Box<dyn Any>
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.82.0 (f6e511eec 2024-10-15) running on x86_64-pc-windows-msvc

query stack during panic:
#0 [thir_body] building THIR for `main::{constant#0}`
#1 [check_match] match-checking `main::{constant#0}`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted
Backtrace

error: missing type for `const` item
 --> src/main.rs:3:12
  |
3 |     const I = 0; // type ommitted
  |            ^ help: provide a type for the constant: `: i32`

warning: unreachable expression
 --> src/main.rs:4:48
  |
4 |     std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {I});
  |                                       -------  ^^^^^^^ unreachable expression
  |                                       |
  |                                       any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default
  = note: this warning originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: compiler\rustc_middle\src\ty\typeck_results.rs:334:13: node_type: no type for node HirId(DefId(0:3 ~ main[4b21]::main).9) (const `{I}`)

thread 'rustc' panicked at compiler\rustc_middle\src\ty\typeck_results.rs:334:13:
Box<dyn Any>
stack backtrace:
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.82.0 (f6e511eec 2024-10-15) running on x86_64-pc-windows-msvc

query stack during panic:
#0 [thir_body] building THIR for `main::{constant#0}`
#1 [check_match] match-checking `main::{constant#0}`
#2 [mir_built] building MIR for `main::{constant#0}`
#3 [mir_const_qualif] const checking `main::{constant#0}`
#4 [mir_promoted] promoting constants in MIR for `main::{constant#0}`
#5 [mir_borrowck] borrow-checking `main::{constant#0}`
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

Stable with RUST_BACKTRACE=full

error: missing type for `const` item
 --> src/main.rs:3:12
  |
3 |     const I = 0; // type ommitted
  |            ^ help: provide a type for the constant: `: i32`

warning: unreachable expression
 --> src/main.rs:4:48
  |
4 |     std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {I});
  |                                       -------  ^^^^^^^ unreachable expression
  |                                       |
  |                                       any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default
  = note: this warning originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: compiler\rustc_middle\src\ty\typeck_results.rs:334:13: node_type: no type for node HirId(DefId(0:3 ~ main[4b21]::main).9) (const `{I}`)

thread 'rustc' panicked at compiler\rustc_middle\src\ty\typeck_results.rs:334:13:
Box<dyn Any>
stack backtrace:
   0:     0x7ff8cdf90f51 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff8cdf90f51 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff8cdf90f51 - std::sys::backtrace::_print_fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\backtrace.rs:66
   3:     0x7ff8cdf90f51 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\backtrace.rs:39
   4:     0x7ff8cdfc2629 - core::fmt::rt::Argument::fmt
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\fmt\rt.rs:177
   5:     0x7ff8cdfc2629 - core::fmt::write
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\fmt\mod.rs:1178
   6:     0x7ff8cdf87117 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\io\mod.rs:1823
   7:     0x7ff8cdf94069 - std::panicking::default_hook::closure$1
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:266
   8:     0x7ff8cdf93bec - std::panicking::default_hook
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:293
   9:     0x7ff8cf4e5e40 - memchr
  10:     0x7ff8cdf94a7b - alloc::boxed::impl$50::call
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/alloc\src\boxed.rs:2245
  11:     0x7ff8cdf94a7b - std::panicking::rust_panic_with_hook
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:805
  12:     0x7ff8d0b752c3 - <rustc_hir_pretty[d4687896f5ad7c5a]::State>::print_variant
  13:     0x7ff8d0b67e49 - <rustc_hir_pretty[d4687896f5ad7c5a]::State>::print_variant
  14:     0x7ff8d0b67b69 - <rustc_hir_pretty[d4687896f5ad7c5a]::State>::print_variant
  15:     0x7ff8d0b80745 - <rustc_errors[e23acac42068c390]::diagnostic::BugAbort as rustc_errors[e23acac42068c390]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  16:     0x7ff8d0a96352 - rustc_middle[c5ee28e0fcbaddd6]::util::bug::bug_fmt
  17:     0x7ff8d0a7663d - rustc_middle[c5ee28e0fcbaddd6]::ty::consts::const_param_default
  18:     0x7ff8d0a7645d - rustc_middle[c5ee28e0fcbaddd6]::ty::consts::const_param_default
  19:     0x7ff8d0a96252 - rustc_middle[c5ee28e0fcbaddd6]::util::bug::bug_fmt
  20:     0x7ff8cf37966b - <rustc_middle[c5ee28e0fcbaddd6]::ty::typeck_results::TypeckResults>::node_type
  21:     0x7ff8ce55128b - rustc_mir_build[60441d8c8ae66f5b]::thir::cx::thir_body
  22:     0x7ff8ceb25ed9 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  23:     0x7ff8cea63f69 - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  24:     0x7ff8ceb29c46 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  25:     0x7ff8ce55556e - rustc_mir_build[60441d8c8ae66f5b]::thir::pattern::check_match::check_match
  26:     0x7ff8ceb23eab - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  27:     0x7ff8cea66906 - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  28:     0x7ff8ceb2f1c1 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  29:     0x7ff8ce4f3553 - rustc_mir_build[60441d8c8ae66f5b]::build::mir_build
  30:     0x7ff8ce488fe2 - rustc_mir_transform[b10e5d743bcd5dcb]::mir_built
  31:     0x7ff8ceb25e6b - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  32:     0x7ff8cea6a0d5 - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  33:     0x7ff8ceb29e43 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  34:     0x7ff8ce48867e - rustc_mir_transform[b10e5d743bcd5dcb]::mir_const_qualif
  35:     0x7ff8ceb24aa0 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  36:     0x7ff8cea25087 - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  37:     0x7ff8ceb29d52 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  38:     0x7ff8ce48adbe - rustc_mir_transform[b10e5d743bcd5dcb]::mir_promoted
  39:     0x7ff8ceb242f9 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  40:     0x7ff8cea6418e - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  41:     0x7ff8ceb2a446 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  42:     0x7ff8ce663cdc - rustc_borrowck[22fe30806a045a2c]::mir_borrowck
  43:     0x7ff8ceb2427b - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  44:     0x7ff8cea6a0d5 - rustc_ty_utils[67287b256ac86568]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  45:     0x7ff8ceb2ec73 - rustc_query_impl[1cbfc9fc16052fcf]::plumbing::query_key_hash_verify_all
  46:     0x7ff8ce003024 - rustc_interface[ab63cb8dd572d7f1]::passes::resolver_for_lowering_raw
  47:     0x7ff8cb098000 - rustc_interface[ab63cb8dd572d7f1]::passes::analysis
  48:     0x7ff8cdb815cb - rustc_ty_utils[67287b256ac86568]::ty::adt_sized_constraint
  49:     0x7ff8cdaf1371 - rustc_ty_utils[67287b256ac86568]::ty::adt_sized_constraint
  50:     0x7ff8cdb8a3e7 - rustc_query_impl[1cbfc9fc16052fcf]::query_system
  51:     0x7ff8cb056e21 - _rust_alloc_error_handler
  52:     0x7ff8cb052a16 - _rust_alloc_error_handler
  53:     0x7ff8cb05c5db - _rust_alloc_error_handler
  54:     0x7ff8cdfa640d - alloc::boxed::impl$48::call_once
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/alloc\src\boxed.rs:2231
  55:     0x7ff8cdfa640d - alloc::boxed::impl$48::call_once
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/alloc\src\boxed.rs:2231
  56:     0x7ff8cdfa640d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\sys\pal\windows\thread.rs:55
  57:     0x7ff9796e7374 - BaseThreadInitThunk
  58:     0x7ff97b57cc91 - RtlUserThreadStart

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.82.0 (f6e511eec 2024-10-15) running on x86_64-pc-windows-msvc

query stack during panic:
#0 [thir_body] building THIR for `main::{constant#0}`
#1 [check_match] match-checking `main::{constant#0}`
#2 [mir_built] building MIR for `main::{constant#0}`
#3 [mir_const_qualif] const checking `main::{constant#0}`
#4 [mir_promoted] promoting constants in MIR for `main::{constant#0}`
#5 [mir_borrowck] borrow-checking `main::{constant#0}`
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

Nightly ice file

thread 'rustc' panicked at compiler\rustc_middle\src\ty\typeck_results.rs:316:13:
Box<dyn Any>
stack backtrace:
   0:     0x7ff8cdc5b183 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff8cdc5b183 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff8cdc5b183 - std::backtrace::Backtrace::create
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\backtrace.rs:331
   3:     0x7ff8cdc5b0ca - std::backtrace::Backtrace::force_capture
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\backtrace.rs:312
   4:     0x7ff8cf2b1c6d - memchr
   5:     0x7ff8cdc75de2 - alloc::boxed::impl$50::call
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/alloc\src\boxed.rs:2468
   6:     0x7ff8cdc75de2 - std::panicking::rust_panic_with_hook
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\panicking.rs:809
   7:     0x7ff8d0a89833 - <rustc_hir_pretty[69ef1f3aaab30476]::State>::print_variant
   8:     0x7ff8d0a7b829 - <rustc_hir_pretty[69ef1f3aaab30476]::State>::print_variant
   9:     0x7ff8d0a7b53e - <rustc_hir_pretty[69ef1f3aaab30476]::State>::print_variant
  10:     0x7ff8d0a96d65 - <rustc_errors[1907ea0eb63de487]::diagnostic::BugAbort as rustc_errors[1907ea0eb63de487]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ff8d09a03b2 - rustc_middle[71967749d50205ea]::util::bug::bug_fmt
  12:     0x7ff8d098007d - rustc_middle[71967749d50205ea]::ty::consts::const_param_default
  13:     0x7ff8d097fe96 - rustc_middle[71967749d50205ea]::ty::consts::const_param_default
  14:     0x7ff8d09a02b2 - rustc_middle[71967749d50205ea]::util::bug::bug_fmt
  15:     0x7ff8cf113393 - <rustc_middle[71967749d50205ea]::ty::typeck_results::TypeckResults>::node_type
  16:     0x7ff8ce24fcbd - rustc_mir_build[f8b0ab950f79740]::thir::cx::thir_body
  17:     0x7ff8cea50919 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  18:     0x7ff8ce987ae8 - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  19:     0x7ff8cea54906 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  20:     0x7ff8ce256e5b - rustc_mir_build[f8b0ab950f79740]::thir::pattern::check_match::check_match
  21:     0x7ff8cea4e2fb - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  22:     0x7ff8ce98b7d1 - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  23:     0x7ff8cea59a01 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  24:     0x7ff8ce1f0382 - rustc_mir_build[f8b0ab950f79740]::build::mir_build
  25:     0x7ff8ce1844e2 - rustc_mir_transform[6bbc1dc9f41e12a3]::mir_built
  26:     0x7ff8cea508ab - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  27:     0x7ff8ce9900ea - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  28:     0x7ff8cea54b03 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  29:     0x7ff8ce183d3e - rustc_mir_transform[6bbc1dc9f41e12a3]::mir_const_qualif
  30:     0x7ff8cea4f140 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  31:     0x7ff8ce9388ce - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  32:     0x7ff8cea54a12 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  33:     0x7ff8ce1861a9 - rustc_mir_transform[6bbc1dc9f41e12a3]::mir_promoted
  34:     0x7ff8cea4e849 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  35:     0x7ff8ce98783e - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  36:     0x7ff8cea55116 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  37:     0x7ff8ce3617bf - rustc_borrowck[cc4b62c65061e478]::mir_borrowck
  38:     0x7ff8cea4e7cb - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  39:     0x7ff8ce9900ea - rustc_ty_utils[a9678677049c5a69]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  40:     0x7ff8cea594a3 - rustc_query_impl[6a42b3291b90a984]::plumbing::query_key_hash_verify_all
  41:     0x7ff8cdcef0ca - rustc_interface[77d69e49813c3a24]::passes::resolver_for_lowering_raw
  42:     0x7ff8cacc898e - rustc_interface[77d69e49813c3a24]::passes::analysis
  43:     0x7ff8cd86f9fb - rustc_ty_utils[a9678677049c5a69]::ty::adt_sized_constraint
  44:     0x7ff8cd7855c7 - rustc_ty_utils[a9678677049c5a69]::ty::adt_sized_constraint
  45:     0x7ff8cd875377 - rustc_query_impl[6a42b3291b90a984]::query_system
  46:     0x7ff8cac830e7 - _rust_alloc_error_handler
  47:     0x7ff8cac7ec8f - _rust_alloc_error_handler
  48:     0x7ff8cac88cc8 - _rust_alloc_error_handler
  49:     0x7ff8cdc877bd - alloc::boxed::impl$48::call_once
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/alloc\src\boxed.rs:2454
  50:     0x7ff8cdc877bd - alloc::boxed::impl$48::call_once
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/alloc\src\boxed.rs:2454
  51:     0x7ff8cdc877bd - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/4f2f477fded0a47b21ed3f6aeddeafa5db8bf518\library/std\src\sys\pal\windows\thread.rs:55
  52:     0x7ff9796e7374 - BaseThreadInitThunk
  53:     0x7ff97b57cc91 - RtlUserThreadStart


rustc version: 1.84.0-nightly (4f2f477fd 2024-10-23)
platform: x86_64-pc-windows-msvc

query stack during panic:
#0 [thir_body] building THIR for `main::{constant#0}`
#1 [check_match] match-checking `main::{constant#0}`
#2 [mir_built] building MIR for `main::{constant#0}`
#3 [mir_const_qualif] const checking `main::{constant#0}`
#4 [mir_promoted] promoting constants in MIR for `main::{constant#0}`
#5 [mir_borrowck] borrow-checking `main::{constant#0}`
#6 [analysis] running analysis passes on this crate
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-THIRArea: Typed HIRA-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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