rust/compiler/rustc_codegen_ssa
Piotr Osiewicz b15584b1a3 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>
2025-04-28 22:52:51 +02:00
..
src shared-generics: Do not share instantiations that cannot be created outside of the current crate 2025-04-28 22:52:51 +02:00
Cargo.toml bump thorin to drop duped deps 2025-03-24 19:38:16 +03:00
messages.ftl Rollup merge of #137953 - RalfJung:simd-intrinsic-masks, r=WaffleLapkin 2025-04-20 13:02:48 +00:00
README.md mv compiler to compiler/ 2020-08-30 18:45:07 +03:00

Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.