]>
Commit | Line | Data |
---|---|---|
29967ef6 XL |
1 | // This test confirms an earlier problem was resolved, supporting the MIR graph generated by the |
2 | // structure of this test. | |
3 | ||
4 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] | |
5 | pub struct Version { | |
6 | major: usize, | |
fc512014 XL |
7 | minor: usize, // Count: 1 - `PartialOrd` compared `minor` values in 3.2.1 vs. 3.3.0 |
8 | patch: usize, // Count: 0 - `PartialOrd` was determined by `minor` (2 < 3) | |
29967ef6 XL |
9 | } |
10 | ||
11 | impl Version { | |
12 | pub fn new(major: usize, minor: usize, patch: usize) -> Self { | |
13 | Self { | |
14 | major, | |
15 | minor, | |
16 | patch, | |
17 | } | |
18 | } | |
19 | } | |
20 | ||
21 | fn main() { | |
22 | let version_3_2_1 = Version::new(3, 2, 1); | |
23 | let version_3_3_0 = Version::new(3, 3, 0); | |
24 | ||
25 | println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0); | |
26 | } | |
27 | ||
28 | /* | |
29 | ||
30 | This test verifies a bug was fixed that otherwise generated this error: | |
31 | ||
32 | thread 'rustc' panicked at 'No counters provided the source_hash for function: | |
33 | Instance { | |
34 | def: Item(WithOptConstParam { | |
35 | did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), | |
36 | const_param_did: None | |
37 | }), | |
38 | substs: [] | |
39 | }' | |
40 | The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage | |
41 | without a code region associated with any `Counter`. Code regions were associated with at least | |
42 | one expression, which is allowed, but the `function_source_hash` was only passed to the codegen | |
43 | (coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the | |
44 | `function_source_hash` without a code region, if necessary. | |
45 | ||
46 | */ | |
47 | ||
fc512014 XL |
48 | // FIXME(#79626): The derived traits get coverage, which is great, but some of the traits appear |
49 | // to get two coverage execution counts at different positions: | |
50 | // | |
51 | // ```text | |
52 | // 4| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] | |
53 | // ^0 ^0 ^0 ^0 ^1 ^0 ^0^0 | |
54 | // ```text | |
55 | // | |
56 | // `PartialEq`, `PartialOrd`, and `Ord` (and possibly `Eq`, if the trait name was longer than 2 | |
57 | // characters) have counts at their first and last characters. | |
58 | // | |
59 | // Why is this? Why does `PartialOrd` have two values (1 and 0)? This must mean we are checking | |
60 | // distinct coverages, so maybe we don't want to eliminate one of them. Should we merge them? | |
61 | // If merged, do we lose some information? |