Skip to content

const fn has no result expression #33031

Closed
@nagisa

Description

@nagisa
#![feature(const_fn)]
pub const fn test() {}
const X: () = test();
fn main() {}

ICEs with

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'const fn has no result expression', src/libcore/option.rs:700
stack backtrace:
   1:     0x7fc09db94d37 - sys::backtrace::tracing::imp::write::h8f11a6299019b37aN7u
   2:     0x7fc09dba498b - panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::closure.46063
   3:     0x7fc09dba4505 - panicking::default_hook::he79d5441312473c9vjA
   4:     0x7fc09db62cef - sys_common::unwind::begin_unwind_inner::h850ac67cf2e6431duZt
   5:     0x7fc09db659f8 - sys_common::unwind::begin_unwind_fmt::h7f9772c177da56ceAYt
   6:     0x7fc09db925e1 - rust_begin_unwind
   7:     0x7fc09dbba94f - panicking::panic_fmt::h7b8691efcf0ee41102L
   8:     0x7fc09dbe0c64 - option::expect_failed::h2f7b609e15d08c701RO
   9:     0x7fc098f2d6f2 - eval::eval_const_expr_partial::hd768fd0c71d5d67ewOa
  10:     0x7fc09cf75fd7 - consts::CheckCrateVisitor<'a, 'tcx>::global_expr::h3fa9a0801caa760cgsa
  11:     0x7fc09cf7dd76 - consts::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h4e6b6664f41ad6ddvDa
  12:     0x7fc09cf824d7 - consts::check_crate::hc2396fa9b810de44Hlb
  13:     0x7fc09e0ad934 - driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::closure.30847
  14:     0x7fc09e0ab601 - ty::context::TyCtxt<'tcx>::create_and_enter::h12752561671132360966
  15:     0x7fc09e0a6852 - driver::phase_3_run_analysis_passes::h7514814909072594316
  16:     0x7fc09e0776d1 - driver::compile_input::h7e38a782c304f126Uca
  17:     0x7fc09e063a80 - run_compiler::ha6ad3fc70e3bb8f8IKc
  18:     0x7fc09e060d3b - sys_common::unwind::try::try_fn::h9022798910832087097
  19:     0x7fc09db9256b - __rust_try
  20:     0x7fc09db924fd - sys_common::unwind::inner_try::h42271e72fc2229cdwWt
  21:     0x7fc09e0615ff - boxed::F.FnBox<A>::call_box::h6627780591262321388
  22:     0x7fc09dba2214 - sys::thread::Thread::new::thread_start::h23b56e13da45f381dhz
  23:     0x7fc09692b423 - start_thread
  24:     0x7fc09d80ccbc - clone
  25:                0x0 - <unknown>

The result expression should probably default to unit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions