fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
2.1 KiB48 linesraw
1   LL|       |// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the
2   LL|       |// structure of this test.
3   LL|       |
4   LL|      2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
5                       ^0            ^0      ^0     ^1       ^1 ^0^0
6   LL|       |pub struct Version {
7   LL|       |    major: usize,
8   LL|       |    minor: usize,
9   LL|       |    patch: usize,
10   LL|       |}
11   LL|       |
12   LL|       |impl Version {
13   LL|      2|    pub fn new(major: usize, minor: usize, patch: usize) -> Self {
14   LL|      2|        Self {
15   LL|      2|            major,
16   LL|      2|            minor,
17   LL|      2|            patch,
18   LL|      2|        }
19   LL|      2|    }
20   LL|       |}
21   LL|       |
22   LL|      1|fn main() {
23   LL|      1|    let version_3_2_1 = Version::new(3, 2, 1);
24   LL|      1|    let version_3_3_0 = Version::new(3, 3, 0);
25   LL|      1|
26   LL|      1|    println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0);
27   LL|      1|}
28   LL|       |
29   LL|       |/*
30   LL|       |
31   LL|       |This test verifies a bug was fixed that otherwise generated this error:
32   LL|       |
33   LL|       |thread 'rustc' panicked at 'No counters provided the source_hash for function:
34   LL|       |    Instance {
35   LL|       |        def: Item(WithOptConstParam {
36   LL|       |            did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp),
37   LL|       |            const_param_did: None
38   LL|       |        }),
39   LL|       |        args: []
40   LL|       |    }'
41   LL|       |The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage
42   LL|       |without a code region associated with any `Counter`. Code regions were associated with at least
43   LL|       |one expression, which is allowed, but the `function_source_hash` was only passed to the codegen
44   LL|       |(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the
45   LL|       |`function_source_hash` without a code region, if necessary.
46   LL|       |
47   LL|       |*/
48