Skip to content

[ICE]: Unexpected type for constructor Variant(0): *const u8 #162393

Description

@matthiaskrgr

similar to #162389

Code

#![feature(macroless_generic_const_args)]
#![feature(generic_const_args, min_generic_const_args)]
const C_INNER: (*const u8, u8) = (None::<u8>, None::<u8>);

fn foo2(x: *const u8) {
    match (x, 1) {
        C_INNER => {}
        _ => {}
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (5a2be9f5f 2026-09-06)
binary: rustc
commit-hash: 5a2be9f5f075d31e3ca5526b5b029881ce441253
commit-date: 2026-09-06
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Error output

<output>
Backtrace

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

warning: the feature `generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 2.rs:2:12
  |
2 | #![feature(generic_const_args, min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 2.rs:2:32
  |
2 | #![feature(generic_const_args, min_generic_const_args)]
  |                                ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information

error[E0741]: `(*const u8, u8)` can't be used as a const parameter type
 --> 2.rs:3:16
  |
3 | const C_INNER: (*const u8, u8) = (None::<u8>, None::<u8>);
  |                ^^^^^^^^^^^^^^^
  |
  = note: `*const u8` must implement `ConstParamTy_`, but it does not

error: the constant `Option::<u8>::None` is not of type `*const u8`
 --> 2.rs:3:1
  |
3 | const C_INNER: (*const u8, u8) = (None::<u8>, None::<u8>);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `Option<u8>`

error: internal compiler error: /rustc-dev/5a2be9f5f075d31e3ca5526b5b029881ce441253/compiler/rustc_pattern_analysis/src/rustc.rs:260:22: Unexpected type for constructor `Variant(0)`: *const u8


thread 'rustc' (2753991) panicked at /rustc-dev/5a2be9f5f075d31e3ca5526b5b029881ce441253/compiler/rustc_pattern_analysis/src/rustc.rs:260:22:
Box<dyn Any>
stack backtrace:
   0:     0x7f502fcc9e96 - <<std[5ec8abe359b480c3]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[cc0c7b2677a049b0]::fmt::Display>::fmt
   1:     0x7f50304086e1 - core[cc0c7b2677a049b0]::fmt::write
   2:     0x7f502fcdef5c - <std[5ec8abe359b480c3]::sys::stdio::unix::Stderr as core[cc0c7b2677a049b0]::io::write::Write>::write_fmt
   3:     0x7f502fc9c73a - std[5ec8abe359b480c3]::panicking::default_hook::{closure#0}
   4:     0x7f502fcbe193 - std[5ec8abe359b480c3]::panicking::default_hook
   5:     0x7f502ec0833f - std[5ec8abe359b480c3]::panicking::update_hook::<alloc[b99aabfda2005865]::boxed::Box<rustc_driver_impl[38c671086a39786d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f502fcbe632 - std[5ec8abe359b480c3]::panicking::panic_with_hook
   7:     0x7f502ec36bf4 - std[5ec8abe359b480c3]::panicking::begin_panic::<rustc_errors[f3a148d1d43c5775]::ExplicitBug>::{closure#0}
   8:     0x7f502ec2f6ce - std[5ec8abe359b480c3]::sys::backtrace::__rust_end_short_backtrace::<std[5ec8abe359b480c3]::panicking::begin_panic<rustc_errors[f3a148d1d43c5775]::ExplicitBug>::{closure#0}, !>
   9:     0x7f502ec2d76e - std[5ec8abe359b480c3]::panicking::begin_panic::<rustc_errors[f3a148d1d43c5775]::ExplicitBug>
  10:     0x7f502ec424c1 - <rustc_errors[f3a148d1d43c5775]::diagnostic::BugAbort as rustc_errors[f3a148d1d43c5775]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f502f1e8549 - rustc_middle[db42a250e1d90d2a]::util::bug::opt_span_bug_fmt::<rustc_span[3a7a1f7602a8ac7]::span_encoding::Span>::{closure#0}
  12:     0x7f502f1e8982 - rustc_middle[db42a250e1d90d2a]::ty::context::tls::with_opt::<rustc_middle[db42a250e1d90d2a]::util::bug::opt_span_bug_fmt<rustc_span[3a7a1f7602a8ac7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f502f1d3bf0 - rustc_middle[db42a250e1d90d2a]::ty::context::tls::with_context_opt::<rustc_middle[db42a250e1d90d2a]::ty::context::tls::with_opt<rustc_middle[db42a250e1d90d2a]::util::bug::opt_span_bug_fmt<rustc_span[3a7a1f7602a8ac7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f502bea96d4 - rustc_middle[db42a250e1d90d2a]::util::bug::bug_fmt
  15:     0x7f5030b5d226 - rustc_pattern_analysis[fc05db769bcad669]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[fc05db769bcad669]::rustc::RustcPatCtxt>
  16:     0x7f5030b5c3cc - rustc_pattern_analysis[fc05db769bcad669]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[fc05db769bcad669]::rustc::RustcPatCtxt>
  17:     0x7f5030b58f91 - rustc_pattern_analysis[fc05db769bcad669]::rustc::analyze_match
  18:     0x7f502d210e25 - <rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::MatchVisitor>::check_match
  19:     0x7f5030ac8cc0 - <rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::MatchVisitor as rustc_middle[db42a250e1d90d2a]::thir::visit::Visitor>::visit_expr
  20:     0x7f5030ac8884 - <rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::MatchVisitor as rustc_middle[db42a250e1d90d2a]::thir::visit::Visitor>::visit_expr
  21:     0x7f5030ac88ef - <rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::MatchVisitor as rustc_middle[db42a250e1d90d2a]::thir::visit::Visitor>::visit_expr
  22:     0x7f5030ac8884 - <rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::MatchVisitor as rustc_middle[db42a250e1d90d2a]::thir::visit::Visitor>::visit_expr
  23:     0x7f5030ac9dd1 - rustc_mir_build[17e5d1f56add629e]::thir::pattern::check_match::check_match
  24:     0x7f5030ac9a07 - rustc_query_impl[edb13fe6529c35bd]::query_vtables::check_match::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f5031123a5f - rustc_query_impl[edb13fe6529c35bd]::execution::try_execute_query::<rustc_data_structures[9fb070120d1c0b6c]::vec_cache::VecCache<rustc_span[3a7a1f7602a8ac7]::def_id::LocalDefId, rustc_middle[db42a250e1d90d2a]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[db42a250e1d90d2a]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7f50311237d5 - rustc_query_impl[edb13fe6529c35bd]::query_vtables::check_match::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f5030eb3431 - rustc_mir_build[17e5d1f56add629e]::builder::build_mir_inner_impl
  28:     0x7f503042402a - rustc_mir_transform[8c3b83de2da6cd3b]::mir_built
  29:     0x7f5030aa5735 - rustc_query_impl[edb13fe6529c35bd]::execution::try_execute_query::<rustc_data_structures[9fb070120d1c0b6c]::vec_cache::VecCache<rustc_span[3a7a1f7602a8ac7]::def_id::LocalDefId, rustc_middle[db42a250e1d90d2a]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[db42a250e1d90d2a]::dep_graph::graph::DepNodeIndex>, false>
  30:     0x7f5030aa5427 - rustc_query_impl[edb13fe6529c35bd]::query_vtables::mir_built::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f5030abb580 - rustc_mir_build[17e5d1f56add629e]::check_unsafety::check_unsafety
  32:     0x7f5030aa92de - rustc_query_impl[edb13fe6529c35bd]::execution::try_execute_query::<rustc_data_structures[9fb070120d1c0b6c]::vec_cache::VecCache<rustc_span[3a7a1f7602a8ac7]::def_id::LocalDefId, rustc_middle[db42a250e1d90d2a]::query::erase::ErasedData<[u8; 0usize]>, rustc_middle[db42a250e1d90d2a]::dep_graph::graph::DepNodeIndex>, false>
  33:     0x7f5030aa9055 - rustc_query_impl[edb13fe6529c35bd]::query_vtables::check_unsafety::execute_query_non_incr::__rust_end_short_backtrace
  34:     0x7f5030aa7e53 - <rustc_middle[db42a250e1d90d2a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[44c3ff40fa2e592b]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  35:     0x7f5030aa724e - rustc_interface[44c3ff40fa2e592b]::passes::analysis
  36:     0x7f503167b10a - rustc_query_impl[edb13fe6529c35bd]::execution::try_execute_query::<rustc_middle[db42a250e1d90d2a]::query::caches::SingleCache<rustc_middle[db42a250e1d90d2a]::query::erase::ErasedData<[u8; 0usize]>>, false>
  37:     0x7f503167aeab - rustc_query_impl[edb13fe6529c35bd]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  38:     0x7f5031722fcc - rustc_interface[44c3ff40fa2e592b]::interface::run_compiler::<(), rustc_driver_impl[38c671086a39786d]::run_compiler::{closure#0}>::{closure#2}
  39:     0x7f50318354a4 - std[5ec8abe359b480c3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[44c3ff40fa2e592b]::util::run_in_thread_with_globals<rustc_interface[44c3ff40fa2e592b]::util::run_in_thread_pool_with_globals<rustc_interface[44c3ff40fa2e592b]::interface::run_compiler<(), rustc_driver_impl[38c671086a39786d]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7f503183524b - <std[5ec8abe359b480c3]::thread::lifecycle::spawn_unchecked<rustc_interface[44c3ff40fa2e592b]::util::run_in_thread_with_globals<rustc_interface[44c3ff40fa2e592b]::util::run_in_thread_pool_with_globals<rustc_interface[44c3ff40fa2e592b]::interface::run_compiler<(), rustc_driver_impl[38c671086a39786d]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cc0c7b2677a049b0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f5031838507 - <std[5ec8abe359b480c3]::sys::thread::unix::Thread>::new::thread_start
  42:     0x7f502a8980a2 - <unknown>
  43:     0x7f502a92080c - <unknown>
  44:                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: please attach the file at `/tmp/reports/rustc-ice-2026-09-06T22_28_22-2753989.txt` to your bug report

note: rustc 1.100.0-nightly (5a2be9f5f 2026-09-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_match] match-checking `foo2`
#1 [mir_built] building MIR for `foo2`
#2 [check_unsafety] unsafety-checking `foo2`
#3 [analysis] running analysis passes on crate `2`
end of query stack
error: aborting due to 3 previous errors; 3 warnings emitted

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

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)
    F-gca_const_items`#![feature(gca_const_items)]` (previously: `generic_const_args`)
    on Sep 6, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 6, 2026
  3. lsunsi commented on Sep 8, 2026

    @lsunsi
    Contributor

    Seems to come from 0f819a1 according to bisect

  4. malezjaa commented on Sep 13, 2026

    @malezjaa
    Contributor

    no longer reproduces since nightly-2026-09-12 ada41e1 (found by bisect)

    @rustbot label -needs-triage +E-needs-test

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 13, 2026
  6. lsunsi commented on Sep 13, 2026

    @lsunsi
    Contributor

    @rustbot claim

  7. lsunsi commented on Sep 13, 2026

    @lsunsi
    Contributor

    @malezjaa thanks for the tip, I added the code as a test and validated the test fails in earlier nightly

  8. added a commit that references this issue on Sep 14, 2026
    360ab3e
  9. added a commit that references this issue on Sep 14, 2026
    3f49d5f
  10. 2 remaining items

  11. added a commit that references this issue on Sep 14, 2026
    bb77d29
  12. added a commit that references this issue on Sep 17, 2026
    4dfb287
  13. added a commit that references this issue on Sep 21, 2026
    656f536
  14. matthiaskrgr commented on Oct 6, 2026

    @matthiaskrgr
    MemberAuthor

    not fixed

    #![feature(gca_min_const_items)]
    #![feature(gca_macroless_items)]
    #![feature(gca_adts)]
    const C_INNER: (*const u8, u8) = (None::<u8>, None::<u8>);
    
    fn foo2(x: *const u8) {
        match (x, 1) {
            C_INNER => {}
            _ => {}
        }
    }
  15. removed
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Oct 6, 2026
  16. lsunsi commented on Oct 7, 2026

    @lsunsi
    Contributor

    @matthiaskrgr I'll take a look

  17. lsunsi commented on Oct 10, 2026

    @lsunsi
    Contributor

    @matthiaskrgr the original code from the issue really does not ICE on current nightly. just info

  18. lsunsi commented on Oct 12, 2026

    @lsunsi
    Contributor

    I took a look and couldn't figure out. I'll un-assign myself for now

    @rustbot unclaim

  19. ShoyuVanilla commented on Oct 18, 2026

    @ShoyuVanilla
    Member

    I accidentally closed this issue while syncing my fork due to an annoying GitHub quirk 😅
    Well, since I'm here, I might as well take a look at it.

    @rustbot claim

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-gca_const_items`#![feature(gca_const_items)]` (previously: `generic_const_args`)F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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