Skip to content

Commit

Permalink
add test for rust-lang#122301 to cover behavior that's on stable
Browse files Browse the repository at this point in the history
if this ought to be broken it should at least happen intentionally
  • Loading branch information
the8472 committed Mar 15, 2024
1 parent 3cbb932 commit 92da110
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/ui/consts/control-flow/dead_branches_dont_eval.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ check-pass

// issue 122301 - currently the only way to supress
// const eval and codegen of code conditional on some other const

struct Foo<T, const N: usize>(T);

impl<T, const N: usize> Foo<T, N> {
const BAR: () = if N == 0 {
panic!()
};
}

struct Invoke<T, const N: usize>(T);

impl<T, const N: usize> Invoke<T, N> {
const FUN: fn() = if N != 0 {
|| Foo::<T, N>::BAR
} else {
|| {}
};
}

fn main() {
Invoke::<(), 0>::FUN();
}

0 comments on commit 92da110

Please sign in to comment.