-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit b15584b
shared-generics: Do not share instantiations that cannot be created outside of the current crate
In Zed shared-generics loading takes up a significant chunk of time in incremental build, as rustc deserializes rmeta of all dependencies of a crate.
I've recently realized that shared-generics includes all instantiations of some_generic_function in the following snippet:
```rs
pub fn some_generic_function(_: impl Fn()) {}
pub fn non_generic_function() {
some_generic_function(|| {});
some_generic_function(|| {});
some_generic_function(|| {});
some_generic_function(|| {});
some_generic_function(|| {});
some_generic_function(|| {});
some_generic_function(|| {});
}
```
even though none of these instantiations can actually be created from outside of `non_generic_function`.
This PR makes shared-generics account for visibilities of generic arguments; an item is only considered for exporting if it is reachable from the outside or if all of it's arguments are visible outside of the local crate.
This PR reduces incremental build time for Zed (touch edito.rs scenario) from 12.4s to 10.4s.
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>1 parent 10fa3c4 commit b15584b
1 file changed
+59
-12
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
164 | 164 |
| |
165 | 165 |
| |
166 | 166 |
| |
167 | - | ||
168 | - | ||
167 | + | ||
168 | + | ||
169 | 169 |
| |
170 | - | ||
170 | + | ||
171 | 171 |
| |
172 | 172 |
| |
173 | 173 |
| |
| |||
321 | 321 |
| |
322 | 322 |
| |
323 | 323 |
| |
324 | + | ||
325 | + | ||
326 | + | ||
327 | + | ||
328 | + | ||
329 | + | ||
330 | + | ||
331 | + | ||
332 | + | ||
333 | + | ||
334 | + | ||
335 | + | ||
336 | + | ||
337 | + | ||
338 | + | ||
339 | + | ||
340 | + | ||
341 | + | ||
342 | + | ||
343 | + | ||
344 | + | ||
345 | + | ||
346 | + | ||
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | ||
351 | + | ||
352 | + | ||
353 | + | ||
354 | + | ||
355 | + | ||
324 | 356 |
| |
325 | 357 |
| |
326 | 358 |
| |
| |||
349 | 381 |
| |
350 | 382 |
| |
351 | 383 |
| |
352 | - | ||
384 | + | ||
385 | + | ||
386 | + | ||
387 | + | ||
388 | + | ||
389 | + | ||
353 | 390 |
| |
354 | 391 |
| |
355 | 392 |
| |
| |||
364 | 401 |
| |
365 | 402 |
| |
366 | 403 |
| |
367 | - | ||
368 | - | ||
369 | - | ||
370 | - | ||
371 | - | ||
372 | - | ||
373 | - | ||
374 | - | ||
404 | + | ||
405 | + | ||
406 | + | ||
407 | + | ||
408 | + | ||
409 | + | ||
410 | + | ||
411 | + | ||
412 | + | ||
413 | + | ||
414 | + | ||
415 | + | ||
416 | + | ||
417 | + | ||
418 | + | ||
419 | + | ||
420 | + | ||
421 | + | ||
375 | 422 |
| |
376 | 423 |
| |
377 | 424 |
| |
|
0 commit comments