Skip to content

Commit 0d84e0b

Browse files
committed
Add test case for -Zinline-mir & -Zinstrument-coverage
1 parent 4b6cc0c commit 0d84e0b

11 files changed

+992
-3
lines changed

src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.async.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1| |#![allow(unused_assignments, dead_code)]
22
2| |
3-
3| |// require-rust-edition-2018
3+
3| |// compile-flags: --edition=2018
44
4| |
55
5| 1|async fn c(x: u8) -> u8 {
66
6| 1| if x == 8 {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
1| |// compile-flags: -Zinline-mir
2+
2| |
3+
3| |use std::fmt::Display;
4+
4| |
5+
5| 1|fn main() {
6+
6| 1| permutations(&['a', 'b', 'c']);
7+
7| 1|}
8+
8| |
9+
9| |#[inline(always)]
10+
10| 1|fn permutations<T: Copy + Display>(xs: &[T]) {
11+
11| 1| let mut ys = xs.to_owned();
12+
12| 1| permutate(&mut ys, 0);
13+
13| 1|}
14+
14| |
15+
15| 16|fn permutate<T: Copy + Display>(xs: &mut [T], k: usize) {
16+
16| 16| let n = length(xs);
17+
17| 16| if k == n {
18+
18| 6| display(xs);
19+
19| 10| } else if k < n {
20+
20| 15| for i in k..n {
21+
^10
22+
21| 15| swap(xs, i, k);
23+
22| 15| permutate(xs, k + 1);
24+
23| 15| swap(xs, i, k);
25+
24| 15| }
26+
25| 0| } else {
27+
26| 0| error();
28+
27| 0| }
29+
28| 16|}
30+
29| |
31+
30| 16|fn length<T>(xs: &[T]) -> usize {
32+
31| 16| xs.len()
33+
32| 16|}
34+
33| |
35+
34| |#[inline]
36+
35| 30|fn swap<T: Copy>(xs: &mut [T], i: usize, j: usize) {
37+
36| 30| let t = xs[i];
38+
37| 30| xs[i] = xs[j];
39+
38| 30| xs[j] = t;
40+
39| 30|}
41+
40| |
42+
41| 6|fn display<T: Display>(xs: &[T]) {
43+
42| 18| for x in xs {
44+
43| 18| print!("{}", x);
45+
44| 18| }
46+
45| 6| println!();
47+
46| 6|}
48+
47| |
49+
48| |#[inline(always)]
50+
49| |fn error() {
51+
50| | panic!("error");
52+
51| |}
53+

src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
2020
19| 2|}
2121
------------------
22-
| used_crate::used_only_from_bin_crate_generic_function::<&str>:
22+
| used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
2323
| 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
2424
| 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
2525
| 19| 1|}
2626
------------------
27-
| used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
27+
| used_crate::used_only_from_bin_crate_generic_function::<&str>:
2828
| 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
2929
| 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
3030
| 19| 1|}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<!DOCTYPE html>
2+
<!--
3+
4+
Preview this file as rendered HTML from the github source at:
5+
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inline/inline.display.-------.InstrumentCoverage.0.html
6+
7+
For revisions in Pull Requests (PR):
8+
* Replace "rust-lang" with the github PR author
9+
* Replace "master" with the PR branch name
10+
11+
-->
12+
<html>
13+
<head>
14+
<title>inline.display - Coverage Spans</title>
15+
<style>
16+
.line {
17+
counter-increment: line;
18+
}
19+
.line:before {
20+
content: counter(line) ": ";
21+
font-family: Menlo, Monaco, monospace;
22+
font-style: italic;
23+
width: 3.8em;
24+
display: inline-block;
25+
text-align: right;
26+
filter: opacity(50%);
27+
-webkit-user-select: none;
28+
}
29+
.code {
30+
color: #dddddd;
31+
background-color: #222222;
32+
font-family: Menlo, Monaco, monospace;
33+
line-height: 1.4em;
34+
border-bottom: 2px solid #222222;
35+
white-space: pre;
36+
display: inline-block;
37+
}
38+
.odd {
39+
background-color: #55bbff;
40+
color: #223311;
41+
}
42+
.even {
43+
background-color: #ee7756;
44+
color: #551133;
45+
}
46+
.code {
47+
--index: calc(var(--layer) - 1);
48+
padding-top: calc(var(--index) * 0.15em);
49+
filter:
50+
hue-rotate(calc(var(--index) * 25deg))
51+
saturate(calc(100% - (var(--index) * 2%)))
52+
brightness(calc(100% - (var(--index) * 1.5%)));
53+
}
54+
.annotation {
55+
color: #4444ff;
56+
font-family: monospace;
57+
font-style: italic;
58+
display: none;
59+
-webkit-user-select: none;
60+
}
61+
body:active .annotation {
62+
/* requires holding mouse down anywhere on the page */
63+
display: inline-block;
64+
}
65+
span:hover .annotation {
66+
/* requires hover over a span ONLY on its first line */
67+
display: inline-block;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
<div class="code" style="counter-reset: line 40"><span class="line"><span><span class="code even" style="--layer: 1"><span class="annotation">@0,1⦊</span>fn display&lt;T: Display&gt;(xs: &amp;[T]) <span class="annotation">⦉@0,1</span></span></span><span class="code" style="--layer: 0">{</span></span>
73+
<span class="line"><span class="code" style="--layer: 0"> for </span><span><span class="code odd" style="--layer: 1" title="42:9-42:10: @8[1]: _13 = ((_9 as Some).0: &amp;T)
74+
42:9-42:10: @8[3]: _14 = _13
75+
42:9-42:10: @8[4]: _7 = move _14
76+
42:9-42:10: @8[5]: _8 = const ()
77+
42:9-42:10: @8[13]: FakeRead(ForLet, _16)"><span class="annotation">@6,8,9,10,11⦊</span>x<span class="annotation">⦉@6,8,9,10,11</span></span></span><span class="code" style="--layer: 0"> in </span><span><span class="code odd" style="--layer: 1" title="42:14-42:16: @8[12]: _16 = _7
78+
43:16-43:20: @8[20]: _47 = const display::&lt;T&gt;::promoted[2]
79+
43:16-43:20: @8[21]: _22 = &amp;(*_47)
80+
43:16-43:20: @8[22]: _21 = &amp;(*_22)
81+
43:16-43:20: @8[23]: _20 = move _21 as &amp;[&amp;str] (Pointer(Unsize))
82+
43:22-43:23: @8[31]: _29 = &amp;_16
83+
43:9-43:25: @8[32]: _28 = (move _29,)
84+
43:9-43:25: @8[34]: FakeRead(ForMatchedPlace, _28)
85+
43:9-43:25: @8[36]: _30 = (_28.0: &amp;&amp;T)
86+
43:9-43:25: @8[39]: _32 = &amp;(*_30)
87+
43:9-43:25: @8[41]: _33 = &lt;&amp;T as std::fmt::Display&gt;::fmt as for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;T, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt; (Pointer(ReifyFnPointer))
88+
43:9-43:25: @8.Call: _31 = std::fmt::ArgumentV1::new::&lt;&amp;T&gt;(move _32, move _33) -&gt; [return: bb9, unwind: bb14]
89+
43:9-43:25: @9[2]: _27 = [move _31]
90+
43:9-43:25: @9[5]: _26 = &amp;_27
91+
43:9-43:25: @9[6]: _25 = &amp;(*_26)
92+
43:9-43:25: @9[7]: _24 = move _25 as &amp;[std::fmt::ArgumentV1] (Pointer(Unsize))
93+
43:9-43:25: @9.Call: _19 = std::fmt::Arguments::new_v1(move _20, move _24) -&gt; [return: bb10, unwind: bb14]
94+
43:9-43:25: @10.Call: _18 = std::io::_print(move _19) -&gt; [return: bb11, unwind: bb14]
95+
42:17-44:6: @11[6]: _17 = const ()"><span class="annotation">@6,8,9,10,11⦊</span>xs {</span></span>
96+
<span class="line"><span class="code odd" style="--layer: 1" title="42:14-42:16: @8[12]: _16 = _7
97+
43:16-43:20: @8[20]: _47 = const display::&lt;T&gt;::promoted[2]
98+
43:16-43:20: @8[21]: _22 = &amp;(*_47)
99+
43:16-43:20: @8[22]: _21 = &amp;(*_22)
100+
43:16-43:20: @8[23]: _20 = move _21 as &amp;[&amp;str] (Pointer(Unsize))
101+
43:22-43:23: @8[31]: _29 = &amp;_16
102+
43:9-43:25: @8[32]: _28 = (move _29,)
103+
43:9-43:25: @8[34]: FakeRead(ForMatchedPlace, _28)
104+
43:9-43:25: @8[36]: _30 = (_28.0: &amp;&amp;T)
105+
43:9-43:25: @8[39]: _32 = &amp;(*_30)
106+
43:9-43:25: @8[41]: _33 = &lt;&amp;T as std::fmt::Display&gt;::fmt as for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;T, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt; (Pointer(ReifyFnPointer))
107+
43:9-43:25: @8.Call: _31 = std::fmt::ArgumentV1::new::&lt;&amp;T&gt;(move _32, move _33) -&gt; [return: bb9, unwind: bb14]
108+
43:9-43:25: @9[2]: _27 = [move _31]
109+
43:9-43:25: @9[5]: _26 = &amp;_27
110+
43:9-43:25: @9[6]: _25 = &amp;(*_26)
111+
43:9-43:25: @9[7]: _24 = move _25 as &amp;[std::fmt::ArgumentV1] (Pointer(Unsize))
112+
43:9-43:25: @9.Call: _19 = std::fmt::Arguments::new_v1(move _20, move _24) -&gt; [return: bb10, unwind: bb14]
113+
43:9-43:25: @10.Call: _18 = std::io::_print(move _19) -&gt; [return: bb11, unwind: bb14]
114+
42:17-44:6: @11[6]: _17 = const ()"> print!("{}", x);</span></span>
115+
<span class="line"><span class="code odd" style="--layer: 1" title="42:14-42:16: @8[12]: _16 = _7
116+
43:16-43:20: @8[20]: _47 = const display::&lt;T&gt;::promoted[2]
117+
43:16-43:20: @8[21]: _22 = &amp;(*_47)
118+
43:16-43:20: @8[22]: _21 = &amp;(*_22)
119+
43:16-43:20: @8[23]: _20 = move _21 as &amp;[&amp;str] (Pointer(Unsize))
120+
43:22-43:23: @8[31]: _29 = &amp;_16
121+
43:9-43:25: @8[32]: _28 = (move _29,)
122+
43:9-43:25: @8[34]: FakeRead(ForMatchedPlace, _28)
123+
43:9-43:25: @8[36]: _30 = (_28.0: &amp;&amp;T)
124+
43:9-43:25: @8[39]: _32 = &amp;(*_30)
125+
43:9-43:25: @8[41]: _33 = &lt;&amp;T as std::fmt::Display&gt;::fmt as for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;T, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt; (Pointer(ReifyFnPointer))
126+
43:9-43:25: @8.Call: _31 = std::fmt::ArgumentV1::new::&lt;&amp;T&gt;(move _32, move _33) -&gt; [return: bb9, unwind: bb14]
127+
43:9-43:25: @9[2]: _27 = [move _31]
128+
43:9-43:25: @9[5]: _26 = &amp;_27
129+
43:9-43:25: @9[6]: _25 = &amp;(*_26)
130+
43:9-43:25: @9[7]: _24 = move _25 as &amp;[std::fmt::ArgumentV1] (Pointer(Unsize))
131+
43:9-43:25: @9.Call: _19 = std::fmt::Arguments::new_v1(move _20, move _24) -&gt; [return: bb10, unwind: bb14]
132+
43:9-43:25: @10.Call: _18 = std::io::_print(move _19) -&gt; [return: bb11, unwind: bb14]
133+
42:17-44:6: @11[6]: _17 = const ()"> }<span class="annotation">⦉@6,8,9,10,11</span></span></span><span class="code" style="--layer: 0"></span></span>
134+
<span class="line"><span class="code" style="--layer: 0"> </span><span><span class="code even" style="--layer: 1" title="45:5-45:16: @5[13]: _46 = const display::&lt;T&gt;::promoted[1]
135+
45:5-45:16: @5[14]: _38 = &amp;(*_46)
136+
45:5-45:16: @5[15]: _37 = &amp;(*_38)
137+
45:5-45:16: @5[16]: _36 = move _37 as &amp;[&amp;str] (Pointer(Unsize))
138+
45:5-45:16: @5[22]: _44 = ()
139+
45:5-45:16: @5[23]: FakeRead(ForMatchedPlace, _44)
140+
45:5-45:16: @5[24]: _45 = const display::&lt;T&gt;::promoted[0]
141+
45:5-45:16: @5[25]: _42 = &amp;(*_45)
142+
45:5-45:16: @5[26]: _41 = &amp;(*_42)
143+
45:5-45:16: @5[27]: _40 = move _41 as &amp;[std::fmt::ArgumentV1] (Pointer(Unsize))
144+
45:5-45:16: @5.Call: _35 = std::fmt::Arguments::new_v1(move _36, move _40) -&gt; [return: bb12, unwind: bb14]
145+
45:5-45:16: @12.Call: _34 = std::io::_print(move _35) -&gt; [return: bb13, unwind: bb14]
146+
46:2-46:2: @13.Return: return"><span class="annotation">@5,12,13⦊</span>println!();</span></span>
147+
<span class="line"><span class="code even" style="--layer: 1" title="45:5-45:16: @5[13]: _46 = const display::&lt;T&gt;::promoted[1]
148+
45:5-45:16: @5[14]: _38 = &amp;(*_46)
149+
45:5-45:16: @5[15]: _37 = &amp;(*_38)
150+
45:5-45:16: @5[16]: _36 = move _37 as &amp;[&amp;str] (Pointer(Unsize))
151+
45:5-45:16: @5[22]: _44 = ()
152+
45:5-45:16: @5[23]: FakeRead(ForMatchedPlace, _44)
153+
45:5-45:16: @5[24]: _45 = const display::&lt;T&gt;::promoted[0]
154+
45:5-45:16: @5[25]: _42 = &amp;(*_45)
155+
45:5-45:16: @5[26]: _41 = &amp;(*_42)
156+
45:5-45:16: @5[27]: _40 = move _41 as &amp;[std::fmt::ArgumentV1] (Pointer(Unsize))
157+
45:5-45:16: @5.Call: _35 = std::fmt::Arguments::new_v1(move _36, move _40) -&gt; [return: bb12, unwind: bb14]
158+
45:5-45:16: @12.Call: _34 = std::io::_print(move _35) -&gt; [return: bb13, unwind: bb14]
159+
46:2-46:2: @13.Return: return">}<span class="annotation">⦉@5,12,13</span></span></span></span></div>
160+
</body>
161+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE html>
2+
<!--
3+
4+
Preview this file as rendered HTML from the github source at:
5+
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inline/inline.error.-------.InstrumentCoverage.0.html
6+
7+
For revisions in Pull Requests (PR):
8+
* Replace "rust-lang" with the github PR author
9+
* Replace "master" with the PR branch name
10+
11+
-->
12+
<html>
13+
<head>
14+
<title>inline.error - Coverage Spans</title>
15+
<style>
16+
.line {
17+
counter-increment: line;
18+
}
19+
.line:before {
20+
content: counter(line) ": ";
21+
font-family: Menlo, Monaco, monospace;
22+
font-style: italic;
23+
width: 3.8em;
24+
display: inline-block;
25+
text-align: right;
26+
filter: opacity(50%);
27+
-webkit-user-select: none;
28+
}
29+
.code {
30+
color: #dddddd;
31+
background-color: #222222;
32+
font-family: Menlo, Monaco, monospace;
33+
line-height: 1.4em;
34+
border-bottom: 2px solid #222222;
35+
white-space: pre;
36+
display: inline-block;
37+
}
38+
.odd {
39+
background-color: #55bbff;
40+
color: #223311;
41+
}
42+
.even {
43+
background-color: #ee7756;
44+
color: #551133;
45+
}
46+
.code {
47+
--index: calc(var(--layer) - 1);
48+
padding-top: calc(var(--index) * 0.15em);
49+
filter:
50+
hue-rotate(calc(var(--index) * 25deg))
51+
saturate(calc(100% - (var(--index) * 2%)))
52+
brightness(calc(100% - (var(--index) * 1.5%)));
53+
}
54+
.annotation {
55+
color: #4444ff;
56+
font-family: monospace;
57+
font-style: italic;
58+
display: none;
59+
-webkit-user-select: none;
60+
}
61+
body:active .annotation {
62+
/* requires holding mouse down anywhere on the page */
63+
display: inline-block;
64+
}
65+
span:hover .annotation {
66+
/* requires hover over a span ONLY on its first line */
67+
display: inline-block;
68+
}
69+
</style>
70+
</head>
71+
<body>
72+
<div class="code" style="counter-reset: line 48"><span class="line"><span><span class="code even" style="--layer: 1" title="50:5-50:21: @0.Call: std::rt::begin_panic::&lt;&amp;str&gt;(const &quot;error&quot;) -&gt; bb1
73+
49:12-51:2: @1.Resume: resume"><span class="annotation">@0,1⦊</span>fn error() {</span></span>
74+
<span class="line"><span class="code even" style="--layer: 1" title="50:5-50:21: @0.Call: std::rt::begin_panic::&lt;&amp;str&gt;(const &quot;error&quot;) -&gt; bb1
75+
49:12-51:2: @1.Resume: resume"> panic!("error");</span></span>
76+
<span class="line"><span class="code even" style="--layer: 1" title="50:5-50:21: @0.Call: std::rt::begin_panic::&lt;&amp;str&gt;(const &quot;error&quot;) -&gt; bb1
77+
49:12-51:2: @1.Resume: resume">}<span class="annotation">⦉@0,1</span></span></span></span></div>
78+
</body>
79+
</html>

0 commit comments

Comments
 (0)