1 LL| |#![feature(coverage_attribute)]
2 LL| |// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3
4 LL| |// Regression test for <https://github.com/rust-lang/rust/issues/117012>.
6 LL| |// If some coverage counters were removed by MIR optimizations, we need to take
7 LL| |// care not to refer to those counter IDs in coverage mappings, and instead
8 LL| |// replace them with a constant zero value. If we don't, `llvm-cov` might see
9 LL| |// a too-large counter ID and silently discard the entire function from its
10 LL| |// coverage reports.
12 LL| 8|#[derive(Debug, PartialEq, Eq)]
17 LL| 1| assert_eq!(Foo(1), Foo(1));
20 LL| 1|fn eq_good_message() {
22 LL| 1| assert_eq!(Foo(1), Foo(1), "message b");
28 LL| 1| assert_ne!(Foo(1), Foo(3));
31 LL| 1|fn ne_good_message() {
33 LL| 1| assert_ne!(Foo(1), Foo(3), "message d");
39 LL| 1| assert_eq!(Foo(1), Foo(3));
42 LL| 1|fn eq_bad_message() {
44 LL| 1| assert_eq!(Foo(1), Foo(3), "message f");
49 LL| 1| assert_ne!(Foo(1), Foo(1));
52 LL| 1|fn ne_bad_message() {
54 LL| 1| assert_ne!(Foo(1), Foo(1), "message h");
60 LL| | eq_good_message();
62 LL| | ne_good_message();
64 LL| | assert!(std::panic::catch_unwind(eq_bad).is_err());
65 LL| | assert!(std::panic::catch_unwind(eq_bad_message).is_err());
66 LL| | assert!(std::panic::catch_unwind(ne_bad).is_err());
67 LL| | assert!(std::panic::catch_unwind(ne_bad_message).is_err());