Skip to content

ICE: Unexpected type for 'Ref' constructor: *const &'{erased} () #126648

Closed

Description

@matthiaskrgr

snippet:

struct Outest(*const &'a ());

fn make() -> Outest {}

fn main() {
    if let Outest("foo") = make() {}
}

Version information

rustc 1.81.0-nightly (dd104ef16 2024-06-18)
binary: rustc
commit-hash: dd104ef16315e2387fe94e8c43eb5a66e3dbd660
commit-date: 2024-06-18
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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

Program output

error[E0261]: use of undeclared lifetime name `'a`
 --> /tmp/icemaker_global_tempdir.TgpW6JrktGaA/rustc_testrunner_tmpdir_reporting.7eRm4vVFAtEm/mvce.rs:1:23
  |
1 | struct Outest(*const &'a ());
  |              -        ^^ undeclared lifetime
  |              |
  |              help: consider introducing lifetime `'a` here: `<'a>`

error[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.TgpW6JrktGaA/rustc_testrunner_tmpdir_reporting.7eRm4vVFAtEm/mvce.rs:3:14
  |
3 | fn make() -> Outest {}
  |    ----      ^^^^^^ expected `Outest`, found `()`
  |    |
  |    implicitly returns `()` as its body has no tail or `return` expression

error: internal compiler error: compiler/rustc_pattern_analysis/src/rustc.rs:241:22: Unexpected type for `Ref` constructor: *const &'{erased} ()

thread 'rustc' panicked at compiler/rustc_pattern_analysis/src/rustc.rs:241:22:
Box<dyn Any>
stack backtrace:
   0:     0x731938db2935 - std::backtrace_rs::backtrace::libunwind::trace::h24001de405a19c29
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x731938db2935 - std::backtrace_rs::backtrace::trace_unsynchronized::h52cb31f58d87e795
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x731938db2935 - std::sys::backtrace::_print_fmt::ha0a4a385e6305dc9
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/sys/backtrace.rs:68:5
   3:     0x731938db2935 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd2ac9d261fff2c5c
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/sys/backtrace.rs:44:22
   4:     0x731938e034db - core::fmt::rt::Argument::fmt::h5dd96858711c38a5
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/core/src/fmt/rt.rs:165:63
   5:     0x731938e034db - core::fmt::write::h9137aaeb0715e137
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/core/src/fmt/mod.rs:1168:21
   6:     0x731938da751f - std::io::Write::write_fmt::h3d543f59fe71748a
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/io/mod.rs:1835:15
   7:     0x731938db270e - std::sys::backtrace::_print::h4a7caef85c10fa0d
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/sys/backtrace.rs:47:5
   8:     0x731938db270e - std::sys::backtrace::print::hf1ff8c4b50b84478
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/sys/backtrace.rs:34:9
   9:     0x731938db5149 - std::panicking::default_hook::{{closure}}::h76d1d90acd3a4473
  10:     0x731938db4eec - std::panicking::default_hook::h2a49ac4243aa5140
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/panicking.rs:292:9
  11:     0x7319354acd2f - std[49f1045a74567fa7]::panicking::update_hook::<alloc[5df14249ca9505f2]::boxed::Box<rustc_driver_impl[db4e8f03b5696bb3]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x731938db5a6f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h25f6191eb839a16b
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/alloc/src/boxed.rs:2076:9
  13:     0x731938db5a6f - std::panicking::rust_panic_with_hook::hc9c5e69e405d5d6c
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/panicking.rs:804:13
  14:     0x7319354dd7e1 - std[49f1045a74567fa7]::panicking::begin_panic::<rustc_errors[f1c452f0768a3196]::ExplicitBug>::{closure#0}
  15:     0x7319354da596 - std[49f1045a74567fa7]::sys::backtrace::__rust_end_short_backtrace::<std[49f1045a74567fa7]::panicking::begin_panic<rustc_errors[f1c452f0768a3196]::ExplicitBug>::{closure#0}, !>
  16:     0x7319354da276 - std[49f1045a74567fa7]::panicking::begin_panic::<rustc_errors[f1c452f0768a3196]::ExplicitBug>
  17:     0x7319354e6d31 - <rustc_errors[f1c452f0768a3196]::diagnostic::BugAbort as rustc_errors[f1c452f0768a3196]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7319359bf58c - rustc_middle[1b5811ec6d2edbd2]::util::bug::opt_span_bug_fmt::<rustc_span[b2dab8d5db9c06d4]::span_encoding::Span>::{closure#0}
  19:     0x7319359a8ada - rustc_middle[1b5811ec6d2edbd2]::ty::context::tls::with_opt::<rustc_middle[1b5811ec6d2edbd2]::util::bug::opt_span_bug_fmt<rustc_span[b2dab8d5db9c06d4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7319359a895b - rustc_middle[1b5811ec6d2edbd2]::ty::context::tls::with_context_opt::<rustc_middle[1b5811ec6d2edbd2]::ty::context::tls::with_opt<rustc_middle[1b5811ec6d2edbd2]::util::bug::opt_span_bug_fmt<rustc_span[b2dab8d5db9c06d4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x73193346c250 - rustc_middle[1b5811ec6d2edbd2]::util::bug::bug_fmt
  22:     0x731937004d48 - rustc_pattern_analysis[9ec12d2f5d12a80]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[9ec12d2f5d12a80]::rustc::RustcPatCtxt>::{closure#0}
  23:     0x731936ffee69 - rustc_pattern_analysis[9ec12d2f5d12a80]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[9ec12d2f5d12a80]::rustc::RustcPatCtxt>::{closure#0}
  24:     0x731936ff92bc - rustc_pattern_analysis[9ec12d2f5d12a80]::analyze_match
  25:     0x731933de2804 - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor>::is_let_irrefutable
  26:     0x731933ddd05d - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  27:     0x731933ddc69d - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  28:     0x731933ddcbc9 - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  29:     0x731933ddc69d - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  30:     0x731933ddd504 - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  31:     0x731933ddc69d - <rustc_mir_build[10942160e2184657]::thir::pattern::check_match::MatchVisitor as rustc_middle[1b5811ec6d2edbd2]::thir::visit::Visitor>::visit_expr
  32:     0x731936bf41be - rustc_mir_build[10942160e2184657]::thir::pattern::check_match::check_match
  33:     0x731936bf3dd5 - rustc_query_impl[ed5fbfae2043678b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ed5fbfae2043678b]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 1usize]>>
  34:     0x731936bf347f - rustc_query_system[f4d6069fb68f5c49]::query::plumbing::try_execute_query::<rustc_query_impl[ed5fbfae2043678b]::DynamicConfig<rustc_query_system[f4d6069fb68f5c49]::query::caches::VecCache<rustc_span[b2dab8d5db9c06d4]::def_id::LocalDefId, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ed5fbfae2043678b]::plumbing::QueryCtxt, false>
  35:     0x731936bf31dd - rustc_query_impl[ed5fbfae2043678b]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  36:     0x731936c0bcc8 - rustc_mir_build[10942160e2184657]::build::mir_build
  37:     0x731936c0b38e - rustc_query_impl[ed5fbfae2043678b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ed5fbfae2043678b]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 8usize]>>
  38:     0x731936bbe0ae - rustc_query_system[f4d6069fb68f5c49]::query::plumbing::try_execute_query::<rustc_query_impl[ed5fbfae2043678b]::DynamicConfig<rustc_query_system[f4d6069fb68f5c49]::query::caches::VecCache<rustc_span[b2dab8d5db9c06d4]::def_id::LocalDefId, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ed5fbfae2043678b]::plumbing::QueryCtxt, false>
  39:     0x731936bbdbcd - rustc_query_impl[ed5fbfae2043678b]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  40:     0x731936bff048 - rustc_mir_build[10942160e2184657]::check_unsafety::check_unsafety
  41:     0x731936bfedf1 - rustc_query_impl[ed5fbfae2043678b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ed5fbfae2043678b]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 0usize]>>
  42:     0x731936bfdeea - rustc_query_system[f4d6069fb68f5c49]::query::plumbing::try_execute_query::<rustc_query_impl[ed5fbfae2043678b]::DynamicConfig<rustc_query_system[f4d6069fb68f5c49]::query::caches::VecCache<rustc_span[b2dab8d5db9c06d4]::def_id::LocalDefId, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ed5fbfae2043678b]::plumbing::QueryCtxt, false>
  43:     0x731936bfdb0b - rustc_query_impl[ed5fbfae2043678b]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  44:     0x731937203d2a - rustc_interface[c6ece38a3a908c28]::passes::analysis
  45:     0x731937202e07 - rustc_query_impl[ed5fbfae2043678b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ed5fbfae2043678b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7319376360a5 - rustc_query_system[f4d6069fb68f5c49]::query::plumbing::try_execute_query::<rustc_query_impl[ed5fbfae2043678b]::DynamicConfig<rustc_query_system[f4d6069fb68f5c49]::query::caches::SingleCache<rustc_middle[1b5811ec6d2edbd2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ed5fbfae2043678b]::plumbing::QueryCtxt, false>
  47:     0x731937635e0f - rustc_query_impl[ed5fbfae2043678b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7319374dd3d2 - rustc_interface[c6ece38a3a908c28]::interface::run_compiler::<core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>, rustc_driver_impl[db4e8f03b5696bb3]::run_compiler::{closure#0}>::{closure#1}
  49:     0x7319374b54c9 - std[49f1045a74567fa7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c6ece38a3a908c28]::util::run_in_thread_with_globals<rustc_interface[c6ece38a3a908c28]::util::run_in_thread_pool_with_globals<rustc_interface[c6ece38a3a908c28]::interface::run_compiler<core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>, rustc_driver_impl[db4e8f03b5696bb3]::run_compiler::{closure#0}>::{closure#1}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>::{closure#0}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>
  50:     0x7319374b527a - <<std[49f1045a74567fa7]::thread::Builder>::spawn_unchecked_<rustc_interface[c6ece38a3a908c28]::util::run_in_thread_with_globals<rustc_interface[c6ece38a3a908c28]::util::run_in_thread_pool_with_globals<rustc_interface[c6ece38a3a908c28]::interface::run_compiler<core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>, rustc_driver_impl[db4e8f03b5696bb3]::run_compiler::{closure#0}>::{closure#1}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>::{closure#0}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3c5d2e85893f84f8]::result::Result<(), rustc_span[b2dab8d5db9c06d4]::ErrorGuaranteed>>::{closure#2} as core[3c5d2e85893f84f8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x731938dbf8eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haf6c6ed15ef7c4b2
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/alloc/src/boxed.rs:2062:9
  52:     0x731938dbf8eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3648257e1237816c
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/alloc/src/boxed.rs:2062:9
  53:     0x731938dbf8eb - std::sys::pal::unix::thread::Thread::new::thread_start::h379e689399d87cbf
                               at /rustc/dd104ef16315e2387fe94e8c43eb5a66e3dbd660/library/std/src/sys/pal/unix/thread.rs:108:17
  54:     0x731938b58ded - <unknown>
  55:     0x731938bdc0dc - <unknown>
  56:                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.81.0-nightly (dd104ef16 2024-06-18) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_match] match-checking `main`
#1 [mir_built] building MIR for `main`
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0261, E0308.
For more information about an error, try `rustc --explain E0261`.

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.
    on Jun 18, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 18, 2024
  3. changed the title [-]ICE: `Unexpected type for `Ref` constructor: *const &'{erased} ()`[/-] [+]ICE: `Unexpected type for 'Ref' constructor: *const &'{erased} ()`[/+] on Jun 18, 2024
  4. GrigorenkoPV commented on Jun 19, 2024

    @GrigorenkoPV
    Contributor

    searched nightlies: from nightly-2022-02-19 to nightly-2024-06-19
    regressed nightly: nightly-2024-03-22
    searched commit range: 1388d7a...0ad927c
    regressed commit: 6a6cd65 (#122803, which is a rollup)
    Same as regressed PR as in #126666

  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 23, 2024
  6. matthiaskrgr commented on Jun 23, 2024

    @matthiaskrgr
    MemberAuthor

    probably #122749

  7. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Jun 30, 2024
  8. added 3 commits that reference this issue on Jul 4, 2024
    7b804d2
    567809d
    c92a8e4
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

    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