fork/rust

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

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

master
7.8 KiB159 linesraw
1$DIR/auxiliary/used_inline_crate.rs:
2   LL|       |#![allow(unused_assignments, unused_variables)]
3   LL|       |// Verify that coverage works with optimizations:
4   LL|       |// compile-flags: -C opt-level=3
5   LL|       |
6   LL|       |use std::fmt::Debug;
7   LL|       |
8   LL|      1|pub fn used_function() {
9   LL|      1|    // Initialize test constants in a way that cannot be determined at compile time, to ensure
10   LL|      1|    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
11   LL|      1|    // dependent conditions.
12   LL|      1|    let is_true = std::env::args().len() == 1;
13   LL|      1|    let mut countdown = 0;
14   LL|      1|    if is_true {
15   LL|      1|        countdown = 10;
16   LL|      1|    }
17                   ^0
18   LL|      1|    use_this_lib_crate();
19   LL|      1|}
20   LL|       |
21   LL|       |#[inline(always)]
22   LL|      1|pub fn used_inline_function() {
23   LL|      1|    // Initialize test constants in a way that cannot be determined at compile time, to ensure
24   LL|      1|    // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
25   LL|      1|    // dependent conditions.
26   LL|      1|    let is_true = std::env::args().len() == 1;
27   LL|      1|    let mut countdown = 0;
28   LL|      1|    if is_true {
29   LL|      1|        countdown = 10;
30   LL|      1|    }
31                   ^0
32   LL|      1|    use_this_lib_crate();
33   LL|      1|}
34   LL|       |
35   LL|       |#[inline(always)]
36   LL|      2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
37   LL|      2|    println!("used_only_from_bin_crate_generic_function with {:?}", arg);
38   LL|      2|}
39  ------------------
40  | Unexecuted instantiation: used_inline_crate::used_only_from_bin_crate_generic_function::<_>
41  ------------------
42  | used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
43  |   LL|      1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
44  |   LL|      1|    println!("used_only_from_bin_crate_generic_function with {:?}", arg);
45  |   LL|      1|}
46  ------------------
47  | used_inline_crate::used_only_from_bin_crate_generic_function::<&str>:
48  |   LL|      1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
49  |   LL|      1|    println!("used_only_from_bin_crate_generic_function with {:?}", arg);
50  |   LL|      1|}
51  ------------------
52   LL|       |// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)
53   LL|       |
54   LL|       |#[inline(always)]
55   LL|      4|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
56   LL|      4|    println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
57   LL|      4|}
58  ------------------
59  | used_inline_crate::used_only_from_this_lib_crate_generic_function::<&str>:
60  |   LL|      2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
61  |   LL|      2|    println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
62  |   LL|      2|}
63  ------------------
64  | used_inline_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
65  |   LL|      2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
66  |   LL|      2|    println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
67  |   LL|      2|}
68  ------------------
69   LL|       |
70   LL|       |#[inline(always)]
71   LL|      3|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
72   LL|      3|    println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
73   LL|      3|}
74  ------------------
75  | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>:
76  |   LL|      2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
77  |   LL|      2|    println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
78  |   LL|      2|}
79  ------------------
80  | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
81  |   LL|      1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
82  |   LL|      1|    println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
83  |   LL|      1|}
84  ------------------
85   LL|       |
86   LL|       |#[inline(always)]
87   LL|      3|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
88   LL|      3|    println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
89   LL|      3|}
90  ------------------
91  | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
92  |   LL|      1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
93  |   LL|      1|    println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
94  |   LL|      1|}
95  ------------------
96  | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
97  |   LL|      2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
98  |   LL|      2|    println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
99  |   LL|      2|}
100  ------------------
101   LL|       |
102   LL|       |#[inline(always)]
103   LL|      0|pub fn unused_generic_function<T: Debug>(arg: T) {
104   LL|      0|    println!("unused_generic_function with {:?}", arg);
105   LL|      0|}
106   LL|       |
107   LL|       |#[inline(always)]
108   LL|      0|pub fn unused_function() {
109   LL|      0|    let is_true = std::env::args().len() == 1;
110   LL|      0|    let mut countdown = 2;
111   LL|      0|    if !is_true {
112   LL|      0|        countdown = 20;
113   LL|      0|    }
114   LL|      0|}
115   LL|       |
116   LL|       |#[inline(always)]
117   LL|       |#[allow(dead_code)]
118   LL|      0|fn unused_private_function() {
119   LL|      0|    let is_true = std::env::args().len() == 1;
120   LL|      0|    let mut countdown = 2;
121   LL|      0|    if !is_true {
122   LL|      0|        countdown = 20;
123   LL|      0|    }
124   LL|      0|}
125   LL|       |
126   LL|      2|fn use_this_lib_crate() {
127   LL|      2|    used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
128   LL|      2|    used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
129   LL|      2|        "used from library used_crate.rs",
130   LL|      2|    );
131   LL|      2|    let some_vec = vec![5, 6, 7, 8];
132   LL|      2|    used_only_from_this_lib_crate_generic_function(some_vec);
133   LL|      2|    used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
134   LL|      2|}
135
136$DIR/uses_inline_crate.rs:
137   LL|       |// This test was failing on Linux for a while due to #110393 somehow making
138   LL|       |// the unused functions not instrumented, but it seems to be fine now.
139   LL|       |
140   LL|       |// Validates coverage now works with optimizations
141   LL|       |// compile-flags: -C opt-level=3
142   LL|       |
143   LL|       |#![allow(unused_assignments, unused_variables)]
144   LL|       |
145   LL|       |// aux-build:used_inline_crate.rs
146   LL|       |extern crate used_inline_crate;
147   LL|       |
148   LL|      1|fn main() {
149   LL|      1|    used_inline_crate::used_function();
150   LL|      1|    used_inline_crate::used_inline_function();
151   LL|      1|    let some_vec = vec![1, 2, 3, 4];
152   LL|      1|    used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec);
153   LL|      1|    used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs");
154   LL|      1|    used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec);
155   LL|      1|    used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
156   LL|      1|        "interesting?",
157   LL|      1|    );
158   LL|      1|}
159