about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/infer/resolve.rs
diff options
context:
space:
mode:
authorPiotr Osiewicz <24362066+osiewicz@users.noreply.github.com>2025-03-14 22:49:08 +0100
committerPiotr Osiewicz <24362066+osiewicz@users.noreply.github.com>2025-04-28 22:52:51 +0200
commitb15584b1a3882a3d21f65261ccb6331b62bf1c58 (patch)
treec619d2614eb707a1b23a6637144aab6e1f15bfd6 /compiler/rustc_infer/src/infer/resolve.rs
parent10fa3c449f6b1613b352a6cbf78d3d91fd9a1d81 (diff)
downloadrust-b15584b1a3882a3d21f65261ccb6331b62bf1c58.tar.gz
rust-b15584b1a3882a3d21f65261ccb6331b62bf1c58.zip
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>
Diffstat (limited to 'compiler/rustc_infer/src/infer/resolve.rs')
0 files changed, 0 insertions, 0 deletions