This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 058a710
committed
Auto merge of rust-lang#79670 - Nadrieril:uninhabited-query, r=estebank
Turn type inhabitedness into a query to fix `exhaustive_patterns` perf
We measured in rust-lang#79394 that enabling the [`exhaustive_patterns` feature](rust-lang#51085) causes significant perf degradation. It was conjectured that the culprit is type inhabitedness checking, and [I hypothesized](rust-lang#79394 (comment)) that turning this computation into a query would solve most of the problem.
This PR turns `tcx.is_ty_uninhabited_from` into a query, and I measured a 25% perf gain on the benchmark that stress-tests `exhaustiveness_patterns`. This more than compensates for the 30% perf hit I measured [when creating it](rust-lang/rustc-perf#801). We'll have to measure enabling the feature again, but I suspect this fixes the perf regression entirely.
I'd like a perf run on this PR obviously.
I made small atomic commits to help reviewing. The first one is just me discovering the "revisions" feature of the testing framework.
I believe there's a push to move things out of `rustc_middle` because it's huge. I guess `inhabitedness/mod.rs` could be moved out, but it's quite small. `DefIdForest` might be movable somewhere too. I don't know what the policy is for that.
Ping `@camelid` since you were interested in following along
`@rustbot` modify labels: +A-exhaustiveness-checkingFile tree
15 files changed
+557
-516
lines changed- compiler/rustc_middle/src
- query
- ty
- inhabitedness
- src/test/ui/pattern/usefulness
- auxiliary
- integer-ranges
15 files changed
+557
-516
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1319 | 1319 | | |
1320 | 1320 | | |
1321 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
1322 | 1331 | | |
1323 | 1332 | | |
1324 | 1333 | | |
| |||
Lines changed: 77 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
22 | 35 | | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
27 | | - | |
| 40 | + | |
28 | 41 | | |
29 | 42 | | |
30 | 43 | | |
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
34 | | - | |
35 | | - | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
43 | 70 | | |
44 | 71 | | |
45 | 72 | | |
46 | 73 | | |
47 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
48 | 83 | | |
49 | 84 | | |
50 | 85 | | |
51 | 86 | | |
52 | | - | |
| 87 | + | |
53 | 88 | | |
54 | 89 | | |
55 | 90 | | |
| |||
58 | 93 | | |
59 | 94 | | |
60 | 95 | | |
61 | | - | |
62 | | - | |
| 96 | + | |
| 97 | + | |
63 | 98 | | |
64 | 99 | | |
65 | 100 | | |
66 | 101 | | |
67 | | - | |
68 | | - | |
| 102 | + | |
69 | 103 | | |
70 | 104 | | |
71 | | - | |
72 | | - | |
| 105 | + | |
| 106 | + | |
73 | 107 | | |
74 | 108 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
83 | 113 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 114 | + | |
| 115 | + | |
88 | 116 | | |
89 | | - | |
| 117 | + | |
90 | 118 | | |
91 | 119 | | |
92 | 120 | | |
93 | 121 | | |
94 | 122 | | |
95 | 123 | | |
96 | 124 | | |
97 | | - | |
98 | | - | |
| 125 | + | |
| 126 | + | |
99 | 127 | | |
100 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
101 | 132 | | |
102 | | - | |
103 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
104 | 138 | | |
105 | 139 | | |
106 | 140 | | |
107 | 141 | | |
108 | | - | |
109 | | - | |
| 142 | + | |
| 143 | + | |
110 | 144 | | |
111 | | - | |
| 145 | + | |
112 | 146 | | |
113 | 147 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
187 | 186 | | |
188 | 187 | | |
189 | 188 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
195 | 197 | | |
196 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
197 | 207 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 208 | + | |
202 | 209 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
209 | 214 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
217 | | - | |
218 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
219 | 230 | | |
220 | 231 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3155 | 3155 | | |
3156 | 3156 | | |
3157 | 3157 | | |
| 3158 | + | |
3158 | 3159 | | |
3159 | 3160 | | |
3160 | 3161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments