fork/rust

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

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

master
2.4 KiB67 linesraw
1   LL|       |#![allow(unused_assignments)]
2   LL|       |// failure-status: 1
3   LL|       |
4   LL|       |struct Firework<T> where T: Copy + std::fmt::Display {
5   LL|       |    strength: T,
6   LL|       |}
7   LL|       |
8   LL|       |impl<T> Firework<T> where T: Copy + std::fmt::Display {
9   LL|       |    #[inline(always)]
10   LL|      3|    fn set_strength(&mut self, new_strength: T) {
11   LL|      3|        self.strength = new_strength;
12   LL|      3|    }
13  ------------------
14  | <generics::Firework<f64>>::set_strength:
15  |   LL|      2|    fn set_strength(&mut self, new_strength: T) {
16  |   LL|      2|        self.strength = new_strength;
17  |   LL|      2|    }
18  ------------------
19  | <generics::Firework<i32>>::set_strength:
20  |   LL|      1|    fn set_strength(&mut self, new_strength: T) {
21  |   LL|      1|        self.strength = new_strength;
22  |   LL|      1|    }
23  ------------------
24   LL|       |}
25   LL|       |
26   LL|       |impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
27   LL|       |    #[inline(always)]
28   LL|      2|    fn drop(&mut self) {
29   LL|      2|        println!("BOOM times {}!!!", self.strength);
30   LL|      2|    }
31  ------------------
32  | <generics::Firework<f64> as core::ops::drop::Drop>::drop:
33  |   LL|      1|    fn drop(&mut self) {
34  |   LL|      1|        println!("BOOM times {}!!!", self.strength);
35  |   LL|      1|    }
36  ------------------
37  | <generics::Firework<i32> as core::ops::drop::Drop>::drop:
38  |   LL|      1|    fn drop(&mut self) {
39  |   LL|      1|        println!("BOOM times {}!!!", self.strength);
40  |   LL|      1|    }
41  ------------------
42   LL|       |}
43   LL|       |
44   LL|      1|fn main() -> Result<(), u8> {
45   LL|      1|    let mut firecracker = Firework { strength: 1 };
46   LL|      1|    firecracker.set_strength(2);
47   LL|      1|
48   LL|      1|    let mut tnt = Firework { strength: 100.1 };
49   LL|      1|    tnt.set_strength(200.1);
50   LL|      1|    tnt.set_strength(300.3);
51   LL|      1|
52   LL|      1|    if true {
53   LL|      1|        println!("Exiting with error...");
54   LL|      1|        return Err(1);
55   LL|      0|    }
56   LL|      0|
57   LL|      0|    let _ = Firework { strength: 1000 };
58   LL|      0|
59   LL|      0|    Ok(())
60   LL|      1|}
61   LL|       |
62   LL|       |// Expected program output:
63   LL|       |//   Exiting with error...
64   LL|       |//   BOOM times 100!!!
65   LL|       |//   BOOM times 1!!!
66   LL|       |//   Error: 1
67