-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.F-pattern_types`#![feature(pattern_types)]``#![feature(pattern_types)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#![feature(pattern_types, pattern_type_macro, pattern_type_range_trait)]
use std::io::{Write, stderr};
use std::pat;
type SmallInt = pat::pattern_type!(i8 is 1..=2);
fn main() {
let s: SmallInt = unsafe { core::mem::transmute(1i8) };
let _ = stderr().lock().write_fmt(format_args!("{}\n", unsafe {
core::mem::transmute::<_, i8>(s)
}));
}
Meta
rustc --version --verbose
:
rustc 1.91.0-nightly (cd7cbe818 2025-08-15)
binary: rustc
commit-hash: cd7cbe818e4a66d46fe2df993d1b8518eba8a5cd
commit-date: 2025-08-15
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
Error output
error: internal compiler error: compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs:466:14: debuginfo: unexpected type in type_di_node(): pattern_type!(i8 is 1..=2)
thread 'rustc' (4925) panicked at compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs:466:14:
Box<dyn Any>
Backtrace
0: 0x7f9b4800a183 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb7d54e90572dcd74
1: 0x7f9b48801a7c - core::fmt::write::h23be9617f50201fc
2: 0x7f9b47ff49c3 - std::io::Write::write_fmt::h351b8ef2fbc321e2
3: 0x7f9b48009dd2 - std::sys::backtrace::BacktraceLock::print::hebefa2de1050d28a
4: 0x7f9b47fec600 - std::panicking::default_hook::{{closure}}::hcf87941fd5ee572d
5: 0x7f9b47fec12c - std::panicking::default_hook::h727f8b8141944d56
6: 0x7f9b4705ccc5 - std[220d04c6371a334c]::panicking::update_hook::<alloc[fbc066ed6891e5d8]::boxed::Box<rustc_driver_impl[a29ea5a24b8f2ec1]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f9b47fecc85 - std::panicking::panic_with_hook::hd0a9fb167f5001f7
8: 0x7f9b47096561 - std[220d04c6371a334c]::panicking::begin_panic::<rustc_errors[371fe44f8f203912]::ExplicitBug>::{closure#0}
9: 0x7f9b47096536 - std[220d04c6371a334c]::sys::backtrace::__rust_end_short_backtrace::<std[220d04c6371a334c]::panicking::begin_panic<rustc_errors[371fe44f8f203912]::ExplicitBug>::{closure#0}, !>
10: 0x7f9b470946f0 - std[220d04c6371a334c]::panicking::begin_panic::<rustc_errors[371fe44f8f203912]::ExplicitBug>
11: 0x7f9b47080b01 - <rustc_errors[371fe44f8f203912]::diagnostic::BugAbort as rustc_errors[371fe44f8f203912]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7f9b4769010a - rustc_middle[2c60d99a48b88058]::util::bug::opt_span_bug_fmt::<rustc_span[cefc81db55162a98]::span_encoding::Span>::{closure#0}
13: 0x7f9b4769004a - rustc_middle[2c60d99a48b88058]::ty::context::tls::with_opt::<rustc_middle[2c60d99a48b88058]::util::bug::opt_span_bug_fmt<rustc_span[cefc81db55162a98]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f9b4769001b - rustc_middle[2c60d99a48b88058]::ty::context::tls::with_context_opt::<rustc_middle[2c60d99a48b88058]::ty::context::tls::with_opt<rustc_middle[2c60d99a48b88058]::util::bug::opt_span_bug_fmt<rustc_span[cefc81db55162a98]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f9b446db5c0 - rustc_middle[2c60d99a48b88058]::util::bug::bug_fmt
16: 0x7f9b48ff45e6 - rustc_codegen_llvm[62b9691424515867]::debuginfo::metadata::type_di_node
17: 0x7f9b48ff1d16 - <rustc_codegen_llvm[62b9691424515867]::context::GenericCx<rustc_codegen_llvm[62b9691424515867]::context::FullCx> as rustc_codegen_ssa[7c42cfa78ee9ce8a]::traits::debuginfo::DebugInfoCodegenMethods>::create_dbg_var
18: 0x7f9b49c39636 - rustc_codegen_ssa[7c42cfa78ee9ce8a]::mir::codegen_mir::<rustc_codegen_llvm[62b9691424515867]::builder::GenericBuilder<rustc_codegen_llvm[62b9691424515867]::context::FullCx>>
19: 0x7f9b48988927 - rustc_codegen_llvm[62b9691424515867]::base::compile_codegen_unit::module_codegen
20: 0x7f9b49be10fd - <rustc_codegen_llvm[62b9691424515867]::LlvmCodegenBackend as rustc_codegen_ssa[7c42cfa78ee9ce8a]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
21: 0x7f9b49bdedb7 - <rustc_codegen_llvm[62b9691424515867]::LlvmCodegenBackend as rustc_codegen_ssa[7c42cfa78ee9ce8a]::traits::backend::CodegenBackend>::codegen_crate
22: 0x7f9b498ba170 - <rustc_interface[9560d1bb3c44bdee]::queries::Linker>::codegen_and_build_linker
23: 0x7f9b498b7cfc - rustc_interface[9560d1bb3c44bdee]::passes::create_and_enter_global_ctxt::<core[5c58642aafdad712]::option::Option<rustc_interface[9560d1bb3c44bdee]::queries::Linker>, rustc_driver_impl[a29ea5a24b8f2ec1]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
24: 0x7f9b49a84c83 - rustc_interface[9560d1bb3c44bdee]::interface::run_compiler::<(), rustc_driver_impl[a29ea5a24b8f2ec1]::run_compiler::{closure#0}>::{closure#1}
25: 0x7f9b49965ef8 - std[220d04c6371a334c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9560d1bb3c44bdee]::util::run_in_thread_with_globals<rustc_interface[9560d1bb3c44bdee]::util::run_in_thread_pool_with_globals<rustc_interface[9560d1bb3c44bdee]::interface::run_compiler<(), rustc_driver_impl[a29ea5a24b8f2ec1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
26: 0x7f9b49965bc8 - <<std[220d04c6371a334c]::thread::Builder>::spawn_unchecked_<rustc_interface[9560d1bb3c44bdee]::util::run_in_thread_with_globals<rustc_interface[9560d1bb3c44bdee]::util::run_in_thread_pool_with_globals<rustc_interface[9560d1bb3c44bdee]::interface::run_compiler<(), rustc_driver_impl[a29ea5a24b8f2ec1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5c58642aafdad712]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
27: 0x7f9b499618cb - std::sys::pal::unix::thread::Thread::new::thread_start::h07bc13a8346182c2
28: 0x7f9b432bddf4 - <unknown>
29: 0x7f9b4332d7cc - <unknown>
30: 0x0 - <unknown
I believe this issue can be fixed by adding a case for ty::Pat, along with an implementation for type_di_node. If/when this feature is ready for public use (i.e. can be constructed safely and does static proof-based analysis on its inputs), we should also have infrastructure like this.
Metadata
Metadata
Assignees
Labels
A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.F-pattern_types`#![feature(pattern_types)]``#![feature(pattern_types)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.