Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ fn check_terminator(
check_operand(tcx, discr, span, def_id, body)
}

// FIXME(ecstaticmorse): We probably want to allow `Unreachable` unconditionally.
TerminatorKind::Unreachable if tcx.features().const_if_match => Ok(()),

| TerminatorKind::Abort | TerminatorKind::Unreachable => {
Err((span, "const fn with unreachable code is not stable".into()))
}
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Test for <https://github.com/rust-lang/rust/issues/66756>

// check-pass

#![feature(const_if_match)]

enum E {
A,
B,
C
}

const fn f(e: E) {
match e {
E::A => {}
E::B => {}
E::C => {}
}
}

const fn g(e: E) {
match e {
_ => {}
}
}

fn main() {}